Submission #79628


ソースコード

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
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<limits.h>
#include<string>
#define ll long long
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<utility>
#include<unordered_set>
#include<map>
using namespace std;
int main(){
priority_queue<ll,vector<ll>,greater<ll>>bag;
ll m,q,sum=0,co=0;cin >>m>>q;
for(int i=0;i<q;i++){
ll e;cin >>e;
if(e==1){
ll a;
cin >>a;
bag.push(a);
co++;
sum+=a;
if(co>m){
co--;
sum-=bag.top();
bag.pop();
}
}else{
cout <<sum<<"\n";
}
}
}

ステータス

項目 データ
問題 1796 - 宝集め
ユーザー名 yu184743
投稿日時 2024-07-09 17:02:54
言語 C++17
状態 Accepted
得点 100
ソースコード長 766 Byte
最大実行時間 167 ms
最大メモリ使用量 3160 KB

セット

セット 得点 Cases
1 ALL 100 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 25 ms 472 KB
1
in2.txt AC 167 ms 2968 KB
1
in3.txt AC 140 ms 3160 KB
1
in4.txt AC 139 ms 1568 KB
1
in5.txt AC 114 ms 1664 KB
1
in6.txt AC 118 ms 1896 KB
1
in7.txt AC 111 ms 1864 KB
1
in8.txt AC 56 ms 1960 KB
1
in9.txt AC 60 ms 2188 KB
1
in10.txt AC 19 ms 448 KB
1