QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#700793#9529. Farm ManagementCCSU_YZT#WA 0ms3884kbC++20925b2024-11-02 13:23:592024-11-02 13:24:04

Judging History

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

  • [2024-11-02 13:24:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3884kb
  • [2024-11-02 13:23:59]
  • 提交

answer

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

#define ll long long
bool cmp(array<int, 3> u, array<int, 3> v) {
	if (u[0] == v[0]) return u[1] < v[1];
	return u[0]> v[0];
}

void solve() {
	ll n, m;
	cin>>n>>m;
	vector<array<int, 3> > a(n+1);
	for (int i = 1; i <= n; i++) {
		int w, l, r;
		cin>>w>>l>>r;
		a[i] = {w, l, r};
	}
//	printf("ddd\n");
	sort(a.begin()+1, a.begin()+n+1, cmp);
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ans += 1ll * a[i][0] * a[i][1];
		m -= a[i][1];
		a[i][2] -= a[i][1];
	}
	for (int i = 1; i < n; i++) {
		ll mn = min(m, 1ll * a[i][2]);
		ans += mn * a[i][0];
		m -= mn;
	}
	ans += a[n][0] * m;
	cout<<ans<<'\n';
}

int main()
{
	if (ifstream("test.in")) {
		freopen("test.in", "r", stdin);
//		freopen("test.out", "w", stdout);
	}
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
//	cin>>T;
	while (T--) {
		solve();
	}
	return 0;
} 

詳細信息

Test #1:

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

input:

5 17
2 3 4
6 1 5
8 2 4
4 3 3
7 5 5

output:

109

result:

ok single line: '109'

Test #2:

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

input:

12 62
503792 9 10
607358 1 3
600501 10 10
33249 4 4
774438 6 6
197692 3 6
495807 8 8
790225 5 9
77272 3 8
494819 4 9
894779 3 9
306279 5 6

output:

35204500

result:

ok single line: '35204500'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

15 32
835418 2 3
178262 1 3
527643 2 2
519710 1 1
774544 3 3
82312 1 1
808199 1 1
809396 1 3
255882 1 3
80467 1 3
874973 1 3
813965 1 2
198275 1 2
152356 1 3
802055 1 1

output:

17015002

result:

wrong answer 1st lines differ - expected: '22000255', found: '17015002'