QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717018#9529. Farm ManagementzhensamaWA 0ms3704kbC++201.0kb2024-11-06 16:39:022024-11-06 16:39:02

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 16:39:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-11-06 16:39:02]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
using namespace std;
const int N=1e5+10;
struct node
{
    int w,l,r,sum;
}a[N];
bool cmp(node a,node b)
{
    return a.w>b.w||a.w==b.w&&a.l<b.l;
}
void solve()
{
    int n,m;cin>>n>>m;
    int w[n+1],l[n+1],r[n+1];
    int L=0,R=0,S=0;
    for(int i=1;i<=n;i++)
    {
         cin>>a[i].w>>a[i].l>>a[i].r;
        L+=a[i].l;
        R+=a[i].r;
        a[i].sum=a[i].w*a[i].l;
        S+=a[i].sum;
    }
    int ans=0;
    sort(a+1,a+n+1,cmp);
    L-=a[n].l;R-=a[n].r;
    a[n].l=0;a[n].r=m;
    S-=a[n].sum;
    a[n].sum=0;
    ans=S;
    int t=L;
    for(int i=1;i<=n;i++)
    {
        if(t+a[i].r-a[i].l<=m)
        {
            ans+=a[i].w*(a[i].r-a[i].l);
            t+=a[i].r-a[i].l;
        }
        else
        {
            ans+=a[i].w*(m-t);
            break;
        }
    }
    cout<<ans<<'\n';
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;//cin>>t;
    while(t--)
        solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

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: 3632kb

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: 3704kb

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'