QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404599#8225. 最小值之和strcmp#0 3ms10028kbC++14941b2024-05-04 10:26:222024-05-04 10:26:22

Judging History

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

  • [2024-05-04 10:26:22]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:10028kb
  • [2024-05-04 10:26:22]
  • 提交

answer

#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long int ll;
using pii = pair<int, int>;
const int maxn = 1e6 + 10;
constexpr int mod = 1e9 + 7;
int d[25][25], f[maxn], a[maxn], n, s[maxn];
inline int ck() {
	for (int i = 1; i <= n; i++) s[i] = 0;
	for (int i = 1; i < n; i++) {
		d[i][i] = f[i];
		for (int j = i + 1; j < n; j++) d[i][j] = min(d[i][j - 1], f[j]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) s[i] += d[j][i - 1];
		for (int j = i; j < n; j++) s[i] += d[i][j];
		if (s[i] != a[i]) return 0;
	}
	return 1;
}
void dfs(int u) {
	if (u == n) {
		if (ck()) {
			puts("Yes");
			for (int i = 1; i < n; i++) printf("%d ", f[i]);
			exit(0);
		}
		return;
	}
	for (int i = 1; i <= 20; i++) f[u] = i, dfs(u + 1);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	dfs(1);
	puts("No");
	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: 0ms
memory: 7948kb

input:

5
14 14 12 13 13

output:

Yes
5 3 3 4 

result:

ok The answer is correct.

Test #2:

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

input:

5
4 4 7 7 4

output:

Yes
1 1 4 1 

result:

ok The answer is correct.

Test #3:

score: 11
Accepted
time: 0ms
memory: 7988kb

input:

5
4 13 14 14 13

output:

Yes
1 4 5 4 

result:

ok The answer is correct.

Test #4:

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

input:

5
11 11 10 5 5

output:

Yes
5 4 1 2 

result:

ok The answer is correct.

Test #5:

score: 11
Accepted
time: 2ms
memory: 7996kb

input:

5
10 10 10 4 4

output:

Yes
4 4 1 1 

result:

ok The answer is correct.

Test #6:

score: 11
Accepted
time: 0ms
memory: 10028kb

input:

5
20 20 17 7 4

output:

Yes
10 7 2 1 

result:

ok The answer is correct.

Test #7:

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

input:

5
12 12 16 19 19

output:

Yes
3 3 5 8 

result:

ok The answer is correct.

Test #8:

score: 0
Wrong Answer
time: 3ms
memory: 7668kb

input:

5
2 2 6 11 11

output:

No

result:

wrong answer Line 1 expected p

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%