Submission #784689

# Submission time Handle Problem Language Result Execution time Memory
784689 2023-07-16T12:20:21 Z oscar1f Council (JOI23_council) C++17
41 / 100
4000 ms 34656 KB
#include<bits/stdc++.h>
using namespace std;

const int MAX_PERS=300*1000+5,MAX_PROP=22,MAX_VAL=(1<<20);

int nbPers,nbChoix,rep,val,bascule,minPerdu;
int choix[MAX_PERS][MAX_PROP];
int somme[MAX_PROP];
int nbOccu[MAX_VAL];

int compte1(int nb) {
	int nb1=0;
	while (nb>0) {
		nb1+=nb%2;
		nb/=2;
	}
	return nb1;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>nbPers>>nbChoix;
	for (int i=0;i<nbPers;i++) {
		for (int j=0;j<nbChoix;j++) {
			cin>>choix[i][j];
			somme[j]+=choix[i][j];
		}
	}
	if (nbPers<=3000) {
		for (int i=0;i<nbPers;i++) {
			rep=0;
			for (int j=0;j<nbPers;j++) {
				if (i!=j) {
					val=0;
					for (int k=0;k<nbChoix;k++) {
						if (somme[k]-choix[i][k]-choix[j][k]>=nbPers/2) {
							val++;
						}
					}
					rep=max(rep,val);
				}
			}
			cout<<rep<<"\n";
		}
	}
	else {
		for (int i=0;i<nbPers;i++) {
			val=0;
			for (int j=0;j<nbChoix;j++) {
				val+=(1<<j)*choix[i][j];
			}
			nbOccu[val]++;
		}
		for (int i=0;i<nbPers;i++) {
			rep=0;
			minPerdu=nbChoix;
			bascule=0;
			val=0;
			for (int j=0;j<nbChoix;j++) {
				val+=(1<<j)*choix[i][j];
				if (somme[j]-choix[i][j]>=nbPers/2) {
					rep++;
					if (somme[j]-choix[i][j]-1<nbPers/2) {
						bascule+=(1<<j);
					}
				}
			}
			nbOccu[val]--;
			for (int j=0;j<(1<<nbChoix);j++) {
				if (nbOccu[j]>0) {
					minPerdu=min(minPerdu,compte1(j&bascule));
				}
			}
			nbOccu[val]++;
			cout<<rep-minPerdu<<"\n";
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 206 ms 580 KB Output is correct
52 Correct 207 ms 596 KB Output is correct
53 Correct 211 ms 596 KB Output is correct
54 Correct 208 ms 596 KB Output is correct
55 Correct 23 ms 596 KB Output is correct
56 Correct 179 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 52 ms 26700 KB Output is correct
3 Correct 51 ms 27852 KB Output is correct
4 Correct 41 ms 27288 KB Output is correct
5 Correct 55 ms 27892 KB Output is correct
6 Correct 42 ms 27336 KB Output is correct
7 Correct 58 ms 27812 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 52 ms 26700 KB Output is correct
3 Correct 51 ms 27852 KB Output is correct
4 Correct 41 ms 27288 KB Output is correct
5 Correct 55 ms 27892 KB Output is correct
6 Correct 42 ms 27336 KB Output is correct
7 Correct 58 ms 27812 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 711 ms 32500 KB Output is correct
21 Correct 440 ms 32020 KB Output is correct
22 Correct 454 ms 32000 KB Output is correct
23 Correct 255 ms 32876 KB Output is correct
24 Correct 274 ms 32608 KB Output is correct
25 Correct 453 ms 32512 KB Output is correct
26 Correct 1496 ms 32600 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 52 ms 26700 KB Output is correct
3 Correct 51 ms 27852 KB Output is correct
4 Correct 41 ms 27288 KB Output is correct
5 Correct 55 ms 27892 KB Output is correct
6 Correct 42 ms 27336 KB Output is correct
7 Correct 58 ms 27812 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 711 ms 32500 KB Output is correct
21 Correct 440 ms 32020 KB Output is correct
22 Correct 454 ms 32000 KB Output is correct
23 Correct 255 ms 32876 KB Output is correct
24 Correct 274 ms 32608 KB Output is correct
25 Correct 453 ms 32512 KB Output is correct
26 Correct 1496 ms 32600 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Execution timed out 4054 ms 34656 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 52 ms 26700 KB Output is correct
3 Correct 51 ms 27852 KB Output is correct
4 Correct 41 ms 27288 KB Output is correct
5 Correct 55 ms 27892 KB Output is correct
6 Correct 42 ms 27336 KB Output is correct
7 Correct 58 ms 27812 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 711 ms 32500 KB Output is correct
21 Correct 440 ms 32020 KB Output is correct
22 Correct 454 ms 32000 KB Output is correct
23 Correct 255 ms 32876 KB Output is correct
24 Correct 274 ms 32608 KB Output is correct
25 Correct 453 ms 32512 KB Output is correct
26 Correct 1496 ms 32600 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Execution timed out 4054 ms 34656 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 206 ms 580 KB Output is correct
52 Correct 207 ms 596 KB Output is correct
53 Correct 211 ms 596 KB Output is correct
54 Correct 208 ms 596 KB Output is correct
55 Correct 23 ms 596 KB Output is correct
56 Correct 179 ms 588 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 52 ms 26700 KB Output is correct
59 Correct 51 ms 27852 KB Output is correct
60 Correct 41 ms 27288 KB Output is correct
61 Correct 55 ms 27892 KB Output is correct
62 Correct 42 ms 27336 KB Output is correct
63 Correct 58 ms 27812 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 0 ms 340 KB Output is correct
68 Correct 1 ms 328 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 340 KB Output is correct
72 Correct 1 ms 328 KB Output is correct
73 Correct 23 ms 596 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 711 ms 32500 KB Output is correct
77 Correct 440 ms 32020 KB Output is correct
78 Correct 454 ms 32000 KB Output is correct
79 Correct 255 ms 32876 KB Output is correct
80 Correct 274 ms 32608 KB Output is correct
81 Correct 453 ms 32512 KB Output is correct
82 Correct 1496 ms 32600 KB Output is correct
83 Correct 1 ms 340 KB Output is correct
84 Correct 1 ms 212 KB Output is correct
85 Correct 1 ms 336 KB Output is correct
86 Correct 0 ms 340 KB Output is correct
87 Correct 1 ms 340 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 212 KB Output is correct
91 Correct 1 ms 340 KB Output is correct
92 Correct 2 ms 340 KB Output is correct
93 Correct 0 ms 212 KB Output is correct
94 Correct 1 ms 340 KB Output is correct
95 Correct 1 ms 340 KB Output is correct
96 Correct 1 ms 340 KB Output is correct
97 Correct 0 ms 340 KB Output is correct
98 Correct 1 ms 340 KB Output is correct
99 Correct 1 ms 212 KB Output is correct
100 Correct 1 ms 340 KB Output is correct
101 Correct 1 ms 340 KB Output is correct
102 Correct 1 ms 340 KB Output is correct
103 Execution timed out 4054 ms 34656 KB Time limit exceeded
104 Halted 0 ms 0 KB -