complete 1448.cpp

This commit is contained in:
2024-05-14 11:21:21 +09:00
parent 9533b4be09
commit 08e9aa7427
3 changed files with 31 additions and 1 deletions

2
run.py
View File

@@ -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(

View File

@@ -0,0 +1,30 @@
#include <algorithm>
#include <functional>
#include <iostream>
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;
}