From 08e9aa7427c87e26583abad78241701572dbc0f3 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Tue, 14 May 2024 11:21:21 +0900 Subject: [PATCH] complete 1448.cpp --- run.py | 2 +- zeta_C/{ => completed}/1620.c | 0 zeta_cpp/completed/1448.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) rename zeta_C/{ => completed}/1620.c (100%) create mode 100644 zeta_cpp/completed/1448.cpp diff --git a/run.py b/run.py index 31d127e..68c0d69 100644 --- a/run.py +++ b/run.py @@ -27,7 +27,7 @@ class ProblemRunEnum: zeta_C: ProblemRunType = ProblemRunType( name="zeta_C", dir="./zeta_C", - runner="gcc -std=c11 {source} && ./a.out < {input}", + runner="gcc -std=c11 {source} && a.out", prefix="c", ) zeta_cpp: ProblemRunType = ProblemRunType( diff --git a/zeta_C/1620.c b/zeta_C/completed/1620.c similarity index 100% rename from zeta_C/1620.c rename to zeta_C/completed/1620.c diff --git a/zeta_cpp/completed/1448.cpp b/zeta_cpp/completed/1448.cpp new file mode 100644 index 0000000..f624eb9 --- /dev/null +++ b/zeta_cpp/completed/1448.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +using namespace std; + +int get_max(int N, int *S) { + for (int i = 0; i < N - 2; i++) { + if (S[i] < S[i + 1] + S[i + 2]) return S[i] + S[i + 1] + S[i + 2]; + } + return -1; +} + +int main() { + + int N; + int S[1000000]; + + cin >> N; + + for (int i = 0; i < N; i++) { + cin >> S[i]; + } + + sort(S, S + N, greater<>()); + + cout << get_max(N, S) << endl; + + return 0; +} \ No newline at end of file