995,WA
  • 板块学术版
  • 楼主xmy201315
  • 当前回复3
  • 已保存回复3
  • 发布时间2025/1/18 19:39
  • 上次更新2025/1/18 22:27:15
查看原帖
995,WA
1259915
xmy201315楼主2025/1/18 19:39

#include <bits/stdc++.h>
using namespace std;
#define N 200010
#define sz(s) s.size()
#define db double
#define mod 1000000007
#define P 998244353
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define per(i,l,r) for(ll i=l;i>=r;i--)
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define in insert
#define y1 y142857
//pair<ll,ll> PII;
//unordered_map<int,int> f;
vector<int>edges[N];
//set<int>c;
int huiwen(int x){int b[100],l=0,t=x;while(t!=0){b[++l]=t%10;t/=10;}for(int i=1,j=l;i<=j;i++,j--)if(b[i]!=b[j])return 0;return 1;}
int prime(int x){for(int i=2;i*i<=x;i++)if(x%i==0)return 0;return 1;} 
inline int gcd(int a,int b){if(a<b)gcd(b,a);if(!b)return a; return gcd(b,a%b);} 
inline int lcm(int a,int b){return a*b/gcd(a,b);}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void pri(int x){
    if(x==1)putchar(' ');
    if(x==2)putchar('\n');
}
inline void put(int x){
    if(x==1)puts("Yes");
    if(x==2)puts("No");
    if(x==3)puts("YES");
    if(x==4)puts("NO");
    if(x==5)puts("yes");
    if(x==6)puts("no");
}
inline void write(ll x,ll w,ll e){
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10,w,e);
    putchar(x%10+'0');
    if(x==e){
        if(w==1)putchar(' ');
        if(w==2)putchar('\n');
    }
    return;
}
//time: O( )
 //memory: ()kb
int a[N];
inline void sovel(){
    int n=read(),ans=0,u=0,f,ma=-1;
    rep(i,1,n)a[i]=read();
    sort(a+1,a+n+1);
	f=a[1],u=1;
    rep(i,2,n+1){
		if(a[i]!=f){
			if(u%2)ma=max(ma,u);
			else ans+=u;
			f=a[i],u=1;
		}else u++;
	}if(ma==-1)ma=0;
	ans+=ma;
	write(ans,2,ans);
}
int main(){
    int _=1;
    while(_--)sovel();
}
//https://www.luogu.com.cn/user/annual-report

求hack,玄关

2025/1/18 19:39
加载中...