답안 #219587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219587 2020-04-05T16:20:45 Z GioChkhaidze Lightning Rod (NOI18_lightningrod) C++14
80 / 100
2000 ms 228236 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1e7+7;
bool f[N];
int n,x[N],y[N];
stack < int > st;

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[i]);
		fastscan(y[i]);
	}
	
	int ans=n;
	for (int i=1; i<=n; i++) {
		if (st.size()) {
			while (st.size() && x[st.top()]-y[st.top()]>=x[i]-y[i]) {
				f[st.top()]=1;
				--ans;
				st.pop();
			}
		}
		st.push(i);
	}
	
	while (st.size()) st.pop();
	
	for (int i=n; i>=1; i--) {
		if (f[i]) continue;
		if (st.size()) {
			while (st.size() && x[st.top()]+y[st.top()]<=x[i]+y[i]) {
				f[st.top()]=1;
				--ans;
				st.pop();
			}
		}
		st.push(i);
	}
	
	printf("%d\n",ans);
}

Compilation message

lightningrod.cpp:16:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1772 ms 127064 KB Output is correct
2 Correct 1830 ms 228236 KB Output is correct
3 Correct 1789 ms 222004 KB Output is correct
# 결과 실행 시간 메모리 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 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 4 ms 384 KB Output is correct
5 Correct 5 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 10 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 4 ms 384 KB Output is correct
5 Correct 5 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 10 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 6 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 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 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 10 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 6 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 60 ms 2936 KB Output is correct
15 Correct 57 ms 3064 KB Output is correct
16 Correct 49 ms 3452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1716 ms 121020 KB Output is correct
2 Correct 1681 ms 215004 KB Output is correct
3 Correct 1660 ms 209812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1772 ms 127064 KB Output is correct
2 Correct 1830 ms 228236 KB Output is correct
3 Correct 1789 ms 222004 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 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 4 ms 384 KB Output is correct
12 Correct 10 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 6 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 60 ms 2936 KB Output is correct
18 Correct 57 ms 3064 KB Output is correct
19 Correct 49 ms 3452 KB Output is correct
20 Correct 1716 ms 121020 KB Output is correct
21 Correct 1681 ms 215004 KB Output is correct
22 Correct 1660 ms 209812 KB Output is correct
23 Execution timed out 2089 ms 195692 KB Time limit exceeded
24 Halted 0 ms 0 KB -