QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801342#9730. Elevator IIProaesWA 0ms3880kbC++11918b2024-12-06 21:30:032024-12-06 21:30:04

Judging History

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

  • [2024-12-06 21:30:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3880kb
  • [2024-12-06 21:30:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define wln putchar('\n')
#define ll long long
const int N=100005;
int n,f,a[N],b[N],p[N];
void Main()
{
    scanf("%d%d",&n,&f);
    For(i,1,n)scanf("%d%d",a+i,b+i);
    ll ans=0;
    For(i,1,n)ans+=b[i]-a[i];
    For(i,1,n)p[i]=i;
    sort(p+1,p+n+1,[&](int x,int y){return b[x]>b[y];});
    int t=n,mina=a[p[1]];
    For(i,1,n)
    {
        // printf("%d(%d,%d)\n",p[i],a[p[i]],b[p[i]]);
        if(b[p[i]]<=f)
        {
            t=i-1;
            break;
        }
        if(b[p[i]]<mina)ans+=mina-b[p[i]];
        if(a[p[i]]<mina)mina=a[p[i]];
    }
    if(mina>f)ans+=mina-f;
    reverse(p+1,p+t+1);
    printf("%lld\n",ans);
    For(i,1,n)printf("%d ",p[i]); wln;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)Main();
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3880kb

input:

2
4 2
3 6
1 3
2 7
5 6
2 5
2 4
6 8

output:

11
2 4 1 3 
5
2 1 

result:

wrong answer Participant declares the cost to be 11, but the plan actually costs 13 (test case 1)