File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments