Submission #1540666


Source Code Expand

/*
 *  Author: Tara Prasad
 */
#include <bits/stdc++.h>
// #include "prettyprint.h"
using namespace std;

// #define LOGGING // May cause TLE or CE
#ifdef LOGGING
	#define LOG(x) cerr << "*** " << x << " ***" << endl;
	#define wi(x) what_is(x, '\n')
	#define wisp(x) what_is(x, ", ")
	#define what_is(x, terminator) cerr << #x << " = " << x << terminator;
#else
	#define LOG(x)
	#define wi(x)
	#define wisp(x)
	#define what_is(x, terminator)
#endif

#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define REV_ALL(x) x.rbegin(), x.rend()
#define SZ(x) (int)x.size()
#define CONTAINS(cont, val) (cont.find(val) != cont.end())
#define endl '\n'
#define IO_SPEED_UP ios::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, s, e) for(ll i = s; i < e; i++)
#define leftmost_set(x) __builtin_clzll(x)
#define PARENT(n) ((n) >> 1LL)
#define LCHILD(n) ((n) << 1LL)
#define RCHILD(n) (((n) << 1LL) + 1LL)
#define TWO_POWER(n) (1LL << (n))

typedef long long ll;typedef pair<ll, ll> ii;
typedef vector<ll> vi;typedef vector<bool> vb;
typedef vector<ii> vii;typedef vector<vi> vvi;

const ll PINF = 1E9 + 5;
const ll NINF = -1E9 - 5;
const ll M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

void get_arr(vi& a, int n) {
	if(SZ(a) < n) a.resize(n); for(int i = 0; i < n; i++) cin >> a[i];
}

void print_arr(const vi &a) {
	for(int i = 0; i < SZ(a); i++) {cout << a[i] << " ";} cout << endl;
}

int main() {
	IO_SPEED_UP;
	if(fopen("tupni.txt", "r")) {
		freopen("tupni.txt", "r", stdin);
		freopen("tuptuo.txt", "w", stdout);
	}

	vector<pair<double, double> > costs(4);
	vi values(4);
	for (ll i = 0; i < 4; ++i) {
		cin >> values[i];
		costs[i].S = TWO_POWER(i) * 0.25;
		costs[i].F = values[i] / costs[i].S;
	}
	sort(ALL(costs));
	ll n; cin >> n;
	ll cost = 0;
	for (int i = 0; i < 4; ++i) {
		if(n != 0) {
			int q = n / costs[i].S;
			n -= q * costs[i].S;
			cost += q * values[i];
		}
	}
	cout << cost << endl;
	return 0;
}

Submission Info

Submission Time
Task A - Ice Tea Store
User sleepify
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2728 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:65:35: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   freopen("tupni.txt", "r", stdin);
                                   ^
./Main.cpp:66:37: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   freopen("tuptuo.txt", "w", stdout);
                                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
WA × 2
AC × 8
WA × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 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
Case Name Status Exec Time Memory
sample_01.txt WA 1 ms 256 KB
sample_02.txt WA 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 WA 1 ms 256 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt WA 1 ms 256 KB
subtask_1_06.txt WA 1 ms 256 KB
subtask_1_07.txt WA 1 ms 256 KB
subtask_1_08.txt WA 1 ms 256 KB
subtask_1_09.txt WA 1 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt WA 1 ms 256 KB
subtask_1_12.txt WA 1 ms 256 KB
subtask_1_13.txt WA 1 ms 256 KB
subtask_1_14.txt WA 1 ms 256 KB
subtask_1_15.txt WA 1 ms 256 KB