이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define endl '\n'
#define modulo 998244353
#define int long long
#define PI acos(-1)
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#define sinDegrees(x) sin((x) * PI / 180.0)
#define cosDegrees(x) cos((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
#define asinDegrees(x) asin(x)* 180.0 / PI
#define EPS 0.000000001
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x,int m=modulo)
{
return (power(x,m-2,m))%m;
}
///IOI 2021 isA
int arr[150401],n,k;
vector<int>ANS;
bool TP(int L,int R,int X,int REM){
int F=L,S=R;
ANS.clear();
//cout<<L<<' '<<R<<' '<<X<<' '<<REM<<endl;
while((S-F+1)>REM){
//if(L==1&&R==2)
//cout<<F<<' '<<S<<' '<<REM<<endl;
if(arr[F]+arr[S]==X){
ANS.push_back(arr[F]),ANS.push_back(arr[S]);
F++,S--;
}
else if(arr[F]+arr[S]>X&&REM>0){
S--,REM--;
}
else if(REM>0){
F++,REM--;
}
else
return 0;
}
return 1;
}
int32_t main()
{
//freopen("output.txt","w",stdout);
//freopen("sorting.in","r",stdin);
cin.tie(0),iostream::sync_with_stdio(0);
cin>>n>>k;
for(int i=0;i<n+k;i++)
cin>>arr[i];
for(int i=0;i<n+k;i++){
for(int l=n+k-1;l>=n-1+i;l--){
if(TP(i+1,l-1,arr[i]+arr[l],k-((n+k-1)-l+i))){
ANS.push_back(arr[i]),ANS.push_back(arr[l]);
sort(ANS.begin(),ANS.end());
for(int i=0;i<n;i++)
cout<<ANS[i]<<' ';
exit(0);
}
}
}
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... |