QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418604#6693. Fast and Fatbible_w#WA 61ms3532kbC++201.1kb2024-05-23 14:44:422024-05-23 14:44:42

Judging History

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

  • [2024-05-23 14:44:42]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:3532kb
  • [2024-05-23 14:44:42]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

void solve(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);

    for (auto &[v,w] : a){
        cin >> v >> w;
    }

    auto calc = [&](int x)->bool{
        vector<int> s,b;
        for (auto [v,w] : a){
            if (v < x) s.push_back(w);
            else
                b.push_back(w + v - x);
        }
        sort(s.begin(),s.end());
        sort(b.begin(),b.end());
        int i,j;
        for (i = 0,j = 0;i < s.size() && j < b.size();){
            while (j < b.size() && s[i] > b[j])
                j++;
            if (j < b.size() && s[i] <= b[j]) i++;
        }
        if (i == s.size()) return true;
        return false;
    };

    int l = 0 ,r = 1e9 + 7;
    while (l + 1 < r){
        int mid = l + r >> 1;
        if (calc(mid)) l = mid;
        else
            r = mid;
    }

    cout << l << "\n";
}

int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

    while (t--){
        solve();
    }

	return 0;
}

详细

Test #1:

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

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: 61ms
memory: 3532kb

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:

455259328
785434740
492518682
280572174
754572396
960871619
852497327
947133410
136979645
751423030
715111359
657783621
636500913
315900406
602613612
711095784
781258283
631916852
355137761
764546586
812952251
568779862
657739840
602104420
720993110
692529559
745319288
579492507
798382479
696516804
...

result:

wrong answer 1st numbers differ - expected: '352409014', found: '455259328'