QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#534302 | #1172. Junkyeom's Contest | 36champ | WA | 0ms | 3592kb | C++20 | 1.1kb | 2024-08-27 01:28:45 | 2024-08-27 01:28:46 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++) cin >> a[i];
sort(a.begin(), a.end());
int ans = -1;
for(int i = n - 1; i >= 6; i--)
{
int l1 = i - 1, r1 = n - 2, target = a[i - 3] + a[i - 4] + a[i - 5] + a[i - 6] - a[i - 2];
while(l1 != r1)
{
int m = (l1 + r1 + 1) / 2;
if(a[m] >= target) r1 = m - 1;
else l1 = m;
}
if(a[l1] + a[i-2] >= a[i-3] + a[i-4] + a[i-5] + a[i-6]) continue;
int l0 = l1 + 1, r0 = n - 1;
target = a[i-2] + a[l1];
while(l0 != r0)
{
int m = (l0 + r0 + 1) / 2;
if(a[m] >= target) r0 = m - 1;
else l0 = m;
}
if(a[l0] >= a[l1] + a[i-2]) continue;
ans = a[l0] + a[l1] + a[i-2] + a[i-3] + a[i-4] + a[i-5];
break;
}
cout << ans;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
7 1 2 3 4 5 6 7
output:
-1
result:
ok 1 number(s): "-1"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
8 1 2 3 4 5 6 7 8
output:
33
result:
wrong answer 1st numbers differ - expected: '35', found: '33'