Submission #1129427

#TimeUsernameProblemLanguageResultExecution timeMemory
1129427MatbubbleInfinite Race (EGOI24_infiniterace2)C++20
29 / 100
163 ms34788 KiB
#include <iostream> #include <iomanip> #include <string> #include <math.h> #include <algorithm> #include <cstring> #include <numeric> #include <vector> #include <bitset> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; #define dbg(x) cerr<<#x<<": "<<x<<"\n"; /* Seventh Heaven INOHA */ void solve(){ long long n, q; cin>>n>>q; map<long long, long long>freq; map<long long, vector<long long>>ans; long long aux=0; for(long long i=0 ; i<q ; i++){ long long curr; cin>>curr; if(curr<0){ curr=-curr; freq[curr]=0; }else{ ans[curr].push_back(freq[curr]); freq[curr]++; } } for(auto it:ans){ vector<long long>v=it.second; long long curr=0; for(long long i=0 ; i<(long long)v.size()-1 ; i++){ if(v[i]>v[i+1]) curr+=v[i]; } aux=max(aux, curr+v.back()); } cout<<aux<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...