QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#801346 | #9730. Elevator II | Proaes | WA | 1ms | 3884kb | C++11 | 816b | 2024-12-06 21:33:26 | 2024-12-06 21:33:27 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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)