Submission #1488047


Source Code Expand

#include<bits/stdc++.h>

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

const int dx[4] = {0,  0, 1, -1};
const int dy[4] = {1, -1, 0,  0};
const int N = 1e5 + 7;
int a[N];
int n;
int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	forn(i,n){
		int x;
		cin >> x;
		while(x % 2 == 0){
			a[i]++;
			x = x / 2;
		}
	}
	sort(a, a + n);
	
	int l = 0;
	int r = n - 1;
	vector<int> v;
	while(l <= r) {
		v.push_back(a[l]);
		if (r != l)
			v.push_back(a[r]);
		r--;
		l++;
	}
	
	
	for(int i = 0; i < v.size() - 1; i++){
		if ((v[i] + v[i + 1]) < 2){
			cout << "No\n";
			return 0;
		}
	}
	
	cout << "Yes\n";
	return 0;
}

Submission Info

Submission Time
Task C - 4-adjacent
User emli
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1376 Byte
Status AC
Exec Time 15 ms
Memory 1276 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 5
AC × 19
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
0_04.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 1 ms 256 KB
1_07.txt AC 13 ms 1276 KB
1_08.txt AC 13 ms 1276 KB
1_09.txt AC 15 ms 1276 KB
1_10.txt AC 15 ms 1276 KB
1_11.txt AC 15 ms 1276 KB
1_12.txt AC 15 ms 1276 KB
1_13.txt AC 15 ms 1276 KB