baekjoon 20260122

This commit is contained in:
songyc macbook 2026-01-22 18:26:25 +09:00
parent c1c2d04eb9
commit 0a8c4f38aa
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,56 @@
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
ll val[5000];
ll res[3];
ll minSumAbs = 5000000000000;
int compare(const void* a, const void* b) {
ll num1 = *(const ll*)a;
ll num2 = *(const ll*)b;
if (num1 > num2) return 1;
if (num1 < num2) return -1;
return 0;
}
void set_res(ll a, ll b, ll c) {
res[0] = a;
res[1] = b;
res[2] = c;
}
int main() {
int N;
scanf("%d",&N);
for(int i=0; i<N; i++) scanf("%lld",&val[i]);
qsort(val, N, sizeof(ll), compare);
for(int fix = 0; fix<N-2; fix++) {
ll a = val[fix];
int l = fix+1, r = N-1;
while(l < r) {
ll b = val[l], c = val[r];
ll current_sum = a + b + c;
ll current_abs = llabs(current_sum);
if(minSumAbs > current_abs) {
minSumAbs = current_abs;
set_res(a,b,c);
}
if(current_sum < 0) l++;
else r--;
}
}
for(int i=0; i<3; i++) printf("%lld%s",res[i], i==2 ? "\n" : " ");
return 0;
}

View File

@ -0,0 +1 @@
print(chr(int(input())-1 + 44032))