Submission #424453

# Submission time Handle Problem Language Result Execution time Memory
424453 2021-06-12T00:51:33 Z jamezzz Table Tennis (info1cup20_tabletennis) C++17
0 / 100
51 ms 4548 KB
#include <bits/stdc++.h>
using namespace std;

#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()

int n,k,v;
vector<int> s,ans;
map<int,int> cnt;

int main(){
	sf("%d%d",&n,&k);
	n+=k;
	for(int i=0;i<n;++i){
		sf("%d",&v);
		s.push_back(v);
	}
	sort(all(s));
	for(int i=0;i<min(2*k,n);++i){
		for(int j=max(0,n-2*k);j<n;++j){
			if(i==j)continue;
			cnt[s[i]+s[j]]+=1;
		}
	}
	int res=0;
	for(auto it:cnt){
		if(it.se>=k){
			res=it.fi;break;
		}
	}
	int cr=n-1;
	for(int i=0;i<n;++i){
		if(s[i]>=res-s[i])break;
		while(res-s[i]<s[cr])--cr;
		if(res-s[i]==s[cr]){
			ans.pb(s[i]);
			ans.pb(res-s[i]);
			--cr;
		}
		if(ans.size()==n-k)break;
	}
	sort(all(ans));
	for(int x:ans)pf("%d ",x);
	pf("\n");
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:44:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |   if(ans.size()==n-k)break;
      |      ~~~~~~~~~~^~~~~
tabletennis.cpp:16:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  sf("%d%d",&n,&k);
      |    ^
tabletennis.cpp:19:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   sf("%d",&v);
      |     ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 716 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 1724 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 716 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 4548 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -