QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#697553 | #9529. Farm Management | RFIY | WA | 0ms | 3664kb | C++17 | 1.0kb | 2024-11-01 14:46:38 | 2024-11-01 14:46:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 10;
struct st{
ll w, l, r;
}p[N];
bool cmp(st x, st y){
return x.w < y.w;
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll n, m;
cin >> n >> m;
for(int i = 0; i < n; i ++){
cin >> p[i].w >> p[i].l >> p[i].r;
}
sort(p, p + n, cmp);
ll ans = 0, res = 0;
for(int i = 0; i < n; i ++){
ans += p[i].w * p[i].l;
res += p[i].l;
}
ll ans1 = ans + (m - res) * p[n - 1].w;
ll cnt = n - 1;
for(int i = n - 1; i >= 0; i --){
ll cur = min(m - res, p[i].r - p[i].l);
ans += p[i].w * cur;
res += cur;
p[i].l += cur;
if(!res){
cnt = i;
break;
}
}
for(int i = 0; i <= cnt; i ++){
ll cur = p[i].l, j = cnt, now = ans;
while(cur && j){
cur -= min(cur, p[j].r - p[j].l);
now += p[j].w * min(cur, p[j].r - p[j].l);
j --;
}
ans1 = max(ans1, now);
}
cout << ans1;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
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: 3588kb
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:
37022500
result:
wrong answer 1st lines differ - expected: '35204500', found: '37022500'