QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#383409 | #6693. Fast and Fat | Susie_Rain# | WA | 77ms | 3644kb | C++17 | 1.9kb | 2024-04-09 13:37:15 | 2024-04-09 13:37:15 |
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 check(int k)
{
vector<bool> b(n + 1);
for (int i = 1; i <= n; i++)
{
if (a[i].second < k)
{
b[i] = 1;
}
}
int j = n, i = n;
while (i > 0 && j > 0)
{
while (j > 0 && b[j] == 0)
{
j--;
}
if (j <= 0)
break;
while (i > 0 && (b[i] == 1 || (a[i].second - max(0LL, a[j].first - a[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;
// cout << check(9) << endl;
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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
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: 77ms
memory: 3588kb
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'