QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#135923#2299. Heating UpmojospyWA 1ms3432kbC++141.4kb2023-08-06 15:43:592023-08-06 15:44:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-06 15:44:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3432kb
  • [2023-08-06 15:43:59]
  • 提交

answer

#include<iostream>
#include<functional>
#include<queue>
#include<unordered_set>
using namespace std;
const int N=5e5+3;
typedef long long int ll;
ll a[N];
int n;

class cmp{
	public:
		bool operator()(const int i,const int j)const{
			return	a[i]>a[j];
		}
};

int deal(int id){
	if(id==n) return 0;
	else if(id<0) return n-1;
	else return id;
}

bool isvaild(ll num){
	for(int i=0;i<n;++i){
		if(num>=a[i]){
			priority_queue<int,vector<int>,cmp> q;
			unordered_set<int> s;
			s.insert(i);
			//s.insert(deal(i+1));
			//s.insert(deal(i-1));
			s.insert(deal(i+1));
			s.insert(deal(i-1));
			q.push(deal(i+1));
			q.push(deal(i-1));
			num+=a[i];
			bool flag=true;
			while(!q.empty()){
				if(num<a[q.top()]){
					flag=false;
					break;
				}
				int cur=q.top();
				q.pop();
				num+=a[cur];
				s.insert(cur);
				if(s.find(deal(cur+1))==s.end()){
					s.insert(deal(cur+1));
					q.push(deal(cur+1));
				}
				if(s.find(deal(cur-1))==s.end()){
					s.insert(deal(cur-1));
					q.push(deal(cur-1));
				}
			}
			//cout<<endl; 
			if(flag) return true;
		}
	}
	return false;
}

int main(){
	ll l=1e13+5,r=-1;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		l=min(l,a[i]);
		r=max(r,a[i]);
	}
	if(a[0]=269655) cout<<isvaild(3)<<endl;
	while(l<=r){
		ll mid=(r+l)/2;
		if(isvaild(mid)){
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	cout<<l;
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3432kb

input:

4
10 20 15 1

output:

0
21

result:

wrong answer 1st lines differ - expected: '9', found: '0'