QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#430885#7793. 雷同bdzzj5 15ms200496kbC++14728b2024-06-04 16:31:322024-06-04 16:31:35

Judging History

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

  • [2024-06-04 16:31:35]
  • 评测
  • 测评结果:5
  • 用时:15ms
  • 内存:200496kb
  • [2024-06-04 16:31:32]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define N 10005
using namespace std;
const ll INF=1e18;
int n,w[N];
ll val[N],sum[N],dp[N][N];
inline void tomin(ll &a,ll b){a=min(a,b);return;}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&w[i]);
		sort(w+1,w+n+1);
		for(int i=1;i<=n;i++) sum[i]=sum[i-1]+w[i];
		for(int i=1;i<=n;i++) val[i]=(i&-i)-__builtin_popcount(i&-i)-1;
		for(int i=0;i<=n;i++) for(int j=0;j<=i;j++) dp[i][j]=INF;
		dp[0][0]=1;
		for(int i=0;i<=n;i++){
			for(int j=i;j>=0;j--){
				if(i+1<=n) tomin(dp[i+1][j+1],dp[i][j]+val[j+1]);
				if(~j&1) tomin(dp[i][j/2],dp[i][j]+sum[i]);
			}
		}
		printf("%lld\n",dp[n][1]);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 6184kb

input:

4
6
1 3 5 7 9 11
6
2 4 6 8 10 12
6
100 1000 100 10 100 10
2
114514 1919810

output:

86
103
1981
2034324

result:

ok 4 tokens

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3884kb

input:

5
12
2 4 3 2 2 3 4 2 3 2 2 1
12
3 3 3 2 3 2 3 2 1 1 2 4
12
6 2 2 2 5 4 6 1 2 8 8 6
12
1 4 2 2 1 6 7 2 4 1 7 5
12
11 1 2 6 16 16 15 8 8 16 6 12

output:

112
108
182
144
400

result:

wrong answer 1st words differ - expected: '114', found: '112'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Wrong Answer

Test #39:

score: 0
Wrong Answer
time: 15ms
memory: 200496kb

input:

2
2500
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

94281
37354253305

result:

wrong answer 1st words differ - expected: '96493', found: '94281'

Subtask #7:

score: 0
Skipped

Dependency #5:

0%