QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#383413 | #6693. Fast and Fat | Susie_Rain# | WA | 47ms | 3540kb | C++17 | 2.1kb | 2024-04-09 13:43:47 | 2024-04-09 13:43:47 |
Judging History
answer
#include <bits/stdc++.h>
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
// gp_hash_table<int, bool> hs;
#define bit1(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define lowbit(i) ((i) & -(i))
#define ull unsigned long long
#define int long long
// #define ll long long
#define Genshin return
#define Impact 0
#define endl '\n'
using namespace std;
const int mod = 998244353;
const int N = 2e5 + 10;
int ksm(int base, int n)
{
int res = 1;
while (n > 0)
{
if (n & 1)
res = (res * base) % mod;
base = (base * base) % mod;
n >>= 1;
}
return res;
}
int n;
pair<int, int> a[100010];
bool cmp(pair<int, int> x, pair<int, int> y)
{
return x.first + x.second < y.first + y.second;
}
bool check(int k)
{
vector<bool> b(n + 1);
vector<pair<int, int>> c;
for (int i = 1; i <= n; i++)
{
if (a[i].second < k)
{
b[i] = 1;
}
else
{
c.push_back(a[i]);
}
}
sort(all(c), cmp);
int j = n, i = c.size() - 1;
while (i > 0 && j > 0)
{
while (j > 0 && b[j] == 0)
{
j--;
}
if (j <= 0)
break;
while (i > 0 && (c[i].second - max(0LL, a[j].first - c[i].first)) < k)
{
i--;
}
if (i <= 0)
break;
j--;
}
if (j <= 0)
return 1;
return 0;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i].second >> a[i].first;
}
sort(a + 1, a + n + 1);
int l = 1, r = 1e9;
int ans = 1;
while (l <= r)
{
int mid = (l + r) >> 1;
if (check(mid))
{
ans = mid;
l = mid + 1;
}
else
{
r = mid - 1;
}
}
cout << ans << endl;
return;
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int tt = 1;
cin >> tt;
while (tt--)
{
solve();
}
Genshin Impact;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
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: 47ms
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:
375808746 785434740 477186035 280572174 754572396 220052258 691253609 947133410 1 751423030 715111359 657783621 636500913 287404882 602613612 585398985 781258283 631916852 300930080 764546586 667381564 568779862 549843088 602104420 708925499 692529559 712523962 579492507 447390353 696516804 71182627...
result:
wrong answer 1st numbers differ - expected: '352409014', found: '375808746'