답안 #677204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677204 2023-01-02T14:35:05 Z ajab_01 Tug of War (BOI15_tug) C++17
18 / 100
787 ms 800 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 3e4 + 4;
int l[N] , r[N] , p[N] , n , k;
bool ch;

bool check(int mask){
	bool vis[N];
	memset(vis , 0 , sizeof(vis));
	int sum1 = 0 , sum2 = 0;
	for(int i = 0 ; i < 2 * n ; i++){
		if(mask & (1 << i)){
			if(vis[r[i]])
				return 0;
			vis[r[i]] = 1;
			sum1 += p[i];
		}
		else{
			if(vis[l[i]])
				return 0;
			vis[l[i]] = 1;
			sum2 += p[i];
		}
	}

	return abs(sum1 - sum2) <= k;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for(int i = 0 ; i < 2 * n ; i++){
		cin >> l[i] >> r[i] >> p[i];
		r[i] += n;
	}

	for(int mask = 0 ; mask < (1 << 2 * n) ; mask++)
		if(check(mask))
			ch = 1;

	if(ch)
		cout << "YES" << '\n';
	else
		cout << "NO" << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 706 ms 340 KB Output is correct
2 Correct 746 ms 340 KB Output is correct
3 Correct 713 ms 340 KB Output is correct
4 Correct 720 ms 344 KB Output is correct
5 Correct 711 ms 340 KB Output is correct
6 Correct 697 ms 340 KB Output is correct
7 Correct 707 ms 340 KB Output is correct
8 Correct 734 ms 340 KB Output is correct
9 Correct 765 ms 340 KB Output is correct
10 Correct 712 ms 340 KB Output is correct
11 Correct 737 ms 460 KB Output is correct
12 Correct 709 ms 344 KB Output is correct
13 Correct 747 ms 340 KB Output is correct
14 Correct 710 ms 344 KB Output is correct
15 Correct 728 ms 344 KB Output is correct
16 Correct 739 ms 340 KB Output is correct
17 Correct 723 ms 340 KB Output is correct
18 Correct 720 ms 340 KB Output is correct
19 Correct 689 ms 340 KB Output is correct
20 Correct 716 ms 340 KB Output is correct
21 Correct 718 ms 340 KB Output is correct
22 Correct 787 ms 344 KB Output is correct
23 Correct 724 ms 340 KB Output is correct
24 Correct 763 ms 348 KB Output is correct
25 Correct 718 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 706 ms 340 KB Output is correct
2 Correct 746 ms 340 KB Output is correct
3 Correct 713 ms 340 KB Output is correct
4 Correct 720 ms 344 KB Output is correct
5 Correct 711 ms 340 KB Output is correct
6 Correct 697 ms 340 KB Output is correct
7 Correct 707 ms 340 KB Output is correct
8 Correct 734 ms 340 KB Output is correct
9 Correct 765 ms 340 KB Output is correct
10 Correct 712 ms 340 KB Output is correct
11 Correct 737 ms 460 KB Output is correct
12 Correct 709 ms 344 KB Output is correct
13 Correct 747 ms 340 KB Output is correct
14 Correct 710 ms 344 KB Output is correct
15 Correct 728 ms 344 KB Output is correct
16 Correct 739 ms 340 KB Output is correct
17 Correct 723 ms 340 KB Output is correct
18 Correct 720 ms 340 KB Output is correct
19 Correct 689 ms 340 KB Output is correct
20 Correct 716 ms 340 KB Output is correct
21 Correct 718 ms 340 KB Output is correct
22 Correct 787 ms 344 KB Output is correct
23 Correct 724 ms 340 KB Output is correct
24 Correct 763 ms 348 KB Output is correct
25 Correct 718 ms 348 KB Output is correct
26 Incorrect 1 ms 340 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 706 ms 340 KB Output is correct
2 Correct 746 ms 340 KB Output is correct
3 Correct 713 ms 340 KB Output is correct
4 Correct 720 ms 344 KB Output is correct
5 Correct 711 ms 340 KB Output is correct
6 Correct 697 ms 340 KB Output is correct
7 Correct 707 ms 340 KB Output is correct
8 Correct 734 ms 340 KB Output is correct
9 Correct 765 ms 340 KB Output is correct
10 Correct 712 ms 340 KB Output is correct
11 Correct 737 ms 460 KB Output is correct
12 Correct 709 ms 344 KB Output is correct
13 Correct 747 ms 340 KB Output is correct
14 Correct 710 ms 344 KB Output is correct
15 Correct 728 ms 344 KB Output is correct
16 Correct 739 ms 340 KB Output is correct
17 Correct 723 ms 340 KB Output is correct
18 Correct 720 ms 340 KB Output is correct
19 Correct 689 ms 340 KB Output is correct
20 Correct 716 ms 340 KB Output is correct
21 Correct 718 ms 340 KB Output is correct
22 Correct 787 ms 344 KB Output is correct
23 Correct 724 ms 340 KB Output is correct
24 Correct 763 ms 348 KB Output is correct
25 Correct 718 ms 348 KB Output is correct
26 Incorrect 1 ms 340 KB Output isn't correct
27 Halted 0 ms 0 KB -