Submission #2240911


Source Code Expand

#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll arr[5] = {};
ll A[5] = {};

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

int main(void)
{
	ll N, answer = 0;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		arr[A[i]]++;
	}

	for (int i = 0; i < N; i++) {

		if (arr[A[i]] == 0)
			continue;

		if (A[i] == 3 && arr[3] > 0 ) {
			if (arr[1] > 0) {
				arr[1]--;
			}
			arr[3]--;
		}
		else if (A[i] == 4 && arr[4] > 0) {
			arr[4]--;
		}
		else if (A[i] == 2 && arr[2] > 0) {
			if (arr[2] >= 2) {
				arr[2]-=2;
			}
			else if (arr[1] > 0) {
				arr[2]--;
				arr[1]--;
				if (arr[1] > 0) {
					arr[1]--;
				}
			}
			else {
				arr[2]--;
			}
		}
		else if(A[i] == 1 && arr[1] > 0){

			if (arr[3] > 0) {
				arr[1]--;
				arr[3]--;
			}
			else if (arr[2] > 0) {
				arr[1]--;
				arr[2]--;
				if (arr[1] > 0) {
					arr[1]--;
				}
			}
			else {
				arr[1] -= min(4LL,arr[1]);
			}
		}
		answer++;
	}

	cout << answer << endl;

	return 0;
}

Submission Info

Submission Time
Task C - スキーリフトの相乗り
User nasatame
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2480 Byte
Status RE
Exec Time 97 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 400
Status
AC × 16
WA × 23
RE × 10
Set Name Test Cases
All 00_sample00, 00_sample01, 100_corner0000, 100_corner0001, 100_corner0002, 100_corner0003, 10_small-0000, 10_small-0001, 10_small-0002, 10_small-0003, 10_small-0004, 10_small-0005, 10_small-0006, 10_small-0007, 10_small-0008, 10_small-0009, 20_special-0000, 20_special-0001, 20_special-0002, 20_special-0003, 20_special-0004, 20_special-0005, 20_special-0006, 20_special-0007, 20_special-0008, 20_special-0009, 20_special-0010, 20_special-0011, 20_special-0012, 20_special-0013, 20_special-0014, 30_large-0000, 30_large-0001, 30_large-0002, 30_large-0003, 30_large-0004, 30_large-0005, 30_large-0006, 30_large-0007, 30_large-0008, 30_large-0009, 80_combination-type00, 80_combination-type01, 80_combination-type02, 80_combination-type03, 80_combination-type04, 80_combination-type05, 80_combination-type06, 90_tayama-killer00
Case Name Status Exec Time Memory
00_sample00 AC 1 ms 256 KB
00_sample01 AC 1 ms 256 KB
100_corner0000 AC 1 ms 256 KB
100_corner0001 AC 1 ms 256 KB
100_corner0002 AC 1 ms 256 KB
100_corner0003 AC 1 ms 256 KB
10_small-0000 WA 1 ms 256 KB
10_small-0001 WA 1 ms 256 KB
10_small-0002 WA 1 ms 256 KB
10_small-0003 WA 1 ms 256 KB
10_small-0004 WA 1 ms 256 KB
10_small-0005 WA 1 ms 256 KB
10_small-0006 WA 1 ms 256 KB
10_small-0007 WA 1 ms 256 KB
10_small-0008 WA 1 ms 256 KB
10_small-0009 WA 1 ms 256 KB
20_special-0000 WA 1 ms 256 KB
20_special-0001 WA 1 ms 256 KB
20_special-0002 WA 1 ms 256 KB
20_special-0003 WA 1 ms 256 KB
20_special-0004 WA 1 ms 256 KB
20_special-0005 WA 1 ms 256 KB
20_special-0006 AC 1 ms 256 KB
20_special-0007 WA 1 ms 256 KB
20_special-0008 WA 1 ms 256 KB
20_special-0009 WA 1 ms 256 KB
20_special-0010 WA 1 ms 256 KB
20_special-0011 WA 1 ms 256 KB
20_special-0012 WA 1 ms 256 KB
20_special-0013 AC 1 ms 256 KB
20_special-0014 WA 1 ms 256 KB
30_large-0000 RE 96 ms 256 KB
30_large-0001 RE 95 ms 256 KB
30_large-0002 RE 96 ms 256 KB
30_large-0003 RE 95 ms 256 KB
30_large-0004 RE 96 ms 256 KB
30_large-0005 RE 96 ms 256 KB
30_large-0006 RE 97 ms 256 KB
30_large-0007 RE 97 ms 256 KB
30_large-0008 RE 96 ms 256 KB
30_large-0009 RE 97 ms 256 KB
80_combination-type00 AC 1 ms 256 KB
80_combination-type01 AC 1 ms 256 KB
80_combination-type02 AC 1 ms 256 KB
80_combination-type03 AC 1 ms 256 KB
80_combination-type04 AC 1 ms 256 KB
80_combination-type05 AC 1 ms 256 KB
80_combination-type06 AC 1 ms 256 KB
90_tayama-killer00 AC 1 ms 256 KB