Submission #265318

# Submission time Handle Problem Language Result Execution time Memory
265318 2020-08-14T15:35:41 Z T0p_ Lightning Rod (NOI18_lightningrod) C++14
0 / 100
2000 ms 61596 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 ;
			int l = 1, r = now;
			while(l != r)
			{
				int mid = (l+r+1)>>1;
				int h = y - x + arr[mid].first;
				if(h >= arr[mid].second) r = mid-1;
				else l = mid;
			}
			now = l;
			arr[++now] = {x, y};
		}
	}
	printf("%d\n",now);
	return 0;
}

Compilation message

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 time Memory Grader output
1 Execution timed out 2049 ms 61596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 41556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2049 ms 61596 KB Time limit exceeded
2 Halted 0 ms 0 KB -