Submission #717366

# Submission time Handle Problem Language Result Execution time Memory
717366 2023-04-01T21:43:16 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
0 / 100
8 ms 4820 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=1e7;
const int off=(1<<20);
const int MOD = 1e9+7;


int mp[N];
signed main(){
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,k;
   cin >> n >> k;
   int sz=n+k;
   int a[sz];
   for(int i=0;i<sz;i++){
      cin >>a[i];
      mp[a[i]]++;
   }
   sort(a,a+sz);

   vector<int>v;
   for(int i=0;i<=k;i++){
      for(int j=0;j<=k-i;j++){
         v.pb(a[i]+a[sz-j-1]);
         // cout<<v.back()<<' ';
      }
   }
   // cout<<v.size()<<endl;
   int h[v.size()]={0};

   for(int i=0;i<sz;i++){
      for(int j=0;j<v.size();j++){
         if(a[i]!=v[j]-a[i]){
            if(v[j]-a[i]>0&&!mp[v[j]-a[i]]){
               if(h[j]<k&&h[j]>=0)h[j]++;
               else h[j]=-1;
            }
         }
         else{
            if(h[j]<k&&h[j]>=0)h[j]++;
            else h[j]=-1;
         }
      }
   }
   int ans;
   for(int i=0;i<v.size();i++){
      if(h[i]>-1)ans=v[i];

   }
   for(int i=0;i<sz;i++){
      if(ans-a[i]>=0&&mp[ans-a[i]])cout<<a[i]<<' ';
   }

}
/*

*/

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:38:20: 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]
   38 |       for(int j=0;j<v.size();j++){
      |                   ~^~~~~~~~~
tabletennis.cpp:52:17: 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]
   52 |    for(int i=0;i<v.size();i++){
      |                ~^~~~~~~~~
tabletennis.cpp:57:13: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |       if(ans-a[i]>=0&&mp[ans-a[i]])cout<<a[i]<<' ';
      |          ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 4820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 2844 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 392 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -