Submission #366194

# Submission time Handle Problem Language Result Execution time Memory
366194 2021-02-13T13:19:57 Z Ahmad_Hasan Table Tennis (info1cup20_tabletennis) C++17
0 / 100
3000 ms 428096 KB
#include <bits/stdc++.h>
#define int long long
/**
     ||||||||||       |||||     |||||    ||||||||||
    |||||||||||||     |||||     |||||  |||||
   ||||     ||||||    |||||     |||||  |||||
  |||||||||||||||||   |||||||||||||||    ||||||||||
 |||||||||||||||||||  |||||||||||||||           |||||
 |||||         |||||  |||||     |||||           |||||
 |||||         |||||  |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int>v(n+k);

    int nn=n+k;
    for(int i=0;i<nn;i++){
        cin>>v[i];
    }

    map<int,int >mp,mp2;
    vector<vector<pair<int,int> > >pos(150000);
    int cr=1;
    for(int i=0;i<nn&&i<k+2;i++){
        mp2[v[i]]=i+1;
        for(int j=nn-1;j>=0&&(nn-1-j)<=k+2;j--){
            if(!mp[v[i]+v[j]])mp[v[i]+v[j]]=cr++;
        }
    }
    int mxi=0;
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
        for(int i=0;i<nn;i++){
            int vl=mp2[(it->first)-v[i]];
            if(vl>i+1){
                pos[it->second].push_back({i,vl-1});
                if(pos[it->second].size()>pos[mxi].size())
                    mxi=it->second;
            }

        }
    }
    vector<int>ans;
    for(int i=0;i<pos[mxi].size()&&i<n/2;i++){
        ans.push_back(v[pos[mxi][i].first]);
        ans.push_back(v[pos[mxi][i].second]);
    }

    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<' ';

    return 0;
}

Compilation message

tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:51:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i=0;i<pos[mxi].size()&&i<n/2;i++){
      |                 ~^~~~~~~~~~~~~~~~
tabletennis.cpp:57:18: 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]
   57 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4716 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 5228 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 107904 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 810 ms 67656 KB Output is correct
2 Incorrect 635 ms 42092 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3820 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4588 KB Output is correct
2 Incorrect 83 ms 17516 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4588 KB Output is correct
2 Execution timed out 3130 ms 428096 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 198348 KB Time limit exceeded
2 Halted 0 ms 0 KB -