답안 #219586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219586 2020-04-05T16:17:39 Z GioChkhaidze Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 171132 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;
main () {
	scanf("%d",&n);
	for (int i=1; i<=n; i++) {
		scanf("%d%d",&x[i],&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:7:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
lightningrod.cpp: In function 'int main()':
lightningrod.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
lightningrod.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x[i],&y[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2029 ms 170872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 376 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 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 376 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 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 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 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 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 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 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 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 73 ms 5496 KB Output is correct
15 Correct 81 ms 5472 KB Output is correct
16 Correct 70 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 171132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2029 ms 170872 KB Time limit exceeded
2 Halted 0 ms 0 KB -