UVa10050

題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=991

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
38
39
40
41
42
43
#include <iostream>

using namespace std;

int main(){
int t;
cin >> t;
int days;
int parties;
while(t--){
cin >> days >> parties;
int p[parties + 5] = {0};
bool h[days + 5] = {false};

for(int i=0; i<parties; ++i) cin >> p[i];

for(int i=0; i<parties; ++i){
int divide = 1;
for(int j=0; j<days; ++j){
if(p[i] == divide){
h[j] = true;
divide = 1;
}
else ++divide;
}
}

for(int i=0; i<days; i+=7){
h[5+i] = false;
h[6+i] = false;
}

int hartals = 0;
for(int i=0; i<days; ++i){
if(h[i] == true){
++hartals;
}
}

cout << hartals << '\n';
}
return 0;
}