QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408841#8225. 最小值之和xuqin0 2ms9416kbC++142.8kb2024-05-11 08:56:182024-05-11 08:56:19

Judging History

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

  • [2024-05-11 08:56:19]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:9416kb
  • [2024-05-11 08:56:18]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<random>
#include<chrono>
#include<bitset>
#include<map>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#define eb emplace_back

using namespace std;
const int maxn=(1<<18)+10, maxm=11+10, inf=2e9+10, P=1e9+7;
const double eps=1e-10, pi=acos(-1.0);
typedef long long LL;
typedef unsigned long long ULL;
const LL INF=4e18;
typedef pair<LL, int> pli;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, LL> pll;
inline int read() {
	int x=0, f=1; char c=getchar();
	for(; c<'0'||c>'9'; c=getchar()) if(c=='-') f=0;
	for(; c>='0'&&c<='9'; c=getchar()) x=x*10+c-'0';
	return f?x:-x;
}
mt19937 rnd((unsigned)chrono::steady_clock::now().time_since_epoch().count());
inline int ksm(int x, int y) {
	int s=1;
	for(; y; y>>=1, x=1LL*x*x%P)
		if(y&1) s=1LL*s*x%P;
	return s;
}
inline int add(int x, int y) {x+=y; return x>=P?x-P:x;}
inline int del(int x, int y) {x-=y; return x<0?x+P:x;}
int gcd(int x, int y) {return y?gcd(y, x%y):x;}

int dp[90][90][90], cho[90][90][90];
int a[90], f[90];

void dfs(int l, int r, int k) {
	if(l==r+1) return;
	if(l==r) {
		a[l]+=f[l]-k;
		return;
	}
	int up=dp[l][r][k%(r-l+1)], p=cho[l][r][k%(r-l+1)];
	for(int i=l; i<=r; ++i) a[i]+=(up-k)/(r-l+1);
	dfs(l, p-1, up); dfs(p+1, r, up);
}

