-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.1.cpp
More file actions
109 lines (99 loc) · 1.51 KB
/
Copy path2.1.cpp
File metadata and controls
109 lines (99 loc) · 1.51 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
FILE *fp = fopen("2.1.txt", "w");
freopen("2in.txt", "r", stdin);
int t;
cin >> t;
int w[101];
int n;
for (int i = 1; i <= t; i++) {
cin >> n;
for (int j = 1; j <= n; j++) {
cin >> w[j];
}
sort(w+1, w + n+1);
int count = 0;
int z=n;
int a = 1;
while (a <= z) { //counting should end when everything was counted
if (w[z] >= 50) {
z--;
count++;
}
else if (w[z] >= 25) {
z--;
a++;
count++;
}
else if (w[z] >= 17) {
z--;
a += 2;
count++;
}
else if (w[z] >= 13) {
z--;
a += 3;
count++;
}
else if (w[z] >= 10) {
z--;
a += 4;
count++;
}
else if (w[z] >= 9) {
z--;
a += 5;
count++;
}
else if (w[z] >= 8) {
z--;
a += 6;
count++;
}
else if (w[z] >= 7) {
z--;
a += 7;
count++;
}
else if (w[z] >= 6) {
z--;
a += 8;
count++;
}
else if (w[z] >= 5) {
z--;
a += 9;
count++;
}
else if (w[z] >= 4) {
z--;
a += 12;
count++;
}
else if (w[z] >= 3) {
z--;
a += 16;
count++;
}
else if (w[z] >= 2) {
z--;
a += 24;
count++;
}
else if (w[z] >= 1) {
z--;
a += 49;
count++;
}
if(z+1<a){ //when counting ends, check whether or not it exceeded the n
count--;
}
}
printf("Case #%d: %d\n",i, count);
fprintf(fp, "Case #%d: %d\n",i, count);
}
}