QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720862#8281. Pangu and StonesMine_KingWA 1ms3904kbC++141.3kb2024-11-07 14:30:452024-11-07 14:30:45

Judging History

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

  • [2024-11-07 14:30:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3904kb
  • [2024-11-07 14:30:45]
  • 提交

answer

// 長い夜の終わりを信じながら
// Think twice, code once.
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eputchar(c) putc(c, stderr)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define eputs(str) fputs(str, stderr), putc('\n', stderr)
using namespace std;

int n, l, r, a[105];
priority_queue<int, vector<int>, greater<>> q;
long long ans = 0x3f3f3f3f3f3f3f3f;

int main() {
	scanf("%d%d%d", &n, &l, &r);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n - 1; i++) {
		int num = (n - 1) / i, cnt = (n - 1) % i;
		while (!q.empty()) q.pop();
		for (int j = 1; j <= n; j++) q.emplace(a[j]);
		int flag = 1;
		long long res = 0;
		for (int j = 1; j <= cnt; j++) {
			flag &= l <= num + 2 && num + 2 <= r;
			int sum = 0;
			for (int k = 1; k <= num + 2; k++) sum += q.top(), q.pop();
			res += sum;
			q.push(sum);
		}
		for (int j = 1; j <= i - cnt; j++) {
			flag &= l <= num + 1 && num + 1 <= r;
			int sum = 0;
			for (int k = 1; k <= num + 1; k++) sum += q.top(), q.pop();
			res += sum;
			q.push(sum);
		}
		if (flag) ans = min(ans, res);
	}
	printf("%lld\n", ans != 0x3f3f3f3f3f3f3f3f ? ans : 0ll);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3828kb

input:

3 2 2
1 2 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

3 2 3
1 2 3

output:

6

result:

ok 1 number(s): "6"

Test #3:

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

input:

4 3 3
1 2 3 4

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

100 4 7
570 608 194 26 243 470 418 119 1000 936 440 302 797 155 676 283 869 60 959 793 158 397 808 656 379 316 485 854 753 280 543 435 756 822 106 561 402 347 99 739 8 682 834 549 812 32 338 765 699 575 575 785 171 504 335 113 284 612 276 518 835 677 865 900 687 48 859 179 343 318 626 812 523 11 400...

output:

123011

result:

wrong answer 1st numbers differ - expected: '120446', found: '123011'