QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#672948 | #9529. Farm Management | ucup-team4474# | WA | 1ms | 3868kb | C++20 | 1.6kb | 2024-10-24 19:59:51 | 2024-10-24 19:59:51 |
Judging History
answer
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read()
{
ll s=0,f=1;
char x=getchar();
while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
while(isdigit(x))s=s*10+x-'0',x=getchar();
return s*f;
}
const int p=1e9+7;
//ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
struct hlydl{
ll w,l,r;
}t[100005];
int main()
{
int n=reaD();
ll m=read();
for(int i=1;i<=n;i++)
{
int w=reaD(),l=reaD(),r=reaD();
t[i]=(hlydl){w,l,r};
}
sort(t+1,t+n+1,[](hlydl x,hlydl y){
return x.w<y.w;
});
ll ans=0,anss=0;
for(int i=1;i<=n;i++)
ans+=t[i].l*t[i].w,m-=t[i].l;
for(int i=n;i>=1;i--)
{
ans-=t[i].l*t[i].w;
m+=t[i].l;
anss=max(anss,ans+m*t[i].w);
ans+=t[i].r*t[i].w;
m-=t[i].r;
}
printf("%lld",anss);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3796kb
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: 3868kb
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:
44007019
result:
wrong answer 1st lines differ - expected: '35204500', found: '44007019'