Submission #66107
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | //#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } bool inmap( int x, int y, int mx, int my) { return (x >= 0 && y >= 0 && x < mx && y < my); } typedef long long ll; typedef vector< int > vint; typedef pair< int , int > pint; typedef vector< long long > vlong; typedef vector<string> vstring; #define vpush(a,x) a.push_back(x); #define rep(i, n) REP(i, 0, n) #define all(v) v.begin(), v.end() #define REP(i, x, n) for(int i = x; i < n; i++) const int INF = 1 << 30; const int dx[] = {1,0,-1,0,1,1,-1,-1}; const int dy[] = {0,-1,0,1,1,-1,-1,1}; #define stp(x) setprecision(x) const long double PI=3.14159265358979323846264338327950; int main(){ cin.tie(nullptr); ios::sync_with_stdio( false ); int n,q; cin>>n>>q; vector<stack< int > > box(n+1); set< int > S; int now=1; rep(i,q){ int query,k,c; cin>>query; if (query==1){ cin>>k>>c; if (box[k].empty()){ S.insert(k); } box[k].push(c); } else { auto flag=S.upper_bound(now); if (flag==S.end()){ flag=S.begin(); } cout<<box[*flag].top()<< '\n' ; box[*flag].pop(); now=*flag; if (box[*flag].empty()){ S.erase(*flag); } } } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 1411 - Stacking Books |
ユーザー名 | ei1918 |
投稿日時 | 2021-04-09 17:44:44 |
言語 | C++17 |
状態 | Accepted |
得点 | 4 |
ソースコード長 | 1475 Byte |
最大実行時間 | 204 ms |
最大メモリ使用量 | 167608 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 4 / 4 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 121 ms | 68956 KB |
1
|
in02.txt | AC | 99 ms | 109584 KB |
1
|
in03.txt | AC | 75 ms | 51640 KB |
1
|
in04.txt | AC | 86 ms | 91256 KB |
1
|
in05.txt | AC | 116 ms | 132524 KB |
1
|
in06.txt | AC | 155 ms | 138072 KB |
1
|
in07.txt | AC | 140 ms | 139028 KB |
1
|
in08.txt | AC | 147 ms | 140120 KB |
1
|
in09.txt | AC | 130 ms | 141076 KB |
1
|
in10.txt | AC | 159 ms | 141924 KB |
1
|
in11.txt | AC | 143 ms | 142868 KB |
1
|
in12.txt | AC | 143 ms | 143972 KB |
1
|
in13.txt | AC | 138 ms | 144940 KB |
1
|
in14.txt | AC | 142 ms | 145904 KB |
1
|
in15.txt | AC | 140 ms | 146844 KB |
1
|
in16.txt | AC | 131 ms | 147800 KB |
1
|
in17.txt | AC | 127 ms | 148664 KB |
1
|
in18.txt | AC | 124 ms | 149660 KB |
1
|
in19.txt | AC | 123 ms | 150648 KB |
1
|
in20.txt | AC | 123 ms | 151000 KB |
1
|
in21.txt | AC | 146 ms | 151476 KB |
1
|
in22.txt | AC | 204 ms | 157432 KB |
1
|
in23.txt | AC | 127 ms | 152376 KB |
1
|
in24.txt | AC | 131 ms | 152292 KB |
1
|
in25.txt | AC | 43 ms | 18060 KB |
1
|
in26.txt | AC | 48 ms | 19028 KB |
1
|
in27.txt | AC | 45 ms | 19864 KB |
1
|
in28.txt | AC | 46 ms | 20832 KB |
1
|
in29.txt | AC | 31 ms | 35752 KB |
1
|
in30.txt | AC | 24 ms | 20876 KB |
1
|
in31.txt | AC | 163 ms | 159964 KB |
1
|
in32.txt | AC | 43 ms | 23324 KB |
1
|
in33.txt | AC | 123 ms | 158656 KB |
1
|
in34.txt | AC | 165 ms | 167608 KB |
1
|
sample01.txt | AC | 22 ms | 23796 KB |
1
|
sample02.txt | AC | 26 ms | 23876 KB |
1
|