Submission #29716164
Source Code Expand
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,k,n) for (int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
void query(multiset<ll> &s, ll sign) {
ll x, k;
cin >> x >> k;
auto it = s.lower_bound(sign * x);
if (it == s.end()) {
cout << -1 << endl;
return;
}
int rem = k - 1;
while (it != s.end() && rem) {
it++;
rem--;
}
if (it == s.end()) cout << -1 << endl;
else cout << sign * (*it) << endl;
}
void solve() {
int q;
cin >> q;
multiset<ll> s2, s3;
rep(i,q) {
ll t;
cin >> t;
if (t == 1) {
ll x;
cin >> x;
s2.insert(-x);
s3.insert(x);
} else if (t == 2) {
query(s2, -1);
} else {
query(s3, 1);
}
}
}
int main() {
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Sequence Query |
| User | goropikari |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 1175 Byte |
| Status | AC |
| Exec Time | 388 ms |
| Memory | 22340 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 374 ms | 9752 KiB |
| 001.txt | AC | 370 ms | 9704 KiB |
| 002.txt | AC | 371 ms | 9856 KiB |
| 003.txt | AC | 365 ms | 9696 KiB |
| 004.txt | AC | 372 ms | 9768 KiB |
| 005.txt | AC | 333 ms | 9748 KiB |
| 006.txt | AC | 327 ms | 9876 KiB |
| 007.txt | AC | 322 ms | 9828 KiB |
| 008.txt | AC | 349 ms | 9884 KiB |
| 009.txt | AC | 353 ms | 9800 KiB |
| 010.txt | AC | 350 ms | 9852 KiB |
| 011.txt | AC | 364 ms | 9848 KiB |
| 012.txt | AC | 366 ms | 9812 KiB |
| 013.txt | AC | 364 ms | 9752 KiB |
| 014.txt | AC | 385 ms | 3556 KiB |
| 015.txt | AC | 383 ms | 3452 KiB |
| 016.txt | AC | 388 ms | 3612 KiB |
| 017.txt | AC | 253 ms | 22316 KiB |
| 018.txt | AC | 253 ms | 22180 KiB |
| 019.txt | AC | 243 ms | 22200 KiB |
| 020.txt | AC | 274 ms | 12880 KiB |
| 021.txt | AC | 275 ms | 12796 KiB |
| add000.txt | AC | 207 ms | 22312 KiB |
| add001.txt | AC | 190 ms | 22284 KiB |
| add002.txt | AC | 198 ms | 22300 KiB |
| add003.txt | AC | 212 ms | 22288 KiB |
| add004.txt | AC | 193 ms | 22340 KiB |
| add005.txt | AC | 204 ms | 22316 KiB |
| example0.txt | AC | 3 ms | 3512 KiB |