#include<bits/stdc++.h>
#include "aliens.h"
using namespace std;
int N, M, K;
vector<int> R, C;
vector<vector<long long>> dp;
long long rec(int idx, int k){
if(idx == N) return 0;
if(k == K-1) return (R[N-1] - R[idx] + 1)*(R[N-1] - R[idx] + 1);
if(dp[idx][k] != -1) return dp[idx][k];
long long res = LLONG_MAX;
for(int i = idx; i < N; i++){
long long c = (R[i] - R[idx] + 1) * (R[i] - R[idx] + 1);
c += rec(i+1, k+1);
res = min(c, res);
}
dp[idx][k] = res;
return res;
}
long long take_photos(int _N, int _M, int _K, std::vector<int> _R, std::vector<int> _C) {
N = _N;
M = _M;
K = _K;
R = _R;
C = _C;
sort(R.begin(), R.end());
dp = vector<vector<long long>> (N, vector<long long> (K,-1));
return rec(0, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong answer: output = 1, expected = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Correct answer: answer = 1 |
2 |
Correct |
0 ms |
256 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
256 KB |
Correct answer: answer = 1 |
4 |
Correct |
1 ms |
384 KB |
Correct answer: answer = 5 |
5 |
Correct |
0 ms |
256 KB |
Correct answer: answer = 41 |
6 |
Correct |
0 ms |
256 KB |
Correct answer: answer = 71923 |
7 |
Correct |
2 ms |
384 KB |
Correct answer: answer = 77137 |
8 |
Correct |
114 ms |
1280 KB |
Correct answer: answer = 764 |
9 |
Correct |
1 ms |
384 KB |
Correct answer: answer = 250000 |
10 |
Correct |
133 ms |
2304 KB |
Correct answer: answer = 500 |
11 |
Correct |
0 ms |
256 KB |
Correct answer: answer = 32 |
12 |
Correct |
1 ms |
384 KB |
Correct answer: answer = 130050 |
13 |
Correct |
37 ms |
512 KB |
Correct answer: answer = 5110 |
14 |
Correct |
5 ms |
384 KB |
Correct answer: answer = 2626 |
15 |
Correct |
12 ms |
512 KB |
Correct answer: answer = 796 |
16 |
Correct |
23 ms |
512 KB |
Correct answer: answer = 7580 |
17 |
Correct |
79 ms |
916 KB |
Correct answer: answer = 1904 |
18 |
Correct |
1 ms |
384 KB |
Correct answer: answer = 996004 |
19 |
Correct |
14 ms |
384 KB |
Correct answer: answer = 38817 |
20 |
Correct |
64 ms |
888 KB |
Correct answer: answer = 4096 |
21 |
Correct |
1 ms |
384 KB |
Correct answer: answer = 1 |
22 |
Correct |
134 ms |
2304 KB |
Correct answer: answer = 1 |
23 |
Correct |
74 ms |
768 KB |
Correct answer: answer = 2040 |
24 |
Correct |
138 ms |
2304 KB |
Correct answer: answer = 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong answer: output = 1, expected = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong answer: output = 1, expected = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong answer: output = 1, expected = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong answer: output = 1, expected = 4 |
2 |
Halted |
0 ms |
0 KB |
- |