QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700739 | #9529. Farm Management | CCSU_YZT# | WA | 0ms | 3884kb | C++20 | 837b | 2024-11-02 13:21:16 | 2024-11-02 13:21:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
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, greater<array<int, 3> >());
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: 3884kb
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: 3576kb
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: 3640kb
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'