Submission #377636

# Submission time Handle Problem Language Result Execution time Memory
377636 2021-03-14T14:15:55 Z wildturtle Table Tennis (info1cup20_tabletennis) C++14
35 / 100
737 ms 38252 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,cnt,A[500005];
map <long long,long long> mp,mp1;
vector <long long> v;
set <long long> st;
set <long long>::iterator it;
long long check(long long sum) {
    for(long long i=1;i<=n;i++) mp1[A[i]]++;
    cnt=0; v.clear();
    for(long long i=1;i<=n;i++) {
        if(mp1[A[i]]==0) continue;
        mp1[A[i]]--;
        if(mp1[sum-A[i]]>=1) {
            cnt++; mp1[sum-A[i]]=0; 
            v.push_back(A[i]);
            v.push_back(sum-A[i]);
            if(cnt==(n-k)/2) break;
        }
    }
    mp1.clear();
    if(cnt>=(n-k)/2) return 1;
    else return 0;
}
int main() {
    cin>>n>>k;
    n+=k;
    for(long long i=1;i<=n;i++) {
        cin>>A[i];
    }
    sort(A+1,A+1+n);
    if(n>=4*k) {
        for(long long i=1;i<=2*k;i++) {
            for(long long j=n-2*k+1;j<=n;j++) {
                mp[A[i]+A[j]]++;
            }
        }
        for(long long i=1;i<=2*k;i++) {
            for(long long j=n-2*k+1;j<=n;j++) {
                if(mp[A[i]+A[j]]>=k*k) st.insert(A[i]+A[j]);
            }
        }
        for(it=st.begin();it!=st.end();it++) {
            if(check(*it)) break;
        }
        sort(v.begin(),v.end());
        for(long long i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    }
    else {
        for(long long i=1;i<=n;i++) {
            for(long long j=i+1;j<=n;j++) {
                if(check(A[i]+A[j])) { l=1; break; }
            }
            if(l==1) break;
        }
        sort(v.begin(),v.end());
        for(long long i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    }
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:47:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(long long i=0;i<v.size();i++)
      |                           ~^~~~~~~~~
tabletennis.cpp:58:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for(long long i=0;i<v.size();i++)
      |                           ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 620 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2156 KB Output is correct
2 Correct 370 ms 21788 KB Output is correct
3 Correct 164 ms 13660 KB Output is correct
4 Correct 168 ms 13788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 1516 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 711 ms 400 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 409 ms 400 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 2 ms 364 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 68 ms 1644 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB Output is correct
2 Incorrect 737 ms 38252 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -