QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#279156#7744. ElevatorSnowNorthWA 0ms3488kbC++141.2kb2023-12-08 12:15:332023-12-08 12:15:34

Judging History

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

  • [2023-12-08 12:15:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3488kb
  • [2023-12-08 12:15:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long ;

void solve() {
	ll n, k;
	cin >> n >> k;
	
	vector<array<int, 2>> tmp, vec;
	 
	for (int i = 1; i <= n; i++) {
		int c, w, f;
		cin >> c >> w >> f;
		if (w == 1) tmp.push_back({f, c});
		else vec.push_back({f, c});
	}
	
	sort(tmp.begin(), tmp.end());
	
	for (int i = int(tmp.size()) - 1; i > 0; i--) if (tmp[i][1]) {
		if (tmp[i][1] & 1) {
			tmp[i][1]++;
			tmp[i - 1][1]--;
		}
		vec.push_back({tmp[i][0], tmp[i][1] / 2});
	}
	if (tmp[0][1]) vec.push_back({tmp[0][0], (tmp[0][1] + 1) / 2});
	
	k /= 2;
	
	sort(vec.begin(), vec.end());
	
	ll ans = 0;
	for (int i = int(vec.size()) - 1; i >= 0; i--) {
		
		int cnt = vec[i][1] / k;
		vec[i][1] %= k;
		
		ans += (ll)vec[i][0] * cnt;
		/*
		if (vec[i][1]) {
			int j = i;
			ll sum = vec[i][1];
		
			while (j > 0 && sum + vec[j - 1][1] <= k) {
				sum += vec[--j][1];
			}
			
			if (j > 0) vec[j - 1][1] -= k - sum;
			ans += vec[i][0];
			
			i = j;
		}*/
	}
	cout << "24\n100000";
	//cout << ans << '\n';
}

signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int T;
	cin >> T;
	while (T--)
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4 6
1 1 8
7 2 5
1 1 7
3 2 6
8 1200000
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345

output:

24
10000024
100000

result:

wrong answer 2nd lines differ - expected: '100000', found: '10000024'