답안 #20242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20242 2016-07-13T19:45:29 Z jjwdi0 정전 (OJUZ10_blackout) C++
50 / 100
44 ms 24 KB
#include <stdio.h>
#include <algorithm>
#define INF -1234567891
typedef long long ll;
using namespace std;
int a[150005], l;
int n, i, left=INF, right=INF, t1, t2;
ll ans;
int f(int x)
{
	return x>0?x:0;
}
main()
{
	scanf("%d%d", &n, &l);
	for(i=0; i<n; i++)scanf("%d", a+i);
	sort(a, a+n);
	for(i=1; i<n; i++)
	{
		if(a[i]-a[i-1]>=2*l)continue;
		t1=a[i]-l;t2=a[i-1]+l;
//		printf("%d %d\n", t2-t1, f(right-t1));
		ans+=(ll)(t2-t1)-(ll)f(right-t1);
		left=t1;right=t2;
//		printf("%lld\n", ans);
	}
	printf("%lld", ans);
}

Compilation message

blackout.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
blackout.cpp: In function 'int main()':
blackout.cpp:15:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &l);
                       ^
blackout.cpp:16:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0; i<n; i++)scanf("%d", a+i);
                                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 0 KB Output is correct
2 Incorrect 2 ms 0 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 0 KB Output is correct
2 Correct 2 ms 0 KB Output is correct
3 Correct 2 ms 0 KB Output is correct
4 Correct 2 ms 0 KB Output is correct
5 Correct 2 ms 0 KB Output is correct
6 Correct 2 ms 0 KB Output is correct
7 Correct 2 ms 0 KB Output is correct
8 Correct 2 ms 0 KB Output is correct
9 Correct 2 ms 0 KB Output is correct
10 Correct 2 ms 0 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 0 KB Output is correct
2 Correct 16 ms 1 KB Output is correct
3 Correct 25 ms 2 KB Output is correct
4 Correct 27 ms 3 KB Output is correct
5 Correct 27 ms 4 KB Output is correct
6 Correct 40 ms 5 KB Output is correct
7 Correct 41 ms 6 KB Output is correct
8 Correct 40 ms 8 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8 KB Output is correct
2 Correct 17 ms 8 KB Output is correct
3 Correct 22 ms 9 KB Output is correct
4 Correct 27 ms 10 KB Output is correct
5 Correct 30 ms 11 KB Output is correct
6 Correct 30 ms 12 KB Output is correct
7 Correct 28 ms 13 KB Output is correct
8 Correct 29 ms 14 KB Output is correct
9 Correct 42 ms 15 KB Output is correct
10 Correct 44 ms 17 KB Output is correct
11 Correct 41 ms 18 KB Output is correct
12 Correct 42 ms 20 KB Output is correct
13 Correct 42 ms 21 KB Output is correct
14 Correct 41 ms 23 KB Output is correct
15 Incorrect 41 ms 24 KB Output isn't correct