QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135918 | #2299. Heating Up | mojospy | WA | 1ms | 3408kb | C++14 | 1.5kb | 2023-08-06 15:38:55 | 2023-08-06 15:38:57 |
Judging History
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;
cout<<a[i]<<" ";
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();
if(a[0]=269655&&num==3) cout<<a[cur]<<" ";
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<<l<<" "<<r<<endl;
while(l<=r){
ll mid=(r+l)/2;
if(isvaild(mid)){
r=mid-1;
}else{
l=mid+1;
}
}
cout<<l;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3408kb
input:
4 10 20 15 1
output:
1 20 1 15 0 1 0 1 13
result:
wrong answer 1st lines differ - expected: '9', found: '1 20'