Submission #1125524

#TimeUsernameProblemLanguageResultExecution timeMemory
1125524ElayV13Infinite Race (EGOI24_infiniterace2)C++20
0 / 100
63 ms12872 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld double
#define FOR(L , R) for(int i = L;i <= R;i++)

const int INF = 1e18;
const int sz = 2e5 + 5;
const int usz = 1e6 + 5;
const int mod = 998244353;

signed main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int ans = 0;
   int n , q;
   cin >> n >> q;
   vector < bool > dp(n , false);
   map < int , int > cnt;
   while(q--)
   {
      int x;
      cin >> x;
      if(0 > x)
      {
         if(!dp[abs(x)])
         {
            cnt[abs(x)]++;
         }
         else
         {
            cnt[abs(x)] = 0;
            dp[abs(x)] = false;
         }
      }
      if(x > 0)
      {
         if(dp[abs(x)])
         {
            cnt[abs(x)]++;
            ans = max(ans , cnt[abs(x)]);
         }
         else
         {
            cnt[abs(x)] = 0;
            dp[abs(x)] = true;
         }
      }
   }
   cout << ans << 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...