QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#427500 | #8768. Arrested Development | ucup-team055# | WA | 1ms | 3856kb | C++20 | 1.7kb | 2024-06-01 13:32:30 | 2024-06-01 13:32:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
using ll = long long;
using ld = long double;
const ll INF = (1ll<<61) - 1;
#define all(p) p.begin(),p.end()
template<class T> bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
int main(){
int N;
cin>>N;
vector<int> A(N),B(N);
rep(i,0,N) cin>>A[i]>>B[i];
if(N==1){
cout<<min(A[0],B[0])<<"\n";
}
auto f=[&](auto self,int l,int r,vector<pair<int,int>> &v) -> void {
if(l==r) return;
vector<pair<int,int>> n_v;
int inda=0,indb=0;
while(inda!=v.size()){
if(indb==v.size()||v[inda].first+A[l]<v[indb].first){
n_v.push_back({v[inda].first+A[l],v[inda].second});
inda++;
}
else{
n_v.push_back({v[indb].first,v[indb].second+B[l]});
indb++;
}
}
swap(n_v,v);
self(self,l+1,r,v);
};
vector<pair<int,int>> X={{0,0}},Y={{0,0}};
f(f,0,N/2,X);
f(f,N/2,N,Y);
rep(i,1,X.size()) chmin(X[i].second,X[i-1].second);
rep(i,1,Y.size()) chmin(Y[i].second,Y[i-1].second);
reverse(all(X));
int indX=0,indY=0;
int ans=max(X[0].first+Y[0].first,X[0].second+Y[0].second);
while(indX+1!=X.size()&&indY+1!=Y.size()){
if(indX+1==X.size()) indY++;
else if(indY+1==Y.size()) indX++;
else if(X[indX].first+Y[indY].first<X[indX].second+Y[indY].second){
indY++;
}
else indX++;
chmin(ans,max(X[indX].first+Y[indY].first,X[indX].second+Y[indY].second));
}
cout<<ans<<"\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
4 100 1 1 90 1 20 1 20
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3796kb
input:
2 314 1 592 6
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3856kb
input:
1 1 1
output:
1 1
result:
wrong output format Extra information in the output file