# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
402912 |
2021-05-12T13:44:51 Z |
jk410 |
None (KOI18_arrowH) |
C++17 |
|
45 ms |
2580 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct point{
int x,color;
bool operator<(point t){
if (color!=t.color)
return color<t.color;
return x<t.x;
}
};
const int INF=1e9+1;
int N;
point A[100001];
ll Ans;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N;
for (int i=1; i<=N; i++)
cin>>A[i].x>>A[i].color;
sort(A+1,A+1+N);
for (int i=1; i<=N; i++){
int t=INF;
if (i>1&&A[i-1].color==A[i].color)
t=min(t,A[i].x-A[i-1].x);
if (i<N&&A[i+1].color==A[i].color)
t=min(t,A[i+1].x-A[i].x);
if (t<INF)
Ans+=t;
}
cout<<Ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
484 KB |
Output is correct |
18 |
Correct |
4 ms |
460 KB |
Output is correct |
19 |
Correct |
3 ms |
460 KB |
Output is correct |
20 |
Correct |
5 ms |
460 KB |
Output is correct |
21 |
Correct |
3 ms |
436 KB |
Output is correct |
22 |
Correct |
3 ms |
460 KB |
Output is correct |
23 |
Correct |
4 ms |
460 KB |
Output is correct |
24 |
Correct |
5 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
484 KB |
Output is correct |
18 |
Correct |
4 ms |
460 KB |
Output is correct |
19 |
Correct |
3 ms |
460 KB |
Output is correct |
20 |
Correct |
5 ms |
460 KB |
Output is correct |
21 |
Correct |
3 ms |
436 KB |
Output is correct |
22 |
Correct |
3 ms |
460 KB |
Output is correct |
23 |
Correct |
4 ms |
460 KB |
Output is correct |
24 |
Correct |
5 ms |
460 KB |
Output is correct |
25 |
Correct |
40 ms |
2520 KB |
Output is correct |
26 |
Correct |
35 ms |
2284 KB |
Output is correct |
27 |
Correct |
45 ms |
2524 KB |
Output is correct |
28 |
Correct |
30 ms |
2268 KB |
Output is correct |
29 |
Correct |
35 ms |
2580 KB |
Output is correct |
30 |
Correct |
29 ms |
2072 KB |
Output is correct |
31 |
Correct |
32 ms |
2388 KB |
Output is correct |
32 |
Correct |
31 ms |
2340 KB |
Output is correct |