求思路反驳或hack
查看原帖
求思路反驳或hack
1173402
yfhshtk楼主2023/10/29 19:45

这个代码可以过样例,讨论区的其他hack也没问题,但交上去报零,求思路反驳或hack(回复请 @ 我)


#include<bits/stdc++.h>
using namespace std;
int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			w=(~w)+1;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		s=(s<<3)+(s<<1)+(ch&15);
		ch=getchar();
	}
	return s*w;
}
void write(int x){
	if(x<0){
		putchar('-');
		x=(~x)+1;
	}
	if(x>9){
		write(x/10);
	}
	putchar(x%10|48);
}
int s[5],min_time;
priority_queue<int>q[5];
int work(int k){
	int res=0,lst=0;
	while(!q[k].empty()){
		if(q[k].size()>=2){
			int a=q[k].top();
			q[k].pop();
			int b=q[k].top();
			q[k].pop();
			res+=a-lst;
			lst=a-b;
		}
		else if(q[k].size()==1){
			res+=q[k].top()-lst;
			q[k].pop();
		}
	}
	return res;
}
int main(){
	std::ios::sync_with_stdio(false);
	for(int i=1;i<=4;i++){
		s[i]=read();
	}
	for(int i=1;i<=4;i++){
		for(int j=1;j<=s[i];j++){
			int tmp;
			tmp=read();
			q[i].push(tmp);
		}
	}
	for(int i=1;i<=4;i++){
		min_time+=work(i);
	}
	cout<<min_time;
	return 0;
}
2023/10/29 19:45
加载中...