QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#760932 | #9730. Elevator II | ygking | WA | 137ms | 5836kb | C++14 | 1.5kb | 2024-11-18 20:15:13 | 2024-11-18 20:15:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define long long int
const int N=1e5+10;
struct stu{
int l,r,place;
}a[N],b[N],c[N];
bool fun[N];
bool cmp1(stu a,stu b)
{
if(a.l!=b.l)
return a.l>b.l;
return a.r>b.r;
}
bool cmp2(stu a,stu b)
{
if(a.l!=b.l)
return a.l<b.l;
return a.r<b.r;
}
int main(){
int T;
cin >> T;
while(T--)
{
memset(fun,true,sizeof fun);
int n,f;
cin >> n >> f;
int x,y,maxx1=0,maxx=0,ans=0,temp=0,t=0,g1=0,g2=0;
map<int,int>mp;
for(int i=1;i<=n;i++)
{
cin >> x >> y ;
c[i].l=x,c[i].r=y,c[i].place=i;
ans += (y-x);
maxx = max(maxx,x);//最高点
if(f>=x)
{
a[++g1].l = x,a[g1].r = y,a[g1].place=i;
if(maxx1<y)
maxx1 = y,temp = i;
//起始能到达的最高点
}
else
{
b[++g2].l = x,b[g2].r = y,b[g2].place=i;
}
}
if(f<maxx1)
f = maxx1 , mp[++t] = temp,fun[temp]=false;
//能走的最高点
sort(b+1,b+1+g2,cmp2);
for(int i=1;i<=g2;i++)
{
if(f>=maxx) break;
if(b[i].r>f)
{
if(b[i].l>f)
ans += (b[i].l-f);
f = b[i].r;
mp[++t] = b[i].place;
fun[b[i].place] = false;
}
}
cout << ans << endl;
sort(c+1,c+1+n,cmp1);
for(auto nums : mp)
{
cout << nums.second << ' ';
}
for(int i=1;i<=n;i++)
{
if(fun[c[i].place])
cout << c[i].place << ' ';
}
cout << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5748kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 3 4 1 2 5 2 1
result:
ok ok 2 cases (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 137ms
memory: 5836kb
input:
6100 19 52 51 98 2 83 40 58 96 99 39 55 72 94 15 17 4 15 48 99 2 99 77 78 35 77 44 62 79 81 30 31 1 48 48 76 68 99 60 66 6 19 44 53 64 92 17 28 67 98 9 99 40 65 16 27 99 100 15 56 4 6 24 97 84 96 47 49 37 38 77 79 13 40 13 92 71 100 47 93 90 91 72 81 15 48 32 71 19 17 95 99 10 23 18 100 90 93 52 92 ...
output:
524 9 4 14 11 6 18 19 1 17 13 3 5 12 15 7 8 10 2 16 194 5 4 2 1 6 3 397 4 11 1 13 5 8 14 12 6 7 16 2 15 10 9 3 733 7 11 3 1 4 17 8 16 5 12 10 19 13 14 6 18 15 9 2 244 3 10 14 5 6 8 12 2 4 11 1 15 9 13 7 422 18 11 10 6 7 2 13 4 20 8 5 9 15 16 14 1 19 3 12 17 104 4 1 3 2 187 4 8 2 3 1 5 6 9 10 ...
result:
wrong answer Integer parameter [name=cost] equals to -1276911647, violates the range [0, 10^18] (test case 1003)