Submission #712101

# Submission time Handle Problem Language Result Execution time Memory
712101 2023-03-18T06:33:27 Z Pherokung Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1915 ms 238608 KB
#include<bits/stdc++.h>
using namespace std;
#define MAXN 10000005
#define F first
#define S second
int n,a,b,x[MAXN],y[MAXN],rod[MAXN],ans=0;
stack<int> dq;

int main(){
	scanf("%d",&n);
	ans = n;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		rod[i] = 1;
	}

	for(int i=1;i<=n;i++){
		while(!dq.empty()){
			int p = dq.top();
			if(y[i] - x[i] >= y[p] - x[p]){
				if(rod[p] == 1){
					rod[p] = 0;
					ans--;
				}
				dq.pop();
			}
			else break;
		}
		dq.push(i);
	}
	while(!dq.empty()) dq.pop();
	
	for(int i=n;i>=1;i--){
		while(!dq.empty()){
			int p = dq.top();
			if(y[i] + x[i] >= y[p] + x[p]){
				if(rod[p] == 1){
					rod[p] = 0;
					ans--;
				}
				dq.pop();
			}
			else break;
		}
		dq.push(i);
	}
	
	printf("%d",ans);
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
lightningrod.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d%d",&x[i],&y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1405 ms 153856 KB Output is correct
2 Correct 1413 ms 153588 KB Output is correct
3 Correct 1414 ms 149228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 40 ms 2416 KB Output is correct
15 Correct 41 ms 2500 KB Output is correct
16 Correct 37 ms 2928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1530 ms 148080 KB Output is correct
2 Correct 1644 ms 147832 KB Output is correct
3 Correct 1493 ms 144200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1405 ms 153856 KB Output is correct
2 Correct 1413 ms 153588 KB Output is correct
3 Correct 1414 ms 149228 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 40 ms 2416 KB Output is correct
18 Correct 41 ms 2500 KB Output is correct
19 Correct 37 ms 2928 KB Output is correct
20 Correct 1530 ms 148080 KB Output is correct
21 Correct 1644 ms 147832 KB Output is correct
22 Correct 1493 ms 144200 KB Output is correct
23 Correct 1856 ms 106696 KB Output is correct
24 Correct 1915 ms 238608 KB Output is correct
25 Correct 1830 ms 226832 KB Output is correct