QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#697558 | #9529. Farm Management | RFIY | WA | 0ms | 3588kb | C++17 | 1.1kb | 2024-11-01 14:49:00 | 2024-11-01 14:49:01 |
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, ti = p[i].l, j = cnt, now = ans - p[i].w * p[i].l;
p[i].l = 0;
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 --;
}
p[i].l = ti;
ans1 = max(ans1, now);
}
cout << ans1;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
99
result:
wrong answer 1st lines differ - expected: '109', found: '99'