제출 #1343821

#제출 시각아이디문제언어결과실행 시간메모리
1343821kokorooInfinite Race (EGOI24_infiniterace2)C++20
29 / 100
14 ms6704 KiB
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define print(a) cout<<a<<endl
typedef long long ll;
#define yn(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YN(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define so(a) sort(a.begin(),a.end())
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define pb push_back
#define a2i(a,s) (ll)(a-s)
#define i2a(s,a) (char)(s+a)
#define ssize(a) a.size()
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<pair<ll,ll>,ll> P3;
typedef pair<pair<ll,ll>,pair<ll,ll>> P4;

typedef pair<ll, ll> Pll;
typedef pair<ll,Pll> Plll;
typedef pair<Pii, int> Piii;
const ll INF = 1000000000000000000;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;

}
using ull=unsigned long long;

int main(){
//入力

	cin.tie(0);
	ios::sync_with_stdio(0);

	ll n,q;
	cin>>n>>q;

	vector<ll> ans(n,0);
	vector<ll> ans2(n,0);

	vector<ll> v(n,1);//直前ぬかした
	vector<ll> v2(n,0);//直前抜かされた

//判定
	for(ll i=0;i<q;i++){
		ll t;
		cin>>t;
		if(t<0){
			t=0-t;
			if(v[t]==1)ans[t]++;
			else v[t]=1;
			v2[t]=0;
		}else{
			if(v2[t]==1)ans2[t]++;
			else v2[t]=1;
			v[t]=0;
		}
	}

	ll ma=0;
	for(ll i=1;i<n;i++)ma=max(ans2[i],ma);
	cout<<ma<<endl;


	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...