Skip to content

Commit 36e1f8b

Browse files
authored
Merge pull request #542 from dmsgk/master
도둑
2 parents 4464172 + 21ade20 commit 36e1f8b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

dmsgk/week50/13422_도둑.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// 13422_도둑.cpp
3+
// AlgorithmCpp
4+
//
5+
// Created by Johyeon Yoon on 2021/09/02.
6+
//
7+
8+
#include <iostream>
9+
#include <queue>
10+
using namespace std;
11+
12+
int t;
13+
int money[100001];
14+
15+
int main(){
16+
ios_base::sync_with_stdio(false);
17+
cin.tie(NULL); cout.tie(NULL);
18+
19+
cin >> t;
20+
for (int i=0; i<t; i++){
21+
int n, m, k;
22+
cin >> n >> m >> k;
23+
24+
for (int j=0; j<n; j++){
25+
cin >> money[j];
26+
}
27+
28+
int cnt = 0, robbed_sum = 0;
29+
queue<int> q;
30+
for (int k = 0; k<m; k++){
31+
q.push(money[k]);
32+
robbed_sum += money[k];
33+
}
34+
35+
if (robbed_sum < k) {
36+
cnt ++;
37+
}
38+
39+
if (n!=m){
40+
for (int i=1; i<n; i++){
41+
int prev = q.front();
42+
int now = money[(i+m-1)%n];
43+
robbed_sum += (now - prev);
44+
q.pop();
45+
q.push(now);
46+
47+
if (robbed_sum < k){
48+
cnt += 1;
49+
}
50+
}
51+
}
52+
cout << cnt << "\n";
53+
}
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)