Submission #311157

# Submission time Handle Problem Language Result Execution time Memory
311157 2020-10-09T14:25:12 Z GioChkhaidze Table Tennis (info1cup20_tabletennis) C++14
25 / 100
357 ms 18792 KB
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define F first
#define S second
 
using namespace std;
 
const int N=2e5+5;

int n,k;
bool f[N];
double a[N];
vector < int > ans;
map < int , int > mp;
unordered_map < int , int > F;

void check(int x) {
  ans.clear();
  int r=n+k;
  
  F.clear();
  for (int i=1; i<=n+k; i++) F[a[i]]++;
  
  for (int i=1; i<=n; i++) {
    if (!F[a[i]]) continue;
    if (!F[x-a[i]]) continue;
    F[a[i]]--,F[x-a[i]]--;
    ans.pb(a[i]),ans.pb(x-a[i]);
    if (ans.size()==n) break;
  }
  
  if (ans.size()==n) {
    sort(ans.begin(),ans.end());
    for (int i=0; i<ans.size(); i++)
      cout<<ans[i]<<" ";
    exit(0);
  }
}

main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL),cout.tie(NULL);
  
  cin>>n>>k;
  for (int i=1; i<=n+k; i++) 
    cin>>a[i];

  int R=min(2*k,n+k),L=max(1,n-k+1);
  for (int i=1; i<=R; i++) 
    for (int j=L; j<=n+k; j++) 
      mp[a[i]+a[j]]++;
  
  for (map < int , int > :: iterator it=mp.begin(); it!=mp.end(); ++it) 
    if ((it->second)>=k) check((it->first));
}

Compilation message

tabletennis.cpp: In function 'void check(int)':
tabletennis.cpp:31:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if (ans.size()==n) break;
      |         ~~~~~~~~~~^~~
tabletennis.cpp:34:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   if (ans.size()==n) {
      |       ~~~~~~~~~~^~~
tabletennis.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i=0; i<ans.size(); i++)
      |                   ~^~~~~~~~~~~
tabletennis.cpp:21:7: warning: unused variable 'r' [-Wunused-variable]
   21 |   int r=n+k;
      |       ^
tabletennis.cpp: At global scope:
tabletennis.cpp:42:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main() {
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1920 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 209 ms 15244 KB Output is correct
2 Correct 128 ms 12860 KB Output is correct
3 Correct 357 ms 18792 KB Output is correct
4 Correct 134 ms 12864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 768 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 4728 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -