QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#418385 | #6693. Fast and Fat | OneWan# | WA | 399ms | 6624kb | C++23 | 1.0kb | 2024-05-23 13:30:36 | 2024-05-23 13:30:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int __OneWan_2024 = [](){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
return 0;
}();
void sol() {
int n;
cin >> n;
vector<int>v(n), w(n);
for (int i = 0; i < n; i++)
cin >> v[i] >> w[i];
int l = 1, r = 1e9;
auto check = [&](int mid) {
vector<int>c1;
set<int>st;
for (int i = 0; i < n; i++) {
if(v[i] < mid) c1.push_back(w[i]);
else {
st.insert(v[i] - mid + w[i]);
}
}
for (int i = 0; i < c1.size(); i++) {
auto pos = st.lower_bound(c1[i]);
if(pos == st.end()) return false;
st.erase(pos);
}
return true;
};
while(l < r) {
int mid = l + r + 1 >> 1;
if(check(mid)) l = mid;
else r = mid - 1;
}
cout << l << endl;
}
int main() {
int t;
cin >> t;
while(t--)
sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
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: 0
Accepted
time: 93ms
memory: 3540kb
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 960871619 691253609 560579095 136979645 399988835 610497257 576427565 636500913 315900406 370430730 526259135 781258283 631916852 300930080 419999540 431930706 479323438 530080165 391912906 708925499 467782812 457987604 389750718 447390353 696516804 ...
result:
ok 10000 numbers
Test #3:
score: 0
Accepted
time: 120ms
memory: 3652kb
input:
400 908 33362229 606508747 632419478 324326751 257284260 336303174 457246243 986284341 542591728 520499949 519145521 971093641 633038285 374866966 137832222 929747560 626840805 488847915 750542462 328721976 928847956 932651817 479954326 140789806 794986794 212084514 372002273 933710809 173161453 119...
output:
504394967 484359492 469225546 475096879 595868798 497700736 456321846 407898878 591377003 568847769 747288891 512226022 532505353 472511102 511795703 477459477 529231318 472548529 525635770 487622149 510138466 527879972 504505269 498990235 475265402 514165957 449627768 450001628 349076692 507182026 ...
result:
ok 400 numbers
Test #4:
score: 0
Accepted
time: 284ms
memory: 4400kb
input:
10 20711 764663709 192212865 55777289 890465487 406536728 278177638 204765968 477730025 379283253 654167175 41026104 774138002 875860206 465532238 934199361 38168843 545038187 933648246 99831648 715642411 984100235 592340109 870539197 676140250 2503522 500646009 813801461 79167382 531368117 16295473...
output:
499001302 509703433 508081053 500768234 505503494 508790115 506879049 472330839 499777658 493607522
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 290ms
memory: 4652kb
input:
5 28172 644161572 775630724 644996423 77402453 959618325 764663709 192212865 55777289 890465487 406536728 278177638 204765968 477730025 379283253 654167175 41026104 774138002 875860206 465532238 934199361 38168843 545038187 933648246 99831648 715642411 984100235 592340109 870539197 676140250 2503522...
output:
500467154 499019830 502230846 506222919 497700052
result:
ok 5 number(s): "500467154 499019830 502230846 506222919 497700052"
Test #6:
score: 0
Accepted
time: 399ms
memory: 6624kb
input:
1 100000 288393588 839718077 938561398 470676893 644161572 775630724 644996423 77402453 959618325 764663709 192212865 55777289 890465487 406536728 278177638 204765968 477730025 379283253 654167175 41026104 774138002 875860206 465532238 934199361 38168843 545038187 933648246 99831648 715642411 984100...
output:
501283249
result:
ok 1 number(s): "501283249"
Test #7:
score: -100
Wrong Answer
time: 62ms
memory: 3880kb
input:
10000 4 2 23 46 91 37 9 28 91 2 52 47 40 35 6 2 23 27 3 26 67 33 43 36 32 35 71 3 74 47 40 26 5 35 29 8 16 88 78 16 72 45 68 31 74 59 35 48 10 88 9 46 43 85 28 19 77 62 29 21 28 95 6 84 98 65 36 90 5 29 86 65 2 20 36 9 31 5 52 71 95 26 28 87 48 48 58 24 60 42 92 90 81 2 58 94 19 63 4 24 66 11 82 9 7...
output:
28 52 33 40 42 58 19 46 45 55 30 41 53 61 6 34 11 52 73 48 40 58 57 28 65 46 41 49 53 45 50 51 53 61 62 55 72 65 54 47 4 47 19 31 39 84 66 58 58 85 50 37 45 35 37 54 62 56 82 40 61 13 42 40 32 70 51 77 44 38 86 35 48 21 86 64 50 44 62 62 35 40 49 66 27 12 47 54 70 66 44 58 67 47 70 28 80 58 57 68 61...
result:
wrong answer 5th numbers differ - expected: '45', found: '42'