QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801346#9730. Elevator IIProaesWA 1ms3884kbC++11816b2024-12-06 21:33:262024-12-06 21:33:27

Judging History

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

  • [2024-12-06 21:33:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2024-12-06 21:33:26]
  • 提交

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);
    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;
    For(i,1,n)
        if(b[p[i]]<=f)
        {
            t=i-1;
            break;
        }
    sort(p+1,p+n+1,[&](int x,int y){return a[x]<a[y];});
    ll ans=0;
    For(i,1,n)ans+=b[i]-a[i];
    b[0]=f;
    For(i,1,n)ans+=max(a[p[i]]-b[p[i-1]],0);
    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: 1ms
memory: 3884kb

input:

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

output:

11
2 3 1 4 
6
1 2 

result:

wrong answer Participant's cost is 6, which is worse than jury's cost 5 (test case 2)