Submission #1342967

#TimeUsernameProblemLanguageResultExecution timeMemory
1342967nathlol2Infinite Race (EGOI24_infiniterace2)C++20
29 / 100
21 ms11240 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, q, ans;
vector<int> a[N];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> q;
    for(int i = 1;i<=q;i++){
        int x; cin >> x;
        if(x > 0) a[x].push_back(1);
        else a[-x].push_back(0);
    }
    for(int i = 1;i<n;i++){
        bool f = 0;
        int res = 0;
        for(auto x : a[i]){
            if(x){
                if(f) ++res;
                else f = 1;  
            }else{
                if(f) f = 0;
            }
        }
        ans = max(ans, res);
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...