Submission #273072

#TimeUsernameProblemLanguageResultExecution timeMemory
273072T0p_Global Warming (NOI13_gw)C++14
6 / 40
1081 ms17012 KiB
#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)

gw.cpp: In function 'int main()':
gw.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |  scanf(" %d",&n);
      |  ~~~~~^~~~~~~~~~
gw.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |   scanf(" %lld",&h[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
#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...