Submission #784704

# Submission time Handle Problem Language Result Execution time Memory
784704 2023-07-16T12:39:36 Z oscar1f Council (JOI23_council) C++17
41 / 100
4000 ms 27040 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 val1[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<(1<<nbChoix);i++) {
			val1[i]=compte1(i);
		}
		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,val1[j&bascule]);
				}
			}
			nbOccu[val]++;
			cout<<rep-minPerdu<<"\n";
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 2 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 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 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 360 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 2 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 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 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 360 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 149 ms 576 KB Output is correct
52 Correct 162 ms 596 KB Output is correct
53 Correct 152 ms 596 KB Output is correct
54 Correct 150 ms 580 KB Output is correct
55 Correct 23 ms 604 KB Output is correct
56 Correct 128 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 57 ms 26756 KB Output is correct
3 Correct 52 ms 26740 KB Output is correct
4 Correct 42 ms 26744 KB Output is correct
5 Correct 56 ms 26708 KB Output is correct
6 Correct 44 ms 26756 KB Output is correct
7 Correct 59 ms 26672 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 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 57 ms 26756 KB Output is correct
3 Correct 52 ms 26740 KB Output is correct
4 Correct 42 ms 26744 KB Output is correct
5 Correct 56 ms 26708 KB Output is correct
6 Correct 44 ms 26756 KB Output is correct
7 Correct 59 ms 26672 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 485 ms 26852 KB Output is correct
21 Correct 313 ms 26676 KB Output is correct
22 Correct 315 ms 26704 KB Output is correct
23 Correct 361 ms 27040 KB Output is correct
24 Correct 342 ms 26644 KB Output is correct
25 Correct 459 ms 26712 KB Output is correct
26 Correct 464 ms 26768 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 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 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 57 ms 26756 KB Output is correct
3 Correct 52 ms 26740 KB Output is correct
4 Correct 42 ms 26744 KB Output is correct
5 Correct 56 ms 26708 KB Output is correct
6 Correct 44 ms 26756 KB Output is correct
7 Correct 59 ms 26672 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 485 ms 26852 KB Output is correct
21 Correct 313 ms 26676 KB Output is correct
22 Correct 315 ms 26704 KB Output is correct
23 Correct 361 ms 27040 KB Output is correct
24 Correct 342 ms 26644 KB Output is correct
25 Correct 459 ms 26712 KB Output is correct
26 Correct 464 ms 26768 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 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 2 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Execution timed out 4088 ms 26700 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 57 ms 26756 KB Output is correct
3 Correct 52 ms 26740 KB Output is correct
4 Correct 42 ms 26744 KB Output is correct
5 Correct 56 ms 26708 KB Output is correct
6 Correct 44 ms 26756 KB Output is correct
7 Correct 59 ms 26672 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 23 ms 596 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 485 ms 26852 KB Output is correct
21 Correct 313 ms 26676 KB Output is correct
22 Correct 315 ms 26704 KB Output is correct
23 Correct 361 ms 27040 KB Output is correct
24 Correct 342 ms 26644 KB Output is correct
25 Correct 459 ms 26712 KB Output is correct
26 Correct 464 ms 26768 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 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 2 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Execution timed out 4088 ms 26700 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 2 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 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 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 360 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 149 ms 576 KB Output is correct
52 Correct 162 ms 596 KB Output is correct
53 Correct 152 ms 596 KB Output is correct
54 Correct 150 ms 580 KB Output is correct
55 Correct 23 ms 604 KB Output is correct
56 Correct 128 ms 596 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 57 ms 26756 KB Output is correct
59 Correct 52 ms 26740 KB Output is correct
60 Correct 42 ms 26744 KB Output is correct
61 Correct 56 ms 26708 KB Output is correct
62 Correct 44 ms 26756 KB Output is correct
63 Correct 59 ms 26672 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 0 ms 340 KB Output is correct
66 Correct 0 ms 340 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 23 ms 596 KB Output is correct
74 Correct 0 ms 212 KB Output is correct
75 Correct 0 ms 340 KB Output is correct
76 Correct 485 ms 26852 KB Output is correct
77 Correct 313 ms 26676 KB Output is correct
78 Correct 315 ms 26704 KB Output is correct
79 Correct 361 ms 27040 KB Output is correct
80 Correct 342 ms 26644 KB Output is correct
81 Correct 459 ms 26712 KB Output is correct
82 Correct 464 ms 26768 KB Output is correct
83 Correct 1 ms 212 KB Output is correct
84 Correct 1 ms 212 KB Output is correct
85 Correct 1 ms 212 KB Output is correct
86 Correct 1 ms 212 KB Output is correct
87 Correct 1 ms 340 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 212 KB Output is correct
91 Correct 0 ms 340 KB Output is correct
92 Correct 1 ms 364 KB Output is correct
93 Correct 1 ms 212 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 1 ms 340 KB Output is correct
97 Correct 1 ms 212 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 2 ms 340 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Execution timed out 4088 ms 26700 KB Time limit exceeded
104 Halted 0 ms 0 KB -