답안 #365730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365730 2021-02-12T09:35:26 Z amunduzbaev Table Tennis (info1cup20_tabletennis) C++14
72 / 100
3000 ms 13932 KB
/** made by amunduzbaev **/
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vv vector
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef pair<int, pii> ipii;
typedef pair<pii, int> piii;
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
 
const int N = 2e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
 
#define MULTI 0	
 
int n, m, k, ans, res, a[N];

/*

4 2
1 2 3 4 8 20

4 2
1 2 5 7 8 100

6 2
1 3 4 5 6 7 8 11

6 2
1 2 3 5 7 8 9 15

4 2
100 200 1 2 3 4

*/

bool check(int s){
	set<int> ss;
	for(int i=0;i<m;i++) ss.insert(a[i]); 
	map<int, int> used;
	for(int i=0;i<m;i++){
		if(used.count(a[i]) || a[i] >= s) continue;
		auto x = ss.find(s - a[i]);
		if(x != ss.end() && *x != a[i]){
			used[*x] = 1, used[a[i]] = 1;
			ss.erase(x);
			ss.erase(a[i]);
		}
	}
	if(sz(used) == n){
		for(auto x:used) cout<<x.ff<<" ";
		cout<<"\n";
		return 1;
	}
	return 0;
}

void solve(int t_case){
	cin>>n>>k;
	m = n+k;
	for(int i=0;i<m;i++) cin>>a[i];
	sort(a, a+m);
	//if(check(7, 4)) { print(4, 7); return; }
	map<int, int> mm;
	for(int i=0;i<=k;i++){
		for(int j=1;j<=k-i+1;j++){
			if(mm[a[i] + a[m-j]]) continue;
			mm[a[i] + a[m-j]] = 1;
			if(check(a[i] + a[m-j])) return;
		}
	}
	
}

signed main(){
	NeedForSpeed
	if(!MULTI) {
		solve(1);
	} else {
		int t; cin>>t;
		for(int t_case = 1; t_case <= t; t_case++) solve(t_case);
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2028 KB Output is correct
2 Correct 201 ms 12524 KB Output is correct
3 Correct 168 ms 12524 KB Output is correct
4 Correct 172 ms 12580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 328 ms 12652 KB Output is correct
2 Correct 203 ms 12524 KB Output is correct
3 Correct 329 ms 12524 KB Output is correct
4 Correct 219 ms 13932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 82 ms 724 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 68 ms 620 KB Output is correct
5 Correct 2 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 54 ms 620 KB Output is correct
3 Correct 8 ms 748 KB Output is correct
4 Correct 32 ms 620 KB Output is correct
5 Correct 8 ms 620 KB Output is correct
6 Correct 25 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 3088 ms 8684 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 364 KB Output is correct
2 Execution timed out 3082 ms 8684 KB Time limit exceeded
3 Halted 0 ms 0 KB -