Submission #425444

#TimeUsernameProblemLanguageResultExecution timeMemory
425444errorgornGlobal Warming (NOI13_gw)C++17
40 / 40
354 ms18604 KiB
#include <cstdio> #include <algorithm> #include <utility> #include <vector> using namespace std; typedef pair<int,int> ii; vector<ii> v; int n,t,islands,max_islands,pp=1; bool arr[1000005]; int main(){ scanf("%d",&n); for (int x=1;x<=n;x++){ scanf("%d",&t); v.push_back(ii (-t,x)); } sort(v.begin(),v.end()); for (vector<ii>::iterator it=v.begin();it!=v.end();it++){ if ((*it).first!=pp){ pp=(*it).first; max_islands=max(islands,max_islands); } t=(*it).second; if (!(arr[t-1] || arr[t+1])){ islands++; } else if (arr[t-1] && arr[t+1]){ islands--; } arr[t]=true; } printf("%d\n",max(max_islands,islands)); }

Compilation message (stderr)

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