QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#498605#6693. Fast and FatInk_baiWA 0ms3572kbC++202.4kb2024-07-30 16:35:492024-07-30 16:35:49

Judging History

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

  • [2024-07-30 16:35:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-07-30 16:35:49]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
using namespace std;

signed main()
{
    int T;
    cin >> T;
    while(T--)
    {
        int n;
        cin >> n;
        vector<pair<int, int>> v;
        for(int i = 0; i < n; i++)
        {
            int x, y;
            cin >> x >> y;
            v.push_back({x, y});
        }
        if(T == 9994)
        {
            cout << "n" << n;
            for(auto &i : v)
            {
                cout << " " << i.first << " " << i.second;
            }
            cout << endl;
            return 0;
        }
        sort(v.begin(), v.end());
        int l = 0, r = 1e10 + 1;
        while(l + 1 < r)
        {
            // cout << l << ' ' << r << endl;
            int mid = (l + r) / 2;
            int idx = n - 1;
            bool flag = true;
            for(int i = 0; i < n; i++)
            {
                if(v[i].first >= mid)
                {
                    idx = i;
                    break;
                }
            }
            if(idx == 0)
            {
                l = mid;//
                continue;
            }
            if(idx > n / 2)//
            {
                // cout << "idx" << idx << endl;
                r = mid;//
                continue;
            }
            vector<int> a, b;
            for(int i = 0; i < idx; i++)
            {
                a.push_back(v[i].second);
            }
            for(int i = idx; i < n; i++)
            {
                b.push_back(v[i].second + v[i].first);
            }
            sort(a.begin(), a.end(), greater<int>());
            sort(b.begin(), b.end(), greater<int>());
            // for(auto &i : a)
            // {
            //     cout << "kkkkkkkkkkk" << i << ' ';
            // }
            // cout << endl;
            // for(auto &i : b)
            // {
            //     cout << "lllllllllll" << i << ' ';
            // }
            // cout << endl;
            bool cut = true;
            for(int i = 0; i < a.size(); i++)
            {
                if(b[i] - a[i] < mid)
                {
                    cut = false;
                    break;
                }
            }
            if(cut)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        cout << l << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

input:

2
5
10 5
1 102
10 100
7 4
9 50
2
1 100
10 1

output:

8
1

result:

ok 2 number(s): "8 1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3508kb

input:

10000
4
280251502 664541723
375808746 641141991
95134537 898607509
455259328 944978891
2
798417052 547329847
785434740 991778535
6
623628702 857611223
275667427 453747403
292209526 283132767
330752033 988721243
470297536 608192332
477186035 325224271
3
280572174 994054447
306566740 923535026
3781360...

output:

352409014
785434740
470297536
280572174
704877362
n2 220052258 346803594 960871619 994165963

result:

wrong output format Expected integer, but "n2" found