답안 #914647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914647 2024-01-22T13:07:46 Z NValchanov Table Tennis (info1cup20_tabletennis) C++17
9 / 100
259 ms 6372 KB
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long ll;

const ll MAXN=1e5+5e4+10;
const ll MAXK=4e2+10;
const ll MAXA=1e9+10;

ll a[MAXN+MAXK],n,k,m;
vector<ll>ans;

void read()
{
    cin>>n>>k;
    m=n+k;
    for(ll i=1;i<=m;i++)
        cin>>a[i];
}

void print()
{
    sort(ans.begin(), ans.end());
    ll sz=ans.size();
    for(ll i=0;i<sz;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}

void solve()
{
    for(ll i=n/2;i<=n/2+k+1;i++)
    {
        ll cur=a[i]+a[i+1];
        ll left=1,right=n+k;
        ll cnt=0;
        while(left<right&&cnt<n/2)
        {
            ///cout<<"Lqwa granica : "<<left<<endl;
            while(left<right&&a[left]+a[right]>cur)
            {
                right--;
                ///cout<<"Dqsna granica : "<<right<<endl;
            }
            if(left<right&&a[left]+a[right]==cur)
            {
                ans.push_back(a[left]);
                ans.push_back(a[right]);
                ///cout<<"Nowo dobawqne na "<<left<<" i "<<right<<endl;
                cnt++;
            }
            left++;
        }
        if(cnt==n/2)
        {
            print();
            return;
        }
    }
}

int main()
{
    #ifdef ONLINE_JUDGE
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

    read();
    solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1500 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 5832 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output not subsequence of input
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output not subsequence of input
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 35 ms 5712 KB Output not subsequence of input
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 259 ms 6372 KB Output not subsequence of input
3 Halted 0 ms 0 KB -