提出 #72363804
ソースコード 拡げる
#include<bits/stdc++.h>
#define LL long long
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define int LL
using namespace std;
inline void solve() {
int n, q; cin >> n >> q;
vector<LL> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a.begin() + 1, a.end());
while (q--) {
LL x, y; cin >> x >> y;
int pre = lower_bound(a.begin() + 1, a.end(), x) - a.begin() - 1;
LL l = x + y - 1; LL r = l + n + 5, out;
while (l <= r) {
LL mid = (l + r) >> 1;
int cnt = upper_bound(a.begin() + 1, a.end(), mid) - a.begin() - 1;
LL val = mid - x + 1 - (cnt - pre);
// cout << mid << " " << cnt << " " << val << "\n";
if (a[cnt] == mid && val == y) val++;
if (val == y) {
out = mid;
break;
} else if (val < y) l = mid + 1;
else r = mid - 1;
}
cout << out << "\n";
}
}
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) solve();
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Forbidden List 2 |
| ユーザ | C202627yehan |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 400 |
| コード長 | 1020 Byte |
| 結果 | AC |
| 実行時間 | 497 ms |
| メモリ | 5796 KiB |
コンパイルエラー
In member function 'operator<<',
inlined from 'solve' at ./Main.cpp:30:11,
inlined from 'main' at ./Main.cpp:37:19:
/opt/atcoder/gcc/include/c++/15.2.0/bits/ostream.h:212:25: warning: 'out' may be used uninitialized [-Wmaybe-uninitialized]
212 | { return _M_insert(__n); }
| ^
./Main.cpp: In function 'main':
./Main.cpp:17:53: note: 'out' was declared here
17 | LL l = x + y - 1; LL r = l + n + 5, out;
| ^
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-sample-01.txt | AC | 4 ms | 3576 KiB |
| 00-sample-02.txt | AC | 1 ms | 3524 KiB |
| 01-01.txt | AC | 2 ms | 3452 KiB |
| 01-02.txt | AC | 2 ms | 3536 KiB |
| 01-03.txt | AC | 2 ms | 3428 KiB |
| 01-04.txt | AC | 2 ms | 3484 KiB |
| 01-05.txt | AC | 3 ms | 3664 KiB |
| 01-06.txt | AC | 3 ms | 3672 KiB |
| 01-07.txt | AC | 2 ms | 3580 KiB |
| 01-08.txt | AC | 4 ms | 3652 KiB |
| 01-09.txt | AC | 4 ms | 3580 KiB |
| 01-10.txt | AC | 3 ms | 3672 KiB |
| 01-11.txt | AC | 3 ms | 3672 KiB |
| 01-12.txt | AC | 3 ms | 3612 KiB |
| 01-13.txt | AC | 213 ms | 5528 KiB |
| 01-14.txt | AC | 336 ms | 5796 KiB |
| 01-15.txt | AC | 356 ms | 5784 KiB |
| 01-16.txt | AC | 88 ms | 4196 KiB |
| 01-17.txt | AC | 497 ms | 5736 KiB |
| 01-18.txt | AC | 318 ms | 4836 KiB |
| 01-19.txt | AC | 184 ms | 5780 KiB |
| 01-20.txt | AC | 224 ms | 5664 KiB |