Submission #1213097


Source Code Expand


#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>

auto& in = std::cin;
auto& out = std::cout;

template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

constexpr int64_t INF = 9223372036854775807/10;
int32_t N;
int64_t a[555];
int64_t dp[15][15][1 << 15];
int64_t func(int32_t i, int32_t need, int32_t mask, int64_t max) {
	if (need <= 0) { return 0; }
	if (i >= N) { return INF; }
	auto& memo = dp[i][need][mask];
	if (memo !=-1) {
		return memo;
	}
	return memo= std::min(func(i + 1, need, mask, max),
		func(i + 1, need - 1, mask|(1<<i), std::max(max + 1, a[i])) + std::max<int64_t>(0, max + 1 - a[i])
		);
}
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	fill_all<int64_t>(dp, -1);
	int need;
	in >> N>>need;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> a[i];
	}
	out << func(0, need, 0, 0) << endl;

	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>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
std::string S[10000];
std::string T;

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

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> S[i];
	}
	in >> T;



	return 0;
}
#endif

Submission Info

Submission Time
Task B - Buildings are Colorful!
User eiya
Language C++14 (GCC 5.4.1)
Score 90
Code Size 2079 Byte
Status WA
Exec Time 16 ms
Memory 57856 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 120 90 / 90 0 / 140
Status
AC × 1
WA × 1
WA × 2
AC × 3
AC × 5
WA × 4
Set Name Test Cases
Sample sub0_in1.txt, sub0_in2.txt
Subtask1 sub1_in1.txt, sub1_in2.txt
Subtask2 sub2_in1.txt, sub2_in2.txt, sub2_in3.txt
Subtask3 sub0_in1.txt, sub0_in2.txt, sub1_in1.txt, sub1_in2.txt, sub2_in1.txt, sub2_in2.txt, sub2_in3.txt, sub3_in1.txt, sub3_in2.txt
Case Name Status Exec Time Memory
sub0_in1.txt AC 16 ms 57856 KB
sub0_in2.txt WA 16 ms 57856 KB
sub1_in1.txt WA 16 ms 57856 KB
sub1_in2.txt WA 16 ms 57856 KB
sub2_in1.txt AC 16 ms 57856 KB
sub2_in2.txt AC 16 ms 57856 KB
sub2_in3.txt AC 16 ms 57856 KB
sub3_in1.txt AC 16 ms 57856 KB
sub3_in2.txt WA 16 ms 57856 KB