int main() {
	int n=read(), fl=0;
	for(int i=1; i<=n; ++i) f[i]=read();
	if(fl) return puts("No"), 0;
	memset(dp, -1, sizeof dp);
	for(int len=1; len<=n-1; ++len) {
		for(int l=1; l+len-1<=n-1; ++l) {
			int r=l+len-1;
			if(l==r) {
				if(f[l]==f[l+1]) dp[l][l][0]=f[l];
				//for(int i=0; i<r-l+1; ++i)
				//	printf("[%d, %d] dp[%d]=%d\n", l, r, i, dp[l][r][i]);
				continue;
			} 
			//p=l or r
			if(dp[l+1][r][f[l]%(r-l)]>=f[l]) {
				if(f[l]>dp[l][r][f[l]%(r-l+1)]) {
					dp[l][r][f[l]%(r-l+1)]=f[l];
					cho[l][r][f[l]%(r-l+1)]=l;
				}
			}
			if(dp[l][r-1][f[r+1]%(r-l)]>=f[r+1]) {
				if(f[r+1]>dp[l][r][f[r+1]%(r-l+1)]) {
					dp[l][r][f[r+1]%(r-l+1)]=f[r+1];
					cho[l][r][f[r+1]%(r-l+1)]=r;
				}
			}
			
			for(int p=l+1; p<r; ++p) {
				int u=p-l, v=r-p, d=gcd(u, v), lcm=u/d*v;
				for(int i=0; i<lcm; ++i) {
					int t1=dp[l][p-1][i%u], t2=dp[p+1][r][i%v];
					if(t1>=i&&t2>=i) {
						int b=min((t1-i)/lcm, (t2-i)/lcm);
						for(int t=b; t>=0&&t>b-(r-l+1); --t) {
							int val=t*lcm+i;
							if(val>dp[l][r][val%(r-l+1)]) {
								dp[l][r][val%(r-l+1)]=val;
								cho[l][r][val%(r-l+1)]=p;
							}
						}
					}
				}
			}
			//for(int i=0; i<r-l+1; ++i)
			//	printf("[%d, %d] dp[%d]=%d\n", l, r, i, dp[l][r][i]);
		}
	}
	if(dp[1][n-1][0]<0) return puts("No"), 0;
	puts("Yes");
	dfs(1, n-1, 0);
	for(int i=1; i<n; ++i) printf("%d ", a[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 1ms
memory: 7120kb

input:

5
14 14 12 13 13

output:

Yes
5 3 3 4 

result:

ok The answer is correct.

Test #2:

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

input:

5
4 4 7 7 4

output:

Yes
1 1 4 1 

result:

ok The answer is correct.

Test #3:

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

input:

5
4 13 14 14 13

output:

Yes
1 4 5 4 

result:

ok The answer is correct.

Test #4:

score: 0
Accepted
time: 1ms
memory: 7160kb

input:

5
11 11 10 5 5

output:

Yes
5 4 1 2 

result:

ok The answer is correct.

Test #5:

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

input:

5
10 10 10 4 4

output:

Yes
4 4 1 1 

result:

ok The answer is correct.

Test #6:

score: 0
Accepted
time: 1ms
memory: 8592kb

input:

5
20 20 17 7 4

output:

Yes
10 7 2 1 

result:

ok The answer is correct.

Test #7:

score: 0
Accepted
time: 1ms
memory: 8060kb

input:

5
12 12 16 19 19

output:

Yes
3 3 5 8 

result:

ok The answer is correct.

Test #8:

score: 0
Accepted
time: 2ms
memory: 8756kb

input:

5
2 2 6 11 11

output:

Yes
2 0 3 8 

result:

ok The answer is correct.

Test #9:

score: 0
Accepted
time: 1ms
memory: 8196kb

input:

5
10 10 8 5 5

output:

Yes
5 3 1 2 

result:

ok The answer is correct.

Test #10:

score: 0
Accepted
time: 1ms
memory: 7268kb

input:

5
24 24 28 28 26

output:

Yes
6 6 9 7 

result:

ok The answer is correct.

Test #11:

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

input:

5
5 5 22 31 31

output:

Yes
2 1 10 19 

result:

ok The answer is correct.

Test #12:

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

input:

5
8 33 38 38 29

output:

Yes
2 11 16 9 

result:

ok The answer is correct.

Test #13:

score: 0
Accepted
time: 1ms
memory: 7568kb

input:

5
16 16 4 12 12

output:

Yes
13 1 1 9 

result:

ok The answer is correct.

Test #14:

score: 0
Accepted
time: 1ms
memory: 7620kb

input:

5
29 29 24 26 26

output:

Yes
11 6 6 8 

result:

ok The answer is correct.

Test #15:

score: 0
Accepted
time: 1ms
memory: 7340kb

input:

5
0 33 33 32 32

output:

Yes
0 13 10 12 

result:

ok The answer is correct.

Test #16:

score: 0
Accepted
time: 1ms
memory: 8144kb

input:

5
20 16 8 25 22

output:

No

result:

ok The answer is correct.

Test #17:

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

input:

5
0 2 3 0 2

output:

No

result:

ok The answer is correct.

Test #18:

score: 0
Accepted
time: 1ms
memory: 7744kb

input:

5
28 23 29 29 24

output:

No

result:

ok The answer is correct.

Test #19:

score: 0
Accepted
time: 1ms
memory: 6700kb

input:

5
0 1 0 4 2

output:

No

result:

ok The answer is correct.

Test #20:

score: 0
Accepted
time: 1ms
memory: 6824kb

input:

5
12 21 21 13 4

output:

No

result:

ok The answer is correct.

Test #21:

score: 0
Accepted
time: 1ms
memory: 7664kb

input:

5
9 22 25 23 12

output:

No

result:

ok The answer is correct.

Test #22:

score: 0
Accepted
time: 1ms
memory: 8516kb

input:

5
6 7 7 6 6

output:

Yes
2 3 1 3 

result:

ok The answer is correct.

Test #23:

score: 0
Accepted
time: 1ms
memory: 8256kb

input:

5
25 25 24 20 20

output:

Yes
8 7 5 5 

result:

ok The answer is correct.

Test #24:

score: 0
Accepted
time: 1ms
memory: 8540kb

input:

5
17 9 8 16 9

output:

No

result:

ok The answer is correct.

Test #25:

score: 0
Accepted
time: 1ms
memory: 6456kb

input:

5
20 5 34 34 23

output:

No

result:

ok The answer is correct.

Test #26:

score: 0
Accepted
time: 1ms
memory: 7676kb

input:

5
15 33 35 35 31

output:

No

result:

ok The answer is correct.

Test #27:

score: 0
Accepted
time: 1ms
memory: 6636kb

input:

5
21 22 23 1 18

output:

No

result:

ok The answer is correct.

Test #28:

score: 0
Accepted
time: 1ms
memory: 7232kb

input:

5
4 2 3 4 2

output:

No

result:

ok The answer is correct.

Test #29:

score: 0
Accepted
time: 1ms
memory: 6504kb

input:

5
16 25 8 19 7

output:

No

result:

ok The answer is correct.

Test #30:

score: 0
Accepted
time: 1ms
memory: 7860kb

input:

5
4 0 8 6 6

output:

No

result:

ok The answer is correct.

Test #31:

score: 0
Accepted
time: 1ms
memory: 7660kb

input:

2
2 3

output:

No

result:

ok The answer is correct.

Test #32:

score: 0
Accepted
time: 1ms
memory: 6768kb

input:

2
2 2

output:

Yes
2 

result:

ok The answer is correct.

Test #33:

score: -11
Wrong Answer
time: 1ms
memory: 7244kb

input:

1
0

output:

No

result:

wrong answer Line 1 expected 

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%