Submission #265316

#TimeUsernameProblemLanguageResultExecution timeMemory
265316T0p_Lightning Rod (NOI18_lightningrod)C++14
66 / 100
2088 ms75384 KiB
#include<bits/stdc++.h>
using namespace std;

pair<int, int> arr[10000005];

int main()
{
	int n, now = 0;
	scanf(" %d",&n);
	while(n--)
	{
		int x, y;
		scanf(" %d %d",&x,&y);
		if(now == 0) arr[++now] = {x, y};
		else
		{
			int h = arr[now].second - x + arr[now].first;
			if(h >= y) continue ;
			while(now > 0)
			{
				int h = y - x + arr[now].first;
				if(h >= arr[now].second) now--;
				else break ;
			}
			arr[++now] = {x, y};
		}
	}
	printf("%d\n",now);
	return 0;
}

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  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,&y);
      |   ~~~~~^~~~~~~~~~~~~~~~
#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...