#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
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 r = -1;
vector<P> nps;
for (P p : ps) {
if (-p._2 > r) {
nps.pb(P(p._1, -p._2));
r = -p._2;
}
}
swap(ps, nps);
int last_r = -1;
long long s = 0;
assert(K==N);
for (P p : ps) {
int l = p._1, r = p._2;
//cout<<"["<<l<<","<<r<<"]\n";
s += 1LL*(r-l+1)*(r-l+1);
if (l <= last_r) s -= 1LL*(last_r-l+1)*(last_r-l+1);
last_r = r;
}
return s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
428 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
448 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
496 KB |
Correct answer: answer = 52 |
6 |
Correct |
2 ms |
496 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
576 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 9502 |
12 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
672 KB |
Correct answer: answer = 10000 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
672 KB |
Correct answer: answer = 1 |
2 |
Runtime error |
2 ms |
812 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
428 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
448 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
496 KB |
Correct answer: answer = 52 |
6 |
Correct |
2 ms |
496 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
576 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 9502 |
12 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
672 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
672 KB |
Correct answer: answer = 1 |
22 |
Runtime error |
2 ms |
812 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
428 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
448 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
496 KB |
Correct answer: answer = 52 |
6 |
Correct |
2 ms |
496 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
576 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 9502 |
12 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
672 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
672 KB |
Correct answer: answer = 1 |
22 |
Runtime error |
2 ms |
812 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
428 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
448 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
496 KB |
Correct answer: answer = 52 |
6 |
Correct |
2 ms |
496 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
576 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 9502 |
12 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
672 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
672 KB |
Correct answer: answer = 1 |
22 |
Runtime error |
2 ms |
812 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
352 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
428 KB |
Correct answer: answer = 4 |
4 |
Correct |
2 ms |
448 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
496 KB |
Correct answer: answer = 52 |
6 |
Correct |
2 ms |
496 KB |
Correct answer: answer = 210 |
7 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 88 |
8 |
Correct |
2 ms |
576 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
576 KB |
Correct answer: answer = 1 |
10 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 9502 |
12 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 49 |
13 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
604 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
604 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
672 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
672 KB |
Correct answer: answer = 1 |
22 |
Runtime error |
2 ms |
812 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Halted |
0 ms |
0 KB |
- |