Submission #982271

#TimeUsernameProblemLanguageResultExecution timeMemory
982271vjudge1Sequence (APIO23_sequence)C++17
7 / 100
695 ms80428 KiB
#include "sequence.h" #include<bits/stdc++.h> using namespace std; priority_queue<int>pql; priority_queue<int,vector<int>,greater<>>pqu; map<int,int>st2; void balance(){ if(pql.size()<pqu.size()) pql.push(pqu.top()),pqu.pop(); if(pql.size()-pqu.size()>1) pqu.push(pql.top()),pql.pop(); } int sequence(int N, std::vector<int> A) { int ans=1,cnt=0; map<int,int>mp,c1,c2; for(auto i:A) mp[i]; for(auto&[i,j]:mp) j=cnt++; for(auto&i:A) i=mp[i]; vector<int>v2=A; vector<int>ok(cnt); sort(v2.begin(),v2.end()); for(int i=N-1>>1;i<N;i++) ok[v2[i]]=1; A.push_back(-1); int dec=0; for(int i=0;i<N;i++){ (dec?c1:c2)[A[i]]++; if(A[i]>A[i+1]) dec=1; } for(int i=0;i<cnt;i++)if(ok[i]) ans=max(ans,c1[i]+c2[i]); else ans=max({ans,c1[i],c2[i]}); return ans; }

Compilation message (stderr)

sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:25:16: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   25 |     for(int i=N-1>>1;i<N;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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...