# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
273072 | T0p_ | Global Warming (NOI13_gw) | C++14 | 1081 ms | 17012 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int n;
long long h[1001000];
vector<long long> v;
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]);
v.push_back(h[i]);
}
sort(v.begin(), v.end());
int l = 0, r = n-1;
while(l != r)
{
int mid = (l+r+1)>>1;
int ll = 0, rr = mid;
while(ll != rr)
{
int mm = (ll+rr+1)>>1;
(solve(v[mm]) != solve(v[mid])) ? ll = mm : rr = mm-1;
}
(solve(v[ll]) <= solve(v[mid])) ? l = mid : r = mid-1;
}
printf("%d\n",solve(v[l]));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |