QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591513 | #6693. Fast and Fat | Foedere0 | WA | 68ms | 3616kb | C++14 | 1.4kb | 2024-09-26 16:15:47 | 2024-09-26 16:15:48 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 1000010;
typedef pair<int, int> PII;
struct node
{
int v, w;
} a[N];
int n;
bool cmp(node x, node y)
{
return x.v > y.v;
}
bool check(int mid)
{
priority_queue<int> o;
priority_queue<int> p;
for (int i = 1; i <= n; i++)
{
if (a[i].v >= mid)
{
o.push(a[i].v + a[i].w - mid);
// cout << o.top() << endl;
}
else
p.push(a[i].w);
}
if (o.size() <= 0)
{
return false;
}
while (p.size())
{
if (o.top() >= p.top())
{
o.pop();
p.pop();
}
else
return false;
}
return true;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i].v >> a[i].w;
}
int l = 0, r = 1e9 + 10;
// sort(a + 1, a + 1 + n, cmp);
while (l < r)
{
int mid = (l + r + 1) / 2;
if (check(mid))
{
l = mid;
}
else
r = mid - 1;
// cout << l << " " << r << endl;
}
cout << l << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 68ms
memory: 3560kb
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 492518682 280572174 715034188 960871619 852497327 562160123 136979645 516531284 610497257 576427565 636500913 315900406 370430730 711095784 781258283 631916852 355137761 565869556 431930706 532872190 657739840 391912906 720993110 467782812 745319288 389750718 798382479 696516804 ...
result:
wrong answer 3rd numbers differ - expected: '470297536', found: '492518682'