QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#498586 | #6693. Fast and Fat | Ink_bai | WA | 101ms | 3804kb | C++20 | 2.2kb | 2024-07-30 16:21:27 | 2024-07-30 16:21:30 |
Judging History
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});
}
sort(v.begin(), v.end());
int l = 0, r = 1e9 + 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: 3804kb
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: 101ms
memory: 3596kb
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 1000000000 691253609 560579095 1000000000 399988835 610497257 576427565 636500913 643310127 370430730 526259135 781258283 631916852 300930080 419999540 431930706 479323438 530080165 391912906 708925499 467782812 457987604 389750718 447390353 69651680...
result:
wrong answer 6th numbers differ - expected: '960871619', found: '1000000000'