Submission #00128


ソースコード

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
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
priority_queue<ll,vector<ll>,greater<ll>>bag;
ll m,q;cin >>m>>q;
for(int i=0;i<q;i++){
int query,a;cin >>query;
if(query==1){
cin >>a;
bag.push(a);
if(bag.size()>m){
bag.pop();
}
}else{
if(!bag.empty()){
ll ans=0;
priority_queue<ll,vector<ll>,greater<ll>>co;
for(int j=0;j<m;j++){
co.push(bag.top());
ans+=bag.top();
bag.pop();
}
for(int j=0;j<m;j++){
bag.push(co.top());
co.pop();
}
cout <<ans<<"\n";
}else{
cout <<"0\n";
}
}
}
}

ステータス

項目 データ
問題 0006 - 宝集め
ユーザー名 yu184743
投稿日時 2024-07-18 15:59:34
言語 C++17
状態 Runtime Error
得点 0
ソースコード長 871 Byte
最大実行時間 200 ms
最大メモリ使用量 2640 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 21 ms 476 KB
1
in2.txt RE 200 ms 2580 KB
1
in3.txt RE 31 ms 2640 KB
1
in4.txt RE 33 ms 408 KB
1
in5.txt AC 104 ms 504 KB
1
in6.txt AC 114 ms 600 KB
1
in7.txt RE 29 ms 700 KB
1
in8.txt RE 31 ms 668 KB
1
in9.txt RE 32 ms 772 KB
1
in10.txt AC 25 ms 440 KB
1