Submission #00127


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define lol long long
#define inf INT_MAX
#define mk(f,s) make_pair(f,s)
#define P pair<int,int>
#define fi first
#define se second
#define Deg2Rad (M_PI*2)/360
#define Rad2Deg 360/(M_PI*2)
int n,q;
int now = 0;
vector<int> inl;
vector<bool> inb(2*10000+10,false);
vector<stack<int>> stacks(2*100000+10);
vector<int> ans;
int main(){
cin>>n>>q;
for(int i=0;i<q;i++){
int a;
cin>>a;
if(a == 1){
int k,c;
cin>>k>>c;
stacks[k-1].push(c);
if(!inb[k]){
inb[k] = true;
inl.push_back(k-1);
sort(inl.begin(),inl.end());
}
}else{
//now = *upper_bound(inl.begin(),inl.end(),now);
now++;
while(stacks[now].empty()){
now = *upper_bound(inl.begin(),inl.end(),now);
}
ans.push_back(stacks[now].top());
stacks[now].pop();
}
}
for(int i=0;i<ans.size();i++){
cout<<ans[i]<<"\n";
}
return(0);
}

ステータス

項目 データ
問題 0005 - Stacking Books
ユーザー名 ei2007
投稿日時 2021-04-07 14:38:26
言語 C++17
状態 Time Limit Exceeded
得点 0
ソースコード長 1139 Byte
最大実行時間 2000 ms
最大メモリ使用量 142320 KB

セット

セット 得点 Cases
1 ALL 0 / 22 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt TLE 2000 ms 135004 KB
1
in02.txt TLE 2000 ms 135088 KB
1
in03.txt TLE 2000 ms 135060 KB
1
in04.txt TLE 2000 ms 134916 KB
1
in05.txt TLE 2000 ms 134892 KB
1
in06.txt TLE 2000 ms 135004 KB
1
in07.txt TLE 2000 ms 134808 KB
1
in08.txt TLE 2000 ms 134796 KB
1
in09.txt TLE 2000 ms 134896 KB
1
in10.txt TLE 2000 ms 134884 KB
1
in11.txt TLE 2000 ms 134996 KB
1
in12.txt TLE 2000 ms 134976 KB
1
in13.txt TLE 2000 ms 135092 KB
1
in14.txt TLE 2000 ms 134892 KB
1
in15.txt TLE 2000 ms 134880 KB
1
in16.txt TLE 2000 ms 134872 KB
1
in17.txt AC 183 ms 136260 KB
1
in18.txt TLE 2000 ms 135728 KB
1
in19.txt TLE 2000 ms 135976 KB
1
in20.txt TLE 2000 ms 135784 KB
1
in21.txt TLE 2000 ms 136012 KB
1
in22.txt TLE 2000 ms 136124 KB
1
in23.txt RE 212 ms 136636 KB
1
in24.txt AC 185 ms 136696 KB
1
in25.txt AC 150 ms 137380 KB
1
in26.txt AC 163 ms 138372 KB
1
in27.txt AC 155 ms 139108 KB
1
in28.txt AC 164 ms 140104 KB
1
in29.txt AC 87 ms 139700 KB
1
in30.txt AC 95 ms 139680 KB
1
in31.txt TLE 2000 ms 139796 KB
1
in32.txt AC 152 ms 141384 KB
1
in33.txt AC 170 ms 142320 KB
1
in34.txt TLE 2000 ms 141808 KB
1
sample01.txt AC 92 ms 141700 KB
1
sample02.txt AC 83 ms 141688 KB
1