Submission #15738

# Submission time Handle Problem Language Result Execution time Memory
15738 2015-07-19T05:10:01 Z cki86201 정전 (OJUZ10_blackout) C++
100 / 100
76 ms 4012 KB
#include<stdio.h>
#include<set>
#include<algorithm>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
#define X first
#define Y second

Pi q[300030];
int p[150020];
int cnt[2];
ll ans;

int main(){
	int n, l;
	scanf("%d%d",&n,&l);
	for(int i=0;i<n;i++)scanf("%d",p+i);
	sort(p, p+n);
	for(int i=0;i<n;i++){
		q[i+i] = Pi(p[i]-l, i);
		q[i+i+1] = Pi(p[i]+l, n+i);
	}
	sort(q, q+n+n);
	for(int i=0;i<n+n;i++){
		if(i > 0 && cnt[0] > 0 && cnt[1] > 0)ans += (ll)q[i].X - q[i-1].X;
		if(q[i].Y < n)cnt[q[i].Y&1]++;
		else cnt[(q[i].Y-n)&1]--;
	}
	printf("%lld",ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 2 ms 4012 KB Output is correct
8 Correct 0 ms 4012 KB Output is correct
9 Correct 0 ms 4012 KB Output is correct
10 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 4012 KB Output is correct
2 Correct 57 ms 4012 KB Output is correct
3 Correct 40 ms 4012 KB Output is correct
4 Correct 48 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 59 ms 4012 KB Output is correct
7 Correct 52 ms 4012 KB Output is correct
8 Correct 28 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 4012 KB Output is correct
2 Correct 60 ms 4012 KB Output is correct
3 Correct 60 ms 4012 KB Output is correct
4 Correct 24 ms 4012 KB Output is correct
5 Correct 76 ms 4012 KB Output is correct
6 Correct 66 ms 4012 KB Output is correct
7 Correct 48 ms 4012 KB Output is correct
8 Correct 42 ms 4012 KB Output is correct
9 Correct 40 ms 4012 KB Output is correct
10 Correct 76 ms 4012 KB Output is correct
11 Correct 66 ms 4012 KB Output is correct
12 Correct 4 ms 4012 KB Output is correct
13 Correct 54 ms 4012 KB Output is correct
14 Correct 53 ms 4012 KB Output is correct
15 Correct 65 ms 4012 KB Output is correct