Submission #14018

# Submission time Handle Problem Language Result Execution time Memory
14018 2015-04-25T01:25:52 Z pjsdream 정전 (OJUZ10_blackout) C++14
100 / 100
50 ms 2256 KB
#pragma warning(disable:4996)

#include <stdio.h>
#include <algorithm>
using namespace std;

int n;
long long l;
long long a[150000];

long long last[2];

long long mymax(long long a, long long b) { return a>b?a:b; }

int main()
{
	scanf("%d%lld", &n, &l);
	for (int i=0; i<n; i++) scanf("%lld", &a[i]);
	sort(a, a+n);

	long long ans=0;

	last[0] = last[1] = -1000000000000ll;
	for (int i=0; i<n; i++) {
		int i0 = i&1;
		int i1 = 1-i0;

		long long s = mymax(a[i]-l, last[i0]);
		long long e = a[i]+l;

		if (s <= last[i1])
			ans += last[i1] - s;

		last[i0] = e;
	}

	printf("%lld\n", ans);

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2256 KB Output is correct
2 Correct 0 ms 2256 KB Output is correct
3 Correct 0 ms 2256 KB Output is correct
4 Correct 0 ms 2256 KB Output is correct
5 Correct 0 ms 2256 KB Output is correct
6 Correct 0 ms 2256 KB Output is correct
7 Correct 0 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2256 KB Output is correct
2 Correct 0 ms 2256 KB Output is correct
3 Correct 0 ms 2256 KB Output is correct
4 Correct 0 ms 2256 KB Output is correct
5 Correct 0 ms 2256 KB Output is correct
6 Correct 0 ms 2256 KB Output is correct
7 Correct 0 ms 2256 KB Output is correct
8 Correct 0 ms 2256 KB Output is correct
9 Correct 0 ms 2256 KB Output is correct
10 Correct 0 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2256 KB Output is correct
2 Correct 37 ms 2256 KB Output is correct
3 Correct 48 ms 2256 KB Output is correct
4 Correct 14 ms 2256 KB Output is correct
5 Correct 48 ms 2256 KB Output is correct
6 Correct 31 ms 2256 KB Output is correct
7 Correct 19 ms 2256 KB Output is correct
8 Correct 31 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 2256 KB Output is correct
2 Correct 28 ms 2256 KB Output is correct
3 Correct 50 ms 2256 KB Output is correct
4 Correct 42 ms 2256 KB Output is correct
5 Correct 19 ms 2256 KB Output is correct
6 Correct 50 ms 2256 KB Output is correct
7 Correct 0 ms 2256 KB Output is correct
8 Correct 27 ms 2256 KB Output is correct
9 Correct 20 ms 2256 KB Output is correct
10 Correct 50 ms 2256 KB Output is correct
11 Correct 25 ms 2256 KB Output is correct
12 Correct 30 ms 2256 KB Output is correct
13 Correct 32 ms 2256 KB Output is correct
14 Correct 42 ms 2256 KB Output is correct
15 Correct 28 ms 2256 KB Output is correct