Submission #265315

# Submission time Handle Problem Language Result Execution time Memory
265315 2020-08-14T15:31:48 Z T0p_ Lightning Rod (NOI18_lightningrod) C++14
Compilation error
0 ms 0 KB
#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(!stk.empty())
			{
				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

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:19:11: error: 'stk' was not declared in this scope; did you mean 'std'?
   19 |    while(!stk.empty())
      |           ^~~
      |           std
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);
      |   ~~~~~^~~~~~~~~~~~~~~~