QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751975#9730. Elevator IIProaes#WA 0ms3628kbC++20994b2024-11-15 21:27:502024-11-15 21:27:51

Judging History

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

  • [2024-11-15 21:27:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-11-15 21:27:50]
  • 提交

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;
			}
		}
		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: 3628kb

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)