Submission #1000760


Source Code Expand

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author RiaD
 */

#include <iostream>
#include <fstream>

#include <iostream>


#include <iterator>


#include <string>
#include <stdexcept>

#ifndef SPCPPL_ASSERT
	#ifdef SPCPPL_DEBUG
		#define SPCPPL_ASSERT(condition) \
		if(!(condition)) { \
			throw std::runtime_error(std::string() + #condition + " in line " + std::to_string(__LINE__) + " in " + __PRETTY_FUNCTION__); \
		}
	#else
		#define SPCPPL_ASSERT(condition)
	#endif
#endif


/**
* Support decrementing and multi-passing, but not declared bidirectional(or even forward) because
* it's reference type is not a reference.
*
* It doesn't return reference because
* 1. Anyway it'll not satisfy requirement [forward.iterators]/6
*   If a and b are both dereferenceable, then a == b if and only if *a and
*   b are bound to the same object.
* 2. It'll not work with reverse_iterator that returns operator * of temporary which is temporary for this iterator
*
* Note, reverse_iterator is not guaranteed to work  now too since it works only with bidirectional iterators,
* but it's seems to work at least on my implementation.
*
* It's not really useful anywhere except iterating anyway.
*/
template <typename T>
class IntegerIterator: public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> {
public:
	explicit IntegerIterator(T value): value(value) {

	}

	IntegerIterator& operator++() {
		++value;
		return *this;
	}

	IntegerIterator operator++(int) {
		IntegerIterator copy = *this;
		++value;
		return copy;
	}

	IntegerIterator& operator--() {
		--value;
		return *this;
	}

	IntegerIterator operator--(int) {
		IntegerIterator copy = *this;
		--value;
		return copy;
	}

	T operator*() const {
		return value;
	}

	bool operator==(IntegerIterator rhs) const {
		return value == rhs.value;
	}

	bool operator!=(IntegerIterator rhs) const {
		return !(*this == rhs);
	}

private:
	T value;
};

template <typename T>
class IntegerRange {
public:
	IntegerRange(T begin, T end): begin_(begin), end_(end) {
		SPCPPL_ASSERT(begin <= end);
	}

	IntegerIterator<T> begin() const {
		return IntegerIterator<T>(begin_);
	}

	IntegerIterator<T> end() const {
		return IntegerIterator<T>(end_);
	}

private:
	T begin_;
	T end_;
};

template <typename T>
class ReversedIntegerRange {
	typedef std::reverse_iterator<IntegerIterator<T>> IteratorType;
public:
	ReversedIntegerRange(T begin, T end): begin_(begin), end_(end) {
		SPCPPL_ASSERT(begin >= end);
	}

	IteratorType begin() const {
		return IteratorType(IntegerIterator<T>(begin_));
	}

	IteratorType end() const {
		return IteratorType(IntegerIterator<T>(end_));
	}

private:
	T begin_;
	T end_;
};

template <typename T>
IntegerRange<T> range(T to) {
	return IntegerRange<T>(0, to);
}

template <typename T>
IntegerRange<T> range(T from, T to) {
	return IntegerRange<T>(from, to);
}

template <typename T>
IntegerRange<T> inclusiveRange(T to) {
	return IntegerRange<T>(0, to + 1);
}

template <typename T>
IntegerRange<T> inclusiveRange(T from, T to) {
	return IntegerRange<T>(from, to + 1);
}

template <typename T>
ReversedIntegerRange<T> downrange(T from) {
	return ReversedIntegerRange<T>(from, 0);
}

template <typename T>
ReversedIntegerRange<T> downrange(T from, T to) {
	return ReversedIntegerRange<T>(from, to);
}

template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from) {
	return ReversedIntegerRange<T>(from + 1, 0);
}

template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
	return ReversedIntegerRange<T>(from + 1, to);
}

#include <vector>

using namespace std;

class TaskD {
public:
	void solve(std::istream& in, std::ostream& out) {
		vector<int> a(6), b(6);
		for (int i: range(6)) {
			in >> a[i];
		}
		for (int i: range(6)) {
			in >> b[i];
		}

		auto solve = [&](double p) {
			auto q = 1 - p;
			double ans = 0;
			for (int i: range(6)) {
				ans += max(p * a[i], q * b[i]);
			}
			return ans;
		};

		//cerr << solve(0.5) << endl;

		double mnAns = 1000000;

		for (int i: range(3000)) {
			for (int j: range(i + 1)) {
				mnAns = min(mnAns, solve(j * 1.0 / i));
			}
		}
		out << mnAns / 100.0 << endl;
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}

Submission Info

Submission Time
Task D - Dice Game
User riadwaw
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 4640 Byte
Status AC
Exec Time 50 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 41
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 49 ms 256 KB
001.txt AC 49 ms 256 KB
002.txt AC 49 ms 256 KB
003.txt AC 49 ms 256 KB
004.txt AC 49 ms 256 KB
005.txt AC 49 ms 256 KB
006.txt AC 49 ms 256 KB
007.txt AC 50 ms 256 KB
008.txt AC 49 ms 256 KB
009.txt AC 49 ms 256 KB
010.txt AC 49 ms 256 KB
011.txt AC 49 ms 256 KB
012.txt AC 49 ms 256 KB
013.txt AC 49 ms 256 KB
014.txt AC 49 ms 256 KB
015.txt AC 49 ms 256 KB
016.txt AC 49 ms 256 KB
017.txt AC 49 ms 256 KB
018.txt AC 49 ms 256 KB
019.txt AC 50 ms 256 KB
020.txt AC 50 ms 256 KB
021.txt AC 50 ms 256 KB
022.txt AC 50 ms 256 KB
023.txt AC 50 ms 256 KB
024.txt AC 49 ms 256 KB
025.txt AC 49 ms 256 KB
026.txt AC 50 ms 256 KB
027.txt AC 49 ms 256 KB
028.txt AC 50 ms 256 KB
029.txt AC 49 ms 256 KB
030.txt AC 49 ms 256 KB
031.txt AC 49 ms 256 KB
032.txt AC 49 ms 256 KB
033.txt AC 50 ms 256 KB
034.txt AC 49 ms 256 KB
035.txt AC 49 ms 256 KB
036.txt AC 49 ms 256 KB
037.txt AC 49 ms 256 KB
038.txt AC 50 ms 256 KB
example0.txt AC 49 ms 384 KB
example1.txt AC 49 ms 256 KB