Submission #712097

# Submission time Handle Problem Language Result Execution time Memory
712097 2023-03-18T06:22:16 Z Pherokung Lightning Rod (NOI18_lightningrod) C++14
0 / 100
1586 ms 153964 KB
#include<bits/stdc++.h>
using namespace std;
#define MAXN 10000005
#define F first
#define S second
int n,x[MAXN],y[MAXN],rod[MAXN],ans=0;
stack<int> dq;
bool oper(pair<int,int> i,pair<int,int> j){
	return i.F > j.F;
}

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);
	}
	
	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:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
lightningrod.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d%d",&x[i],&y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1500 ms 153964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1586 ms 148048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1500 ms 153964 KB Output isn't correct
2 Halted 0 ms 0 KB -