QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#210520#6540. Beautiful Sequence275307894aWA 1ms8152kbC++141.0kb2023-10-11 15:43:222023-10-11 15:43:22

Judging History

你现在查看的是最新测评结果

  • [2023-10-11 15:43:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8152kb
  • [2023-10-11 15:43:22]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e6+5,M=N*4,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const ll INF=1e18+7;mt19937 rnd(263082);
int n,m,A[N],B[N];
void Solve(){
	int i,j;scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&A[i]);sort(A+1,A+n+1);
	fill(B+1,B+n+1,0);
	m=0;for(i=1;i<=n;i++) m+=(A[i]!=A[i-1]),B[m]++;
	int ans=0,sum=0;
	for(i=1;i<=m;i++){
		if(B[i]>=3) ans+=B[i]-2;
		if(sum) ans+=min(B[i],2),sum--;
		else sum++,ans+=(B[i]>=2);
	}
	printf("%d\n",ans+(sum+1)/2);
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 8152kb

input:

2
6
1 1 2 3 3 4
5
1 2 2 3 3

output:

4
4

result:

ok 2 number(s): "4 4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 6100kb

input:

2
5
1 2 2 3 3
20
1 1 1 1 1 1 4 5 8 8 8 8 9 9 9 9 10 10 10 10

output:

4
17

result:

ok 2 number(s): "4 17"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 6124kb

input:

300
14
1 1 1 2 2 2 3 3 3 4 5 5 6 6
14
1 1 1 2 2 3 3 4 4 5 5 6 7 7
14
1 1 2 2 3 4 4 4 5 5 5 6 6 6
14
1 1 2 2 3 3 3 4 5 5 5 6 6 6
14
1 1 1 1 1 1 2 2 2 2 2 3 3 3
14
1 1 1 1 1 1 1 1 1 1 1 1 1 1
14
1 2 2 3 4 5 5 6 6 6 7 8 8 8
14
1 2 2 2 2 2 3 4 5 6 7 8 9 10
14
1 2 2 3 4 4 4 5 6 6 6 6 6 7
14
1 1 2 2 2 3 3...

output:

11
11
11
11
13
14
10
9
11
11
9
10
10
9
12
12
11
10
10
12
10
9
10
10
11
11
11
11
11
11
10
9
10
10
10
11
11
13
12
12
12
11
9
10
10
11
11
10
11
9
11
10
11
10
11
10
11
11
11
12
12
10
10
10
10
10
9
11
11
12
11
10
10
10
11
10
11
10
10
10
9
11
9
11
9
12
10
11
12
12
9
9
11
9
12
11
10
12
10
11
11
10
10
9
11
...

result:

wrong answer 1st numbers differ - expected: '10', found: '11'