답안 #219595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219595 2020-04-05T16:36:20 Z GioChkhaidze Lightning Rod (NOI18_lightningrod) C++14
100 / 100
778 ms 236936 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;

int getn() {
	char ch = getchar_unlocked();
    int ans = 0;
    while(!isdigit(ch)) {
        ch = getchar_unlocked();
    }
    while(isdigit(ch)) {
        ans = ans * 10 + ch - '0';
        ch = getchar_unlocked();
    }
    return ans;
}
 
main () {
	n=getn();
	for (int i=1; i<=n; i++) {
		x=getn();
		y=getn();
		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:20:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 459 ms 116344 KB Output is correct
2 Correct 438 ms 114552 KB Output is correct
3 Correct 470 ms 111480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 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
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 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 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 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 4 ms 384 KB Output is correct
10 Correct 5 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 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 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 4 ms 384 KB Output is correct
10 Correct 5 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 5 ms 384 KB Output is correct
14 Correct 22 ms 4352 KB Output is correct
15 Correct 21 ms 4480 KB Output is correct
16 Correct 21 ms 4792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 475 ms 119472 KB Output is correct
2 Correct 464 ms 117496 KB Output is correct
3 Correct 451 ms 114808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 459 ms 116344 KB Output is correct
2 Correct 438 ms 114552 KB Output is correct
3 Correct 470 ms 111480 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 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 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 22 ms 4352 KB Output is correct
18 Correct 21 ms 4480 KB Output is correct
19 Correct 21 ms 4792 KB Output is correct
20 Correct 475 ms 119472 KB Output is correct
21 Correct 464 ms 117496 KB Output is correct
22 Correct 451 ms 114808 KB Output is correct
23 Correct 776 ms 86832 KB Output is correct
24 Correct 778 ms 236936 KB Output is correct
25 Correct 762 ms 220764 KB Output is correct