Submission #1001119

# Submission time Handle Problem Language Result Execution time Memory
1001119 2024-06-18T14:58:56 Z kachim2 Table Tennis (info1cup20_tabletennis) C++17
9 / 100
3000 ms 5384 KB
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <numeric>
#include <vector>
using namespace std;
vector<pair<int, int>> res; 
vector<pair<int, int>> &check_balanced(vector<int> in, int val) {
  
  res.resize(0);
  int j = in.size()-1;
  for (int i = 0; i < j; i++){
    while(in[i]+in[j]>val) j--;
    if(in[i]+in[j]==val) res.push_back({in[i], in[j]});
  }
  
  return res;

}
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> input(N+K);
  for(int i = 0; i < N+K; i++){
    cin >> input[i];
  }
  long insum = accumulate(input.begin(), input.end(), 0);
  sort(input.begin(), input.end());
  for(int i = 0; i <= K; i++){
    for(int j = 0; j + i <= K; j++){
      const int sp = N+K-j-1;
      if((N/2)*(input[i]+input[sp]) > insum) continue;
      auto a = check_balanced(input, input[i]+input[sp]);
      	if(a.size()>=N/2){
	  vector<int> out;
	  for(auto i : a){
	    out.push_back(i.first);
	    out.push_back(i.second);
	  }
	  sort(out.begin(), out.end());
	  for(int i = 0; i < N; i++){
	    cout << out[i] <<' ';
	  }
	  return 0;
	}
    }
  }
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:34:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |        if(a.size()>=N/2){
      |           ~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 860 KB Output is correct
2 Correct 56 ms 5384 KB Output is correct
3 Correct 65 ms 5240 KB Output is correct
4 Correct 69 ms 5244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 5300 KB Output is correct
2 Correct 53 ms 5128 KB Output is correct
3 Correct 51 ms 5156 KB Output is correct
4 Incorrect 36 ms 860 KB Unexpected end of file - int32 expected
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 140 ms 5184 KB Output is correct
3 Correct 55 ms 5156 KB Output is correct
4 Incorrect 46 ms 1540 KB Unexpected end of file - int32 expected
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 3059 ms 1592 KB Time limit exceeded
3 Halted 0 ms 0 KB -