AtCoder Grand Contest 019

Submission #1540307

Source codeソースコード

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

//#define READ_FROM_FILE

int main() {
	ios::sync_with_stdio(false);
	#ifdef READ_FROM_FILE
    freopen("input.in","r",stdin);
 	freopen("output.out","w",stdout);
	#endif

	vector<ll> cost(4);
	vector<pair<ll, ll>> A(4);

	ll N;
	rep(i, 4) {
		cin>>cost[i];
		A[i] = make_pair(cost[i]*(8/pow(2, i)), i);
	}
	cin>>N;

	sort(A.begin(), A.end());

	int i = 0;
	if(A[i].second == 0) {
		cout<<4LL*N*cost[0]<<endl;
		return 0;
	}

	if(A[i].second == 1) {
		cout<<2LL*N*cost[1]<<endl;
		return 0;
	}

	if(A[i].second == 2) {
		cout<<N*cost[2]<<endl;
		return 0;
	}

	if(N%2 == 0) {
		cout<<(N/2)*cost[3]<<endl;
		return 0;
	}

	ll ans = (N/2)*cost[3];
	N = 1;

	i = 1;
	if(A[i].second == 0) {
		cout<<ans+4LL*N*cost[0]<<endl;
		return 0;
	}

	if(A[i].second == 1) {
		cout<<ans+2LL*N*cost[1]<<endl;
		return 0;
	}

	if(A[i].second == 2) {
		cout<<ans+N*cost[2]<<endl;
		return 0;
	}

	return 0;
}

Submission

Task問題 A - Ice Tea Store
User nameユーザ名 cryptomanic
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 1665 Byte
File nameファイル名
Exec time実行時間 3 ms
Memory usageメモリ使用量 384 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt
All 300 / 300 sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 3 ms 384 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 1 ms 256 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 1 ms 256 KB
subtask_1_15.txt AC 1 ms 256 KB