# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
632628 |
2022-08-20T13:14:49 Z |
Richem |
Self Study (JOI22_ho_t2) |
C++14 |
|
403 ms |
11452 KB |
#include <iostream>
#define int long long
using namespace std;
const int MAX_COURS = 3e5+42, INF = 1e18;
int nbCours, nbSemaine;
int cours[MAX_COURS][2];
void input() {
cin >> nbCours >> nbSemaine;
for(int k = 0; k < 2; k++) {
for(int i = 0; i < nbCours; i++)
cin >> cours[i][k];
}
for(int i = 0; i < nbCours; i++)
cours[i][0] = max(cours[i][0], cours[i][1]);
}
int calc(int petit, int grand) {
int rep = grand / petit;
if(rep * petit < grand)
rep++;
return rep;
}
int nbRestant[MAX_COURS];
bool possible(int k) {
int nbDispo = nbCours * nbSemaine;
for(int cur = 0; cur < nbCours; cur++) {
if(k <= cours[cur][0] * nbSemaine) {
nbDispo -= calc(cours[cur][0], k);
}
else {
int restant = k - nbSemaine * cours[cur][0];
nbDispo = nbDispo - nbSemaine - calc(cours[cur][1], restant);
if(nbDispo < 0) return 0;
}
}
return nbDispo >= 0;
}
int dicho(int deb, int fin) {
while(deb < fin) {
int milieu = (deb + fin+1) / 2;
if(possible(milieu))
deb = milieu;
else
fin = milieu-1;
}
return deb;
}
signed main() {
input();
cout << dicho(0, INF);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
247 ms |
5748 KB |
Output is correct |
12 |
Correct |
261 ms |
5748 KB |
Output is correct |
13 |
Correct |
183 ms |
5744 KB |
Output is correct |
14 |
Correct |
174 ms |
5364 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
80 ms |
6112 KB |
Output is correct |
17 |
Correct |
263 ms |
11420 KB |
Output is correct |
18 |
Correct |
249 ms |
10660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
80 ms |
6112 KB |
Output is correct |
3 |
Correct |
263 ms |
11420 KB |
Output is correct |
4 |
Correct |
249 ms |
10660 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
128 ms |
3412 KB |
Output is correct |
14 |
Correct |
96 ms |
2568 KB |
Output is correct |
15 |
Correct |
65 ms |
2132 KB |
Output is correct |
16 |
Correct |
56 ms |
1992 KB |
Output is correct |
17 |
Correct |
1 ms |
216 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
6 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
247 ms |
5748 KB |
Output is correct |
12 |
Correct |
261 ms |
5748 KB |
Output is correct |
13 |
Correct |
183 ms |
5744 KB |
Output is correct |
14 |
Correct |
174 ms |
5364 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
128 ms |
3412 KB |
Output is correct |
24 |
Correct |
96 ms |
2568 KB |
Output is correct |
25 |
Correct |
65 ms |
2132 KB |
Output is correct |
26 |
Correct |
56 ms |
1992 KB |
Output is correct |
27 |
Correct |
1 ms |
216 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 |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
80 ms |
6112 KB |
Output is correct |
36 |
Correct |
263 ms |
11420 KB |
Output is correct |
37 |
Correct |
249 ms |
10660 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 |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
5 ms |
468 KB |
Output is correct |
46 |
Correct |
9 ms |
572 KB |
Output is correct |
47 |
Correct |
1 ms |
340 KB |
Output is correct |
48 |
Correct |
45 ms |
2072 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
308 KB |
Output is correct |
51 |
Correct |
5 ms |
468 KB |
Output is correct |
52 |
Correct |
1 ms |
212 KB |
Output is correct |
53 |
Correct |
0 ms |
308 KB |
Output is correct |
54 |
Correct |
0 ms |
212 KB |
Output is correct |
55 |
Correct |
130 ms |
5396 KB |
Output is correct |
56 |
Correct |
82 ms |
3072 KB |
Output is correct |
57 |
Correct |
61 ms |
3128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
128 ms |
3412 KB |
Output is correct |
10 |
Correct |
96 ms |
2568 KB |
Output is correct |
11 |
Correct |
65 ms |
2132 KB |
Output is correct |
12 |
Correct |
56 ms |
1992 KB |
Output is correct |
13 |
Correct |
1 ms |
216 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
80 ms |
6112 KB |
Output is correct |
22 |
Correct |
263 ms |
11420 KB |
Output is correct |
23 |
Correct |
249 ms |
10660 KB |
Output is correct |
24 |
Correct |
52 ms |
1800 KB |
Output is correct |
25 |
Correct |
137 ms |
4972 KB |
Output is correct |
26 |
Correct |
28 ms |
1364 KB |
Output is correct |
27 |
Correct |
279 ms |
10732 KB |
Output is correct |
28 |
Correct |
256 ms |
10828 KB |
Output is correct |
29 |
Correct |
251 ms |
10788 KB |
Output is correct |
30 |
Correct |
284 ms |
10672 KB |
Output is correct |
31 |
Correct |
361 ms |
10724 KB |
Output is correct |
32 |
Correct |
153 ms |
6148 KB |
Output is correct |
33 |
Correct |
403 ms |
11452 KB |
Output is correct |
34 |
Correct |
146 ms |
6156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
247 ms |
5748 KB |
Output is correct |
12 |
Correct |
261 ms |
5748 KB |
Output is correct |
13 |
Correct |
183 ms |
5744 KB |
Output is correct |
14 |
Correct |
174 ms |
5364 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
128 ms |
3412 KB |
Output is correct |
24 |
Correct |
96 ms |
2568 KB |
Output is correct |
25 |
Correct |
65 ms |
2132 KB |
Output is correct |
26 |
Correct |
56 ms |
1992 KB |
Output is correct |
27 |
Correct |
1 ms |
216 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 |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
5 ms |
468 KB |
Output is correct |
42 |
Correct |
9 ms |
572 KB |
Output is correct |
43 |
Correct |
1 ms |
340 KB |
Output is correct |
44 |
Correct |
45 ms |
2072 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
308 KB |
Output is correct |
47 |
Correct |
5 ms |
468 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
308 KB |
Output is correct |
50 |
Correct |
0 ms |
212 KB |
Output is correct |
51 |
Correct |
130 ms |
5396 KB |
Output is correct |
52 |
Correct |
82 ms |
3072 KB |
Output is correct |
53 |
Correct |
61 ms |
3128 KB |
Output is correct |
54 |
Correct |
52 ms |
1800 KB |
Output is correct |
55 |
Correct |
137 ms |
4972 KB |
Output is correct |
56 |
Correct |
28 ms |
1364 KB |
Output is correct |
57 |
Correct |
279 ms |
10732 KB |
Output is correct |
58 |
Correct |
256 ms |
10828 KB |
Output is correct |
59 |
Correct |
251 ms |
10788 KB |
Output is correct |
60 |
Correct |
284 ms |
10672 KB |
Output is correct |
61 |
Correct |
361 ms |
10724 KB |
Output is correct |
62 |
Correct |
153 ms |
6148 KB |
Output is correct |
63 |
Correct |
403 ms |
11452 KB |
Output is correct |
64 |
Correct |
146 ms |
6156 KB |
Output is correct |
65 |
Correct |
0 ms |
212 KB |
Output is correct |
66 |
Correct |
80 ms |
6112 KB |
Output is correct |
67 |
Correct |
263 ms |
11420 KB |
Output is correct |
68 |
Correct |
249 ms |
10660 KB |
Output is correct |
69 |
Correct |
41 ms |
1420 KB |
Output is correct |
70 |
Correct |
10 ms |
596 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
60 ms |
1716 KB |
Output is correct |
73 |
Correct |
11 ms |
596 KB |
Output is correct |
74 |
Correct |
2 ms |
316 KB |
Output is correct |
75 |
Correct |
272 ms |
10776 KB |
Output is correct |
76 |
Correct |
277 ms |
10780 KB |
Output is correct |
77 |
Correct |
273 ms |
10680 KB |
Output is correct |
78 |
Correct |
307 ms |
10812 KB |
Output is correct |
79 |
Correct |
370 ms |
10716 KB |
Output is correct |
80 |
Correct |
374 ms |
10776 KB |
Output is correct |
81 |
Correct |
333 ms |
8792 KB |
Output is correct |
82 |
Correct |
328 ms |
8796 KB |
Output is correct |