Submission #00203


ソースコード

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
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(),(x).end()
#define inf 1001001001
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if(a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if(b < a) {a = b; return true;} return false; }
//================================================================================================
int main(){
int n, m, ans = 0;
cin >> n >> m;
queue<int> kane;
int home[n + 1] = {};
for(int i = 0; i < m; i++){
int zei, place;
cin >> zei >> place;
home[place] = zei;
}
for(int i = 1; i <= n; i++){
if(home[i] > 0){
kane.push(home[i]);
ans += home[i];
}else if(!kane.empty()){
ans += kane.front();
kane.push(kane.front());
kane.pop();
}
}
cout << ans << endl;
return(0);
}

ステータス

項目 データ
問題 0007 - 税の徴収
ユーザー名 ei2212
投稿日時 2023-08-28 11:34:17
言語 C++17
状態 Accepted
得点 30
ソースコード長 1071 Byte
最大実行時間 49 ms
最大メモリ使用量 1332 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1 AC 20 ms 604 KB
1
in2 AC 21 ms 524 KB
1
in3 AC 21 ms 616 KB
1
in4 AC 18 ms 584 KB
1
in5 AC 24 ms 684 KB
1
in6 AC 26 ms 660 KB
1
in7 AC 30 ms 628 KB
1
in8 AC 25 ms 596 KB
1
in9 AC 21 ms 568 KB
1
in10 AC 18 ms 448 KB
1
in11 AC 19 ms 548 KB
1
in12 AC 17 ms 644 KB
1
in13 AC 17 ms 612 KB
1
in14 AC 17 ms 584 KB
1
in15 AC 22 ms 432 KB
1
in16 AC 22 ms 664 KB
1
in17 AC 21 ms 500 KB
1
in18 AC 27 ms 968 KB
1
in19 AC 21 ms 936 KB
1
in20 AC 27 ms 1008 KB
1
in21 AC 42 ms 1192 KB
1
in22 AC 49 ms 1332 KB
1
in23 AC 20 ms 932 KB
1
in24 AC 22 ms 904 KB
1