이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//####################
//Binome_Equilibres
//####################
#include<bits/stdc++.h>
using namespace std;
int n,k;
vector<int> nums;
bool possible(int start,int end,int K){
int target = nums[start]+nums[end];
vector<int> S,E;
S.push_back(nums[start]);
E.push_back(nums[end]);
start++;
end--;
while(start<end && K>=0){
int sum = nums[start]+nums[end];
if(sum>target){
K--;
end--;
}else if(sum<target){
K--;
start++;
}else{
S.push_back(nums[start]);
E.push_back(nums[end]);
start++;
end--;
}
}
if(K<0)return false;
while(n!=(int(S.size()+E.size()))){
S.erase(S.begin());
E.erase(E.begin());
}
for(int v:S)cout<<v<<' ';
reverse(E.begin(),E.end());
for(int v:E)cout<<v<<' ';
cout<<'\n';
return true;
}
signed main(){
cin>>n>>k;
nums.resize(n+k);
for(int i=0;i<n+k;i++){
cin>>nums[i];
}
for(int i=0;i<=k;i++){
int taked = i;
for(int j=n+k-1;j>=0 && taked<=k;j--){
if(possible(i,j,k-taked)){
return 0;
}
taked++;
}
}
return 0;
};
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |