Submission #518095

# Submission time Handle Problem Language Result Execution time Memory
518095 2022-01-23T08:36:57 Z Ronin13 Table Tennis (info1cup20_tabletennis) C++14
87 / 100
3000 ms 4552 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++;
                else{
                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 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 308 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 748 KB Output is correct
2 Correct 105 ms 3040 KB Output is correct
3 Correct 126 ms 4408 KB Output is correct
4 Correct 100 ms 4408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 3012 KB Output is correct
2 Correct 78 ms 4536 KB Output is correct
3 Correct 122 ms 4524 KB Output is correct
4 Correct 76 ms 4408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 3 ms 304 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 372 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 299 ms 4488 KB Output is correct
3 Correct 82 ms 4412 KB Output is correct
4 Correct 122 ms 4412 KB Output is correct
5 Correct 102 ms 4436 KB Output is correct
6 Correct 126 ms 4552 KB Output is correct
7 Correct 123 ms 4444 KB Output is correct
8 Correct 87 ms 4392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Execution timed out 3073 ms 2252 KB Time limit exceeded
3 Halted 0 ms 0 KB -