Submission #732098

#TimeUsernameProblemLanguageResultExecution timeMemory
732098TrunktyGlobal Warming (NOI13_gw)C++14
40 / 40
212 ms22540 KiB
#include <bits/extc++.h> using namespace std; typedef long long ll; //#define int ll int n,curr,ans; int arr[1000005]; vector<pair<int,int>> v; bool check[1000005]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=1;i<=n;i++){ cin >> arr[i]; v.push_back({arr[i],i}); } sort(v.begin(),v.end(),greater<pair<int,int>>()); for(int i=0;i<v.size();i++){ int x = v[i].second; check[x] = true; curr++; if(check[x-1]){ curr--; } if(check[x+1]){ curr--; } if(i==v.size()-1 or v[i+1].first!=v[i].first){ ans = max(ans,curr); } } cout << ans << "\n"; return 0; }

Compilation message (stderr)

gw.cpp: In function 'int main()':
gw.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
gw.cpp:30:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(i==v.size()-1 or v[i+1].first!=v[i].first){
      |            ~^~~~~~~~~~~~
#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...