QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700979 | #9529. Farm Management | CCSU_YZT# | WA | 1ms | 3880kb | C++20 | 1.1kb | 2024-11-02 13:36:53 | 2024-11-02 13:36:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool cmp(array<ll, 3> u, array<ll, 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<ll, 3> > a(n+1);
for (int i = 1; i <= n; i++) {
ll w, l, r;
cin>>w>>l>>r;
a[i] = {w, l, r};
}
sort(a.begin()+1, a.begin()+n+1, cmp);
ll ans = 0;
for (int i = 1; i < n; i++) {
ans += 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, a[i][2]);
ans += mn * a[i][0];
m -= mn;
}
ans += a[n][0] * m;// 最后一个尽量小
ll res = 0;
for (int i = 2; i <= n; i++) {
ll mn = min(m, a[i][1]);
res += mn * a[i][0];
m -= mn;
}
res += m*a[1][0];// 第一个尽量大
cout<<max(ans, res)<<'\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: 3644kb
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: 1ms
memory: 3880kb
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: 3808kb
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'