Submission #137658

#TimeUsernameProblemLanguageResultExecution timeMemory
137658ekremLightning Rod (NOI18_lightningrod)C++98
66 / 100
2060 ms73556 KiB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define coc g[mode][i]
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)>>1)
#define mod 1000000007
#define inf 1000000009
#define N 10000005

using namespace std;

typedef long long ll;
typedef pair < int , int > ii;
typedef pair < double , double > dd;

int n, m;
ii a, s[N];

int main(){
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d %d",&a.st ,&a.nd);
		while(m and abs(s[m].st - a.st) <= a.nd - s[m].nd)
			m--;
		if(m and abs(s[m].st - a.st) <= s[m].nd - a.nd)
			continue;
		s[++m] = a;
	}
	printf("%d\n", m);
	return 0;
}

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
lightningrod.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&a.st ,&a.nd);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...