QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#801342 | #9730. Elevator II | Proaes | WA | 0ms | 3880kb | C++11 | 918b | 2024-12-06 21:30:03 | 2024-12-06 21:30:04 |
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);
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();
}
Details
Tip: Click on the bar to expand more detailed information
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)