QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#714321 | #9529. Farm Management | L_liu11# | WA | 0ms | 3564kb | C++17 | 1.5kb | 2024-11-05 22:38:27 | 2024-11-05 22:38:28 |
Judging History
answer
// Problem: K - 农场经营
// Contest: Virtual Judge - 第十届中国大学生程序设计竞赛(哈尔滨)-(CCPC2024-Harbin)
// URL: https://vjudge.net/contest/665838#problem/K
// Memory Limit: 1024 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
struct node{
ll w,l,r;
};
node a[N];
ll p[N],k[N];
bool cmp(node a,node b)
{
return a.w > b.w;
}
int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ll n,m,sum = 0,cnt,maxn = -1;
cin >> n >> m;
cnt = m;
for(int i=1; i<=n; i++)
{
cin >> a[i].w >> a[i].l >> a[i].r;
sum += a[i].w * a[i].l;
cnt -= a[i].l;
}
sort(a+1,a+1+n,cmp);
for(int i=1; i<=n; i++)
{
k[i] += k[i-1] + (a[i].r - a[i].l);
p[i] += p[i-1] + (a[i].r - a[i].l) * a[i].w;
}
// for(int i=1; i<=n; i++)
// {
// cout << a[i].w << " " << a[i].l << " " << a[i].r << " " << k[i] << " " << p[i] << "\n";
// }
for(int i=1; i<=n; i++)
{
ll yv = cnt + a[i].l;
ll ans = sum - a[i].l * a[i].w;
maxn = max(ans + yv * a[i].w , maxn);
ll ip = lower_bound(k+1,k+1+n,yv) - k;
cout << ip << "\n";
ans += p[ip] - (k[ip]-yv) * a[ip].w;
maxn = max(ans , maxn);
}
cout << maxn;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
3 6 3 3 3 109
result:
wrong answer 1st lines differ - expected: '109', found: '3'