QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#389875#6462. Jewel ThieflouisliangWA 444ms134012kbC++141.1kb2024-04-14 20:49:012024-04-14 20:49:01

Judging History

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

  • [2024-04-14 20:49:01]
  • 评测
  • 测评结果:WA
  • 用时:444ms
  • 内存:134012kb
  • [2024-04-14 20:49:01]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long f[305][50005], n, k, s[1000005];
vector <int> v[305], p;
bool cmp(int x, int y){
	return x > y;
}
void solve(int pos, int l, int r, int pl, int pr){
	if(l > r)
		return;
	int mid = (l + r) >> 1, opt = max(pl, mid - (int)v[pos].size());
	for(int i = opt + 1; i <= min(pr, mid); i++)
		if(f[pos - 1][p[opt]] + s[mid - opt] < f[pos - 1][p[i]] + s[mid - i])
			opt = i;
	f[pos][p[mid]] = f[pos - 1][p[opt]] + s[mid - opt];
	solve(pos, l, mid - 1, pl, opt);
	solve(pos, mid + 1, r, opt, pr);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k;
	for(int i = 1, x, y; i <= n; i++){
		cin >> x >> y;
		v[x].push_back(y);
	}
	for(int i = 1; i <= 300; i++){
		sort(v[i].begin(), v[i].end(), cmp);
		for(int j = 0; j < v[i].size(); j++)
			s[j + 1] = v[i][j] + s[j];
		for(int j = 0; j < i; j++){
			p.clear();
			for(int t = j; t <= k; t += i)
				p.push_back(t);
			solve(i, 0, (int)p.size() - 1, 0, (int)p.size() - 1);
		}
	}
	for(int i = 1; i <= k; i++)
		cout << f[300][i] << " ";
	return 0;
}

詳細信息

Test #1:

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

input:

4 9
2 8
1 1
3 4
5 100

output:

1 8 9 9 100 101 108 109 109 

result:

ok single line: '1 8 9 9 100 101 108 109 109 '

Test #2:

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

input:

5 7
2 2
3 8
2 7
2 4
3 8

output:

0 7 8 11 15 16 19 

result:

ok single line: '0 7 8 11 15 16 19 '

Test #3:

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

input:

2 6
300 1
300 2

output:

0 0 0 0 0 0 

result:

ok single line: '0 0 0 0 0 0 '

Test #4:

score: -100
Wrong Answer
time: 444ms
memory: 134012kb

input:

1000000 100000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

1000000 1999999 2999997 3999994 4999990 5999985 6999979 7999972 8999964 9999955 10999945 11999934 12999922 13999909 14999895 15999880 16999864 17999847 18999829 19999810 20999790 21999769 22999747 23999724 24999700 25999675 26999649 27999622 28999594 29999565 30999535 31999504 32999472 33999439 3499...

result:

wrong answer 1st lines differ - expected: '1000000 1999999 2999997 399999...8249997 94999149999 95000050000', found: '1000000 1999999 2999997 399999...374972 48744324979 48745274985 '