답안 #342594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342594 2021-01-02T12:19:03 Z ogibogi2004 Table Tennis (info1cup20_tabletennis) C++14
38 / 100
3000 ms 2412 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=150002;
int n,k;
int a[MAXN];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n+k;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=1;i<=k&&i<=n+k;i++)
	{
		for(int j=n+k;i-1+(n+k-j)<=k;j--)
		{
			int sum=a[i]+a[j];
			int l=i,r=j,cnt=0;
			for(;;)
			{
				if(l==r||l>r)break;
				if(a[l]+a[r]==sum)
				{
					cnt++;l++;r--;
				}
				else
				{
					if(a[l]+a[r]>sum)r--;
					else l++;
				}
			}
			if(cnt>=n/2)
			{
				vector<int>v;
				l=i,r=j;
				for(;;)
				{
					//l++;r--;
					if(l==r||l>r)break;
					if(v.size()==n)break;
					if(a[l]+a[r]==sum)
					{
						v.push_back(a[l]);
						v.push_back(a[r]);
						l++;
						r--;
					}
					else
					{
						if(a[l]+a[r]>sum)r--;
						else l++;
					}
				}
				sort(v.begin(),v.end());
				for(int xd=0;xd<n;xd++)cout<<v[xd]<<" ";
				cout<<endl;
				return 0;
			}
		}
	}
return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:41:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |      if(v.size()==n)break;
      |         ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1004 KB Output is correct
2 Incorrect 67 ms 2380 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 2412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 3052 ms 2412 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 3076 ms 2412 KB Time limit exceeded
3 Halted 0 ms 0 KB -