QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#751952 | #9730. Elevator II | Proaes# | WA | 0ms | 3504kb | C++20 | 1.0kb | 2024-11-15 21:23:38 | 2024-11-15 21:23:38 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
struct pp{
int l,r,in;
};
int t,n,f;
bool cmp1(pp x,pp y){
if (x.l==y.l) return x.r>y.r;
else return x.l<y.l;
}
bool cmp2(pp x,pp y){
if (x.r==y.r) return x.l<y.l;
else return x.r<y.r;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin>>t;
while (t--){
cin>>n>>f;
vector<int> ins(n);
vector<pp> ans(n);
int sumn=0;
for (int i=0;i<n;i++){
cin>>ans[i].l>>ans[i].r;
sumn+=ans[i].r-ans[i].l;
ans[i].in=i;
}
sort(ans.begin(),ans.end(),cmp1);
int maxn=f;
int top=0;
for (int i=0;i<n;i++){
if (ans[i].r>maxn){
sumn+=max(ans[i].l-maxn,0ll);
maxn=ans[i].r;
ins[ans[i].in]=++top;
}
}
sort(ans.begin(),ans.end(),cmp2);
for (int i=n-1;i>=0;i--){
if (!ins[ans[i].in]){
ins[ans[i].in]=++top;
}
}
cout<<sumn<<endl;
for (int i=0;i<n;i++){
cout<<ins[i]<<" ";
}
cout<<endl;
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3504kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 4 1 2 3 5 2 1
result:
wrong answer Participant declares the cost to be 11, but the plan actually costs 14 (test case 1)