Submission #273052

# Submission time Handle Problem Language Result Execution time Memory
273052 2020-08-19T03:09:05 Z T0p_ Global Warming (NOI13_gw) C++14
6 / 40
282 ms 17532 KB
#include<bits/stdc++.h>
using namespace std;

int n;
long long h[1001000];

int solve(long long x)
{
	bool ch = x < h[1];
	int ret = 0;
	for(int i=2 ; i<=n ; i++)
	{
		if(x < h[i]) ch = true;
		else
		{
			if(ch)
			{
				ch = false;
				ret++;
			}
		}
	}
	if(ch) ret++;
	return ret;
}

int main()
{
	scanf(" %d",&n);
	for(int i=1 ; i<=n ; i++)
		scanf(" %lld",&h[i]);
	long long l = 0, r = 2e9;
	while(l != r)
	{
		long long mid = (l+r)>>1;
		(solve(mid) >= solve(mid+1)) ? r = mid : l = mid+1;
	}
	printf("%d\n",solve(l));
	return 0;
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  scanf(" %d",&n);
      |  ~~~~~^~~~~~~~~~
gw.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |   scanf(" %lld",&h[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1408 KB Output is correct
2 Correct 23 ms 1408 KB Output is correct
3 Correct 22 ms 1408 KB Output is correct
4 Correct 22 ms 1408 KB Output is correct
5 Correct 21 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 282 ms 17532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 264 ms 16944 KB Output isn't correct
2 Halted 0 ms 0 KB -