結果
問題 | No.649 ここでちょっとQK! |
ユーザー | matsukin1111 |
提出日時 | 2019-06-21 14:53:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 287 ms / 3,000 ms |
コード長 | 2,184 bytes |
コンパイル時間 | 952 ms |
コンパイル使用メモリ | 101,576 KB |
実行使用メモリ | 8,792 KB |
最終ジャッジ日時 | 2023-08-26 06:03:14 |
合計ジャッジ時間 | 7,349 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 287 ms
4,376 KB |
testcase_04 | AC | 178 ms
8,792 KB |
testcase_05 | AC | 179 ms
8,744 KB |
testcase_06 | AC | 168 ms
7,480 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 113 ms
5,980 KB |
testcase_13 | AC | 113 ms
5,640 KB |
testcase_14 | AC | 111 ms
5,712 KB |
testcase_15 | AC | 112 ms
5,776 KB |
testcase_16 | AC | 110 ms
5,640 KB |
testcase_17 | AC | 122 ms
6,080 KB |
testcase_18 | AC | 133 ms
6,240 KB |
testcase_19 | AC | 145 ms
6,496 KB |
testcase_20 | AC | 157 ms
6,868 KB |
testcase_21 | AC | 169 ms
7,004 KB |
testcase_22 | AC | 181 ms
7,428 KB |
testcase_23 | AC | 191 ms
7,704 KB |
testcase_24 | AC | 202 ms
7,956 KB |
testcase_25 | AC | 214 ms
8,136 KB |
testcase_26 | AC | 226 ms
8,464 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 2 ms
4,380 KB |
testcase_29 | AC | 2 ms
4,380 KB |
testcase_30 | AC | 78 ms
5,440 KB |
testcase_31 | AC | 76 ms
5,432 KB |
testcase_32 | AC | 2 ms
4,376 KB |
testcase_33 | AC | 2 ms
4,376 KB |
testcase_34 | AC | 1 ms
4,376 KB |
testcase_35 | AC | 1 ms
4,376 KB |
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include <cstdlib> #include <math.h> #include <cmath> #include<cctype> #include<string> #include<set> #include<iomanip> #include <map> #include<algorithm> #include <functional> #include<vector> #include<climits> #include<stack> #include<queue> #include<bitset> #include <deque> #include <climits> #include <typeinfo> #include <utility> using namespace std; using ll = long long; using R = double; using Data = pair < ll, vector <ll>>; template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 60; struct edge { ll from; ll to; ll cost; }; typedef pair<ll, ll>pll; #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(ll i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(ll i = m;i >= n;--i) #define INF INT_MAX/2 template<typename T> struct BIT { int n; vector<T>dat; BIT(int n = 0) { initialize(n); } void initialize(int temp) { n = temp; dat.resize(n); rep(i, 0, n)dat[i] = 0; } T sum(int i) { T s = 0; while (i >= 0) { s += dat[i]; i = (i & (i + 1)) - 1; } return s; } T sum_between(int i, int j) { if (i > j)return 0; return sum(j) - sum(i-1); } void plus(int i ,T x) { while (i < n) { dat[i] += x; i |= i + 1; } } int lower_bound(T x) { if (sum(n - 1) < x)return -1; else if (sum(0) >= x)return 0; int ng = 0, ok = n - 1; while (ok - ng > 1) { int mid = (ok + ng) / 2; if (sum(mid) >= x)ok = mid; else ng = mid; } return ok; } }; int T[202020]; ll A[202020]; int main() { int Q, K; cin >> Q >> K; vector<ll>dic; rep(i, 0, Q) { cin >> T[i]; if (T[i] == 1) { cin >> A[i]; dic.pb(A[i]); } } sort(all(dic)); dic.erase(unique(all(dic)),dic.end()); BIT<ll>bitnum(dic.size()); rep(i, 0, Q) { if (T[i] == 1) { ll a = A[i]; int ind = lower_bound(all(dic),A[i])-dic.begin(); bitnum.plus(ind, 1LL); } else { int ind = bitnum.lower_bound(K); if (ind == -1) { cout << -1 << endl; } else { bitnum.plus(ind, -1LL); cout << dic[ind] << endl; } } } return 0; }