QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#534302#1172. Junkyeom's Contest36champWA 0ms3592kbC++201.1kb2024-08-27 01:28:452024-08-27 01:28:46

Judging History

你现在查看的是最新测评结果

  • [2024-08-27 01:28:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-08-27 01:28:45]
  • 提交

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'