# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1071212 |
2024-08-23T05:58:12 Z |
정민찬(#11138) |
Cultivation (JOI17_cultivation) |
C++17 |
|
282 ms |
684 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll inf = 2e18;
ll R, C;
ll N;
ll solve(vector<pll> p, ll H1, ll H2) {
vector<vector<ll>> cur(R+1);
for (ll i=0; i<N; i++) {
for (ll j=max(1LL, p[i].first - H1); j<=min(R, p[i].first + H2); j++) {
cur[j].push_back(p[i].second);
}
}
ll l = 0, r = 0, sum = 0;
for (ll i=1; i<=R; i++) {
if (cur[i].empty()) return inf;
sort(cur[i].begin(), cur[i].end());
l = max(l, cur[i][0] - 1);
r = max(r, C - cur[i].back());
for (ll j=0; j+1<cur[i].size(); j++) {
sum = max(sum, cur[i][j+1] - cur[i][j] - 1);
}
}
return max(l+r, sum);
}
int main() {
ios_base :: sync_with_stdio(false); cin.tie(NULL);
cin >> R >> C;
cin >> N;
vector<pll> p(N);
for (ll i=0; i<N; i++) {
cin >> p[i].first >> p[i].second;
}
sort(p.begin(), p.end());
ll ans = inf;
for (ll i=0; i<=R-1; i++) {
for (ll j=0; j<=R-1; j++) {
ans = min(ans, i + j + solve(p, i, j));
}
}
cout << ans << '\n';
}
Compilation message
cultivation.cpp: In function 'll solve(std::vector<std::pair<long long int, long long int> >, ll, ll)':
cultivation.cpp:26:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (ll j=0; j+1<cur[i].size(); j++) {
| ~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
348 KB |
Output is correct |
19 |
Correct |
14 ms |
476 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
30 ms |
492 KB |
Output is correct |
22 |
Correct |
70 ms |
520 KB |
Output is correct |
23 |
Correct |
20 ms |
344 KB |
Output is correct |
24 |
Correct |
132 ms |
344 KB |
Output is correct |
25 |
Correct |
94 ms |
344 KB |
Output is correct |
26 |
Correct |
263 ms |
644 KB |
Output is correct |
27 |
Correct |
248 ms |
648 KB |
Output is correct |
28 |
Correct |
120 ms |
552 KB |
Output is correct |
29 |
Correct |
216 ms |
636 KB |
Output is correct |
30 |
Correct |
252 ms |
644 KB |
Output is correct |
31 |
Correct |
251 ms |
648 KB |
Output is correct |
32 |
Correct |
264 ms |
664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
348 KB |
Output is correct |
19 |
Correct |
14 ms |
476 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
30 ms |
492 KB |
Output is correct |
22 |
Correct |
70 ms |
520 KB |
Output is correct |
23 |
Correct |
20 ms |
344 KB |
Output is correct |
24 |
Correct |
132 ms |
344 KB |
Output is correct |
25 |
Correct |
94 ms |
344 KB |
Output is correct |
26 |
Correct |
263 ms |
644 KB |
Output is correct |
27 |
Correct |
248 ms |
648 KB |
Output is correct |
28 |
Correct |
120 ms |
552 KB |
Output is correct |
29 |
Correct |
216 ms |
636 KB |
Output is correct |
30 |
Correct |
252 ms |
644 KB |
Output is correct |
31 |
Correct |
251 ms |
648 KB |
Output is correct |
32 |
Correct |
264 ms |
664 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
126 ms |
656 KB |
Output is correct |
35 |
Correct |
270 ms |
660 KB |
Output is correct |
36 |
Correct |
282 ms |
660 KB |
Output is correct |
37 |
Correct |
171 ms |
628 KB |
Output is correct |
38 |
Correct |
270 ms |
652 KB |
Output is correct |
39 |
Correct |
265 ms |
684 KB |
Output is correct |
40 |
Correct |
281 ms |
656 KB |
Output is correct |
41 |
Correct |
132 ms |
612 KB |
Output is correct |
42 |
Correct |
148 ms |
628 KB |
Output is correct |
43 |
Correct |
224 ms |
640 KB |
Output is correct |
44 |
Correct |
278 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
348 KB |
Output is correct |
19 |
Correct |
14 ms |
476 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
30 ms |
492 KB |
Output is correct |
22 |
Correct |
70 ms |
520 KB |
Output is correct |
23 |
Correct |
20 ms |
344 KB |
Output is correct |
24 |
Correct |
132 ms |
344 KB |
Output is correct |
25 |
Correct |
94 ms |
344 KB |
Output is correct |
26 |
Correct |
263 ms |
644 KB |
Output is correct |
27 |
Correct |
248 ms |
648 KB |
Output is correct |
28 |
Correct |
120 ms |
552 KB |
Output is correct |
29 |
Correct |
216 ms |
636 KB |
Output is correct |
30 |
Correct |
252 ms |
644 KB |
Output is correct |
31 |
Correct |
251 ms |
648 KB |
Output is correct |
32 |
Correct |
264 ms |
664 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
126 ms |
656 KB |
Output is correct |
35 |
Correct |
270 ms |
660 KB |
Output is correct |
36 |
Correct |
282 ms |
660 KB |
Output is correct |
37 |
Correct |
171 ms |
628 KB |
Output is correct |
38 |
Correct |
270 ms |
652 KB |
Output is correct |
39 |
Correct |
265 ms |
684 KB |
Output is correct |
40 |
Correct |
281 ms |
656 KB |
Output is correct |
41 |
Correct |
132 ms |
612 KB |
Output is correct |
42 |
Correct |
148 ms |
628 KB |
Output is correct |
43 |
Correct |
224 ms |
640 KB |
Output is correct |
44 |
Correct |
278 ms |
652 KB |
Output is correct |
45 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 6 |
46 |
Halted |
0 ms |
0 KB |
- |