Submission #41546

#TimeUsernameProblemLanguageResultExecution timeMemory
41546wzyGlobal Warming (NOI13_gw)C++11
40 / 40
658 ms32768 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define F first #define S second #define pii pair<int,int> vector<pii> t; bool x[1000100]; int n; int main(){ cin>>n; for(int i = 0 ; i < n; i++){ int k ; cin>>k; t.pb(pii(k , i + 1)); x[i+1] = 1; } sort(t.begin() , t.end()); int maxxi = 1; int curr = 1; for(int i = 0 ; i < n; i++){ pii u = t[i]; x[u.S] = 0; if(i && t[i-1].F != u.F){ maxxi = max(maxxi , curr); } if(x[u.S - 1] + x[u.S + 1] == 2) curr++; // Cria nova ilha else if(x[u.S - 1] + x[u.S + 1] == 0) curr--; // Afunda uma ilha existente } cout<<maxxi<<endl; }
#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...