# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
42804 |
2018-03-04T05:07:20 Z |
funcsr |
Aliens (IOI16_aliens) |
C++14 |
|
626 ms |
7404 KB |
#include "aliens.h"
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define INF 1145141919
#define _1 first
#define _2 second
inline void chmin(long long &x, long long v) { if (x > v) x = v; }
long long dp[100010][101];
int L[100010];
int minL[2000][2000];
long long take_photos(int N, int M, int K, std::vector<int> R, std::vector<int> C) {
vector<P> ps;
rep(i, N) {
int l = R[i], r = C[i];
if (l > r) swap(l, r);
ps.pb(P(l, -r));
}
sort(all(ps));
int mr = -1;
vector<P> nps;
for (P p : ps) {
if (-p._2 > mr) {
nps.pb(P(p._1, -p._2));
mr = -p._2;
}
}
swap(ps, nps);
M = mr+1;
rep(i, M) L[i] = INF;
for (P p : ps) {
int l = p._1, r = p._2;
//cout<<"["<<l<<","<<r<<"]\n";
L[r] = l;
}
//rep(i, M) cout<<L[i]<<",";cout<<"\n";
//for (int i=M-2; i>=0; i--) L[i] = min(L[i], L[i+1]);
rep(l, M) {
int m = INF;
for (int r=l; r<M; r++) {
m = min(m, L[r]);
minL[l][r] = m;
}
}
rep(i, M+1) rep(j, K+1) dp[i][j] = 1LL<<60;
dp[0][0] = 0;
rep(i, M) {
rep(k, K) {
rep(pos, i+1) if (dp[pos][k] != 1LL<<60) {
int l = minL[pos][i];
if (l == INF) continue;
int s = i-l+1, s2 = max(0, pos-l);
//cout<<"s="<<s<<", s2="<<s2<<"\n";
chmin(dp[i+1][k+1], dp[pos][k] + 1LL*s*s - 1LL*s2*s2);
}
}
}
//cout<<"M="<<M<<"\n";
long long m = 1LL<<60;
rep(k, K+1) chmin(m, dp[M][k]);
return m;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
2 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
592 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 12 |
5 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
608 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
608 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 2374 |
11 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 151 |
14 |
Correct |
3 ms |
1048 KB |
Correct answer: answer = 7550 |
15 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7220 |
16 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
18 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
19 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
2 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 4 |
3 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 1 |
4 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 5 |
5 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 41 |
6 |
Correct |
13 ms |
6896 KB |
Correct answer: answer = 71923 |
7 |
Correct |
28 ms |
7276 KB |
Correct answer: answer = 77137 |
8 |
Incorrect |
626 ms |
7404 KB |
Wrong answer: output = 355, expected = 764 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
2 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
592 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 12 |
5 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
608 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
608 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 2374 |
11 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 151 |
14 |
Correct |
3 ms |
1048 KB |
Correct answer: answer = 7550 |
15 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7220 |
16 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
18 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
19 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 4 |
23 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 1 |
24 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 41 |
26 |
Correct |
13 ms |
6896 KB |
Correct answer: answer = 71923 |
27 |
Correct |
28 ms |
7276 KB |
Correct answer: answer = 77137 |
28 |
Incorrect |
626 ms |
7404 KB |
Wrong answer: output = 355, expected = 764 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
2 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
592 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 12 |
5 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
608 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
608 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 2374 |
11 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 151 |
14 |
Correct |
3 ms |
1048 KB |
Correct answer: answer = 7550 |
15 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7220 |
16 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
18 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
19 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 4 |
23 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 1 |
24 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 41 |
26 |
Correct |
13 ms |
6896 KB |
Correct answer: answer = 71923 |
27 |
Correct |
28 ms |
7276 KB |
Correct answer: answer = 77137 |
28 |
Incorrect |
626 ms |
7404 KB |
Wrong answer: output = 355, expected = 764 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
2 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
592 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 12 |
5 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
608 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
608 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 2374 |
11 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 151 |
14 |
Correct |
3 ms |
1048 KB |
Correct answer: answer = 7550 |
15 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7220 |
16 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
18 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
19 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 4 |
23 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 1 |
24 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 41 |
26 |
Correct |
13 ms |
6896 KB |
Correct answer: answer = 71923 |
27 |
Correct |
28 ms |
7276 KB |
Correct answer: answer = 77137 |
28 |
Incorrect |
626 ms |
7404 KB |
Wrong answer: output = 355, expected = 764 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
2 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
592 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 12 |
5 |
Correct |
2 ms |
592 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
608 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
608 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 2374 |
11 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 151 |
14 |
Correct |
3 ms |
1048 KB |
Correct answer: answer = 7550 |
15 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7220 |
16 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
18 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
19 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 4 |
23 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 1 |
24 |
Correct |
2 ms |
1048 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
1048 KB |
Correct answer: answer = 41 |
26 |
Correct |
13 ms |
6896 KB |
Correct answer: answer = 71923 |
27 |
Correct |
28 ms |
7276 KB |
Correct answer: answer = 77137 |
28 |
Incorrect |
626 ms |
7404 KB |
Wrong answer: output = 355, expected = 764 |
29 |
Halted |
0 ms |
0 KB |
- |