QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#685277#9529. Farm Managementehdxbc#WA 0ms3572kbC++20996b2024-10-28 18:38:452024-10-28 18:38:46

Judging History

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

  • [2024-10-28 18:38:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-10-28 18:38:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//#define int long long
using LL = long long;
typedef pair<int,int> PII;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 2E9;
using vi = vector<int>;
using vp = vector<PII>;
#define all(x) begin(x), end(x) 
struct node{
	int w, l, r;
};
void solve() {
	int n;
	LL m;
	cin >> n >> m;
	vector<node> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].w >> v[i].l >> v[i].r;
	}
	sort(all(v), [&](const struct node &x, const struct node &y) {
		return x.w > y.w;
	});
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		auto [w, l, r] = v[i];
		if (m >= l) {
			if (m >= r) {
				ans += 1ll * w * r;
				m -= r;
			} else {
				ans += 1ll * m * w;
				m = 0;
			}
		} else {
			continue;
		}
		if (m == 0) break;
	}
	cout << ans << endl;
}

signed main() {
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   int t = 1;
   // cin >> t;
   while (t--) {
      solve();
   }
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3572kb

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:

40106857

result:

wrong answer 1st lines differ - expected: '35204500', found: '40106857'