AtCoder Grand Contest 019

Submission #1541090

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef pair<int, int>pii; typedef pair<long, long>pll; typedef pair<string, int>psi;
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<long long>vll; typedef vector<pair<int,int> > vii;
typedef set<int> si; typedef set<string> ss; typedef set<bool> sb; typedef set<long long>sll; typedef set<pair<int, int> > sii;
typedef list<int> li; typedef list<string> ls; typedef list<bool> lb; typedef list<long long>lll; typedef list<pair<int, int> > lii;
typedef map<string, int> msi;
void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); }

int main() {
	fastIO();
	vector<pii>v;
	ll a1, a2, a3, a4, s;
	ll sum;
	std::cin >> a1 >> a2 >> a3 >> a4 >> s;
	v.push_back(make_pair(a1 ,1));
	v.push_back(make_pair(a2 ,2));
	v.push_back(make_pair(a3 ,4));
	v.push_back(make_pair(a4,8));
	sort(v.begin(), v.end(), [](pii x1, pii x2) {return (float)x1.first/x1.second < (float)x2.first/ x2.second; });


	s *= 4;
	sum = s / v[0].second *v[0].first;
	ll rst = s - s/ v[0].second *v[0].second;
	
	if(rst>0)
	{	
		sum+= rst / v[1].second *v[1].first;
	    rst = s - s / v[1].second *v[1].second;
		if (rst > 0)
		{
			sum += rst / v[2].second *v[2].first;
			rst = s - s / v[2].second *v[2].second;
			if (rst>0)
			{
				sum += rst / v[3].second *v[3].first;
				std::cout << sum;
			}
			else std::cout << sum;
		}
		else std::cout << sum;
	}
	else std::cout <<sum;



	




}

Submission

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