Submission #219589

# Submission time Handle Problem Language Result Execution time Memory
219589 2020-04-05T16:27:11 Z GioChkhaidze Lightning Rod (NOI18_lightningrod) C++14
80 / 100
2000 ms 118524 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1e7+7;
bool f[N];
int n,x,y,X[N],Y[N],st[N],sts;

inline void fastscan(int &number)  { 
  register int c; 
  number = 0; 
  c = getchar(); 
  for (; (c>47 && c<58); c=getchar()) 
      number = number *10 + c - 48; 
} 

main () {
	fastscan(n);
	for (int i=1; i<=n; i++) {
		fastscan(x);
		fastscan(y);
		X[i]=x-y;
		Y[i]=x+y;
	}
	
	for (int i=1; i<=n; i++) {
		if (sts) {
			while (sts && X[st[sts]]>=X[i]) {
				f[st[sts]]=1;
				--sts;
			}
		}
		st[++sts]=i;
	}

	sts=0;
	
	for (int i=n; i>=1; i--) {
		if (f[i]) continue;
		if (sts) {
			while (sts && Y[st[sts]]<=Y[i]) {
				--sts;
			}
		}
		st[++sts]=i;
	}
	cout<<sts;
}

Compilation message

lightningrod.cpp:15:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
# Verdict Execution time Memory Grader output
1 Correct 1456 ms 116196 KB Output is correct
2 Correct 1450 ms 114380 KB Output is correct
3 Correct 1398 ms 111224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 51 ms 3064 KB Output is correct
15 Correct 50 ms 3192 KB Output is correct
16 Correct 42 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1361 ms 118524 KB Output is correct
2 Correct 1363 ms 117240 KB Output is correct
3 Correct 1343 ms 114784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1456 ms 116196 KB Output is correct
2 Correct 1450 ms 114380 KB Output is correct
3 Correct 1398 ms 111224 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 51 ms 3064 KB Output is correct
18 Correct 50 ms 3192 KB Output is correct
19 Correct 42 ms 3576 KB Output is correct
20 Correct 1361 ms 118524 KB Output is correct
21 Correct 1363 ms 117240 KB Output is correct
22 Correct 1343 ms 114784 KB Output is correct
23 Execution timed out 2086 ms 100052 KB Time limit exceeded
24 Halted 0 ms 0 KB -