Submission #518063

# Submission time Handle Problem Language Result Execution time Memory
518063 2022-01-23T08:29:57 Z Ronin13 Table Tennis (info1cup20_tabletennis) C++14
0 / 100
3000 ms 2244 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;

unordered_map<int,int>used;

int main(){
    int n;cin>>n;
    int k;cin>>k;
    int a[n+k+1];
    for(int i=1;i<=n+k;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n+k);
    vector<int>vec;
    bool ind=false;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k-i;j++){
            int l=i+2,r=n+k-j-1;
            int ss=a[i+1]+a[n+k-j];
            int cnt=0;
            vec.clear();
            vec.pb(i+1),vec.pb(n+k-j);
            while(l<r){
                if(a[l]+a[r]==ss)vec.pb(l),vec.pb(r),r--,l++;
                if(a[l]+a[r]<ss)l++,cnt++;
                else if(a[l]+a[r]<ss)r--,cnt++;
            }
            if(cnt+i+j<=k){
                sort(vec.begin(),vec.end());
                for(int p=0;p<n;p++)cout<<a[vec[p]]<<' ';
                return 0;
            }
        }
    }
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:25:10: warning: unused variable 'ind' [-Wunused-variable]
   25 |     bool ind=false;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 952 KB Output is correct
2 Execution timed out 3068 ms 2244 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 2244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3044 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3076 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3087 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3068 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -