提出 #31456137
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
using ll = long long;
int main() {
multiset<ll> a;
int q; cin >> q;
while (q--) {
ll c, x;
cin >> c >> x;
if (c == 1) {
a.insert(x);
continue;
}
ll k; cin >> k;
ll ans = -2;
if (c == 3) {
auto it = a.lower_bound(x);
rep(i, k-1) {
if (it == a.end()) {
ans = -1;
break;
}
it++;
}
if (ans != -1 && it != a.end()) ans = *it;
else ans = -1;
}
else {
auto it = a.upper_bound(x);
rep(i, k) {
if (it == a.begin()) {
ans = -1;
break;
}
it--;
}
// if (ans != -1 && it != prev(a.begin())) ans = *it;
if (ans != -1) ans = *it;
else ans = -1;
}
cout << ans << endl;
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Sequence Query |
| ユーザ | Jessica_nao_ |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 400 |
| コード長 | 1138 Byte |
| 結果 | AC |
| 実行時間 | 401 ms |
| メモリ | 12940 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, add000.txt, add001.txt, add002.txt, add003.txt, add004.txt, add005.txt, example0.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 343 ms | 6620 KiB |
| 001.txt | AC | 341 ms | 6580 KiB |
| 002.txt | AC | 340 ms | 6520 KiB |
| 003.txt | AC | 342 ms | 6708 KiB |
| 004.txt | AC | 343 ms | 6504 KiB |
| 005.txt | AC | 318 ms | 6572 KiB |
| 006.txt | AC | 319 ms | 6660 KiB |
| 007.txt | AC | 314 ms | 6596 KiB |
| 008.txt | AC | 337 ms | 6696 KiB |
| 009.txt | AC | 333 ms | 6628 KiB |
| 010.txt | AC | 332 ms | 6532 KiB |
| 011.txt | AC | 341 ms | 6584 KiB |
| 012.txt | AC | 339 ms | 6704 KiB |
| 013.txt | AC | 338 ms | 6520 KiB |
| 014.txt | AC | 395 ms | 3512 KiB |
| 015.txt | AC | 396 ms | 3372 KiB |
| 016.txt | AC | 401 ms | 3572 KiB |
| 017.txt | AC | 147 ms | 12884 KiB |
| 018.txt | AC | 148 ms | 12896 KiB |
| 019.txt | AC | 148 ms | 12932 KiB |
| 020.txt | AC | 260 ms | 8252 KiB |
| 021.txt | AC | 257 ms | 8220 KiB |
| add000.txt | AC | 151 ms | 12752 KiB |
| add001.txt | AC | 139 ms | 12940 KiB |
| add002.txt | AC | 143 ms | 12936 KiB |
| add003.txt | AC | 152 ms | 12928 KiB |
| add004.txt | AC | 147 ms | 12896 KiB |
| add005.txt | AC | 147 ms | 12936 KiB |
| example0.txt | AC | 2 ms | 3576 KiB |