QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#498600#6693. Fast and FatInk_baiWA 0ms3592kbC++202.4kb2024-07-30 16:33:022024-07-30 16:33:02

Judging History

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

  • [2024-07-30 16:33:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-07-30 16:33:02]
  • 提交

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 == 9995)
        {
            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: 3468kb

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: 3592kb

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
n29810469108 305218916468608188 728428678827457716 772370072802358145 470855168314367531 812837974433130259 942468735990797348 355798010619017288 306156409360713246 287781043805508585 331147128776585419 291139077704877362 477387929492658321 662560328919808595 ...

result:

wrong output format Expected integer, but "n29810469108" found