답안 #518356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518356 2022-01-23T14:09:01 Z Ronin13 Table Tennis (info1cup20_tabletennis) C++14
34 / 100
117 ms 10380 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define epb emplace_back
#define inf 1e9+1
#define linf 1e18+11
using namespace std;

map<ll,int>used;
int main(){
    int n;cin>>n;
    int k;cin>>k;
    n+=k;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>vec;
    if(n>=2*k){
        for(int i=1;i<=k+1;i++){
            for(int j=n;j>=n-k;j--){
                int x=a[i]+a[j];
                used[x]++;
                if(used[x]==k/2||used[x]==k/2+1)vec.pb(x);
            }
        }
    }
    else{
        for(int i=1;i<=k+1;i++){
            for(int j=n;j>=n-k;j--){
                int x=a[i]+a[j];
                vec.pb(x);
            }
        }
    }
    for(int to:vec){
        int l=1,r=n;
        vector<int>ans;
        while(l<r){
            if(ans.size()==(n-k))break;
            if(a[l]+a[r]==to){
                ans.pb(a[l]);
                ans.pb(a[r]);
                l++;
                r--;
                continue;
            }
            if(a[l]+a[r]>to){
                r--;
                continue;
            }
            l++;
        }
        if(ans.size()==(n-k)){
            sort(ans.begin(),ans.end());
            for(int x:ans)cout<<x<<' ';
            return 0;
        }
        ans.clear();
    }
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:43:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |             if(ans.size()==(n-k))break;
      |                ~~~~~~~~~~^~~~~~~
tabletennis.cpp:57:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |         if(ans.size()==(n-k)){
      |            ~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 744 KB Output is correct
2 Correct 73 ms 3012 KB Output is correct
3 Correct 74 ms 3028 KB Output is correct
4 Correct 72 ms 3032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 2972 KB Output is correct
2 Correct 78 ms 2992 KB Output is correct
3 Correct 84 ms 3020 KB Output is correct
4 Correct 77 ms 3036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 2 ms 844 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 54 ms 864 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Incorrect 117 ms 10380 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -