Submission #2680779


Source Code Expand

Copy

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t A,B;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> A>>B;
	if (A <= 8 && B <= 8) {
		out << "Yay!\n";
	}
	else {
		out << ":(\n";
	}


	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;
std::tuple<int64_t, int64_t, int64_t> operator+(const std::tuple<int64_t, int64_t, int64_t>& a, const std::tuple<int64_t, int64_t, int64_t>& b) {
	return { std::get<0>(a) + std::get<0>(b), std::get<1>(a) + std::get<1>(b), std::get<2>(a) + std::get<2>(b) };
}

std::tuple<int64_t, int64_t, int64_t> xyz[1000];
bool used[1000][1001][3][3][3];
std::tuple<int64_t, int64_t, int64_t> DP[1000][1001][3][3][3];
std::tuple<int64_t, int64_t, int64_t> func(int i, int m, int n1, int n2, int n3)
{
	if (i == N) {
		return { 0 ,0,0};
	}
	if (m == 0) {
		return { 0 ,0,0 };
	}
	if (used[i][m][n1 + 1][n2 + 1][n3 + 1]) {
		return DP[i][m][n1 + 1][n2 + 1][n3 + 1];
	}
	used[i][m][n1 + 1][n2 + 1][n3 + 1] = true;
	auto a = func(i + 1, m, n1, n2, n3);
	auto b = func(i + 1, m - 1, n1, n2, n3) + xyz[i];

	auto a_score = n1 * std::get<0>(a) + n2 * std::get<1>(a) + n3 * std::get<2>(a);
	auto b_score = n1 * std::get<0>(b) + n2 * std::get<1>(b) + n3 * std::get<2>(b);

	if (a_score > b_score) {
		return DP[i][m][n1 + 1][n2 + 1][n3 + 1]=a;
	}
	else {
		return DP[i][m][n1 + 1][n2 + 1][n3 + 1] = b;
	}
}

template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);
	in >> N >> M;
	for (size_t i = 0; i < N; i++)
	{
		in >> std::get<0>(xyz[i]) >> std::get<1>(xyz[i]) >> std::get<2>(xyz[i]);
	}
	int64_t score = 0;
	for (int i = -1; i <= 1; i+=2)
		for (int j = -1; j <= 1; j += 2)
			for (int k = -1; k <= 1; k += 2)
	{
		auto a = func(0, M, i, j, k);
		auto score_TMP = i * std::get<0>(a) + j * std::get<1>(a) + k * std::get<2>(a);
		if (score_TMP > score) {
			score = score_TMP;
		}
	}
	out << score << endl;

	return 0;
}
#endif

Submission Info

Submission Time
Task A - Happy Birthday!
User eiya
Language C++14 (Clang 3.8.0)
Score 100
Code Size 3530 Byte
Status
Exec Time 2 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 100 / 100 in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
in01.txt 2 ms 256 KB
in02.txt 1 ms 256 KB
in03.txt 1 ms 256 KB
in04.txt 1 ms 256 KB
in05.txt 1 ms 256 KB
in06.txt 1 ms 256 KB
in07.txt 1 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB