Submission #1173219
Source Code Expand
#include <cstdio>
#include <vector>
#include <numeric>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define debug(x) #x << " = " << (x) << " "
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
constexpr int n = 8;
constexpr int d_max = 50;
constexpr int total_turn = 1000;
void do_fill(int i) {
assert (0 <= i and i < 8);
printf("fill %d\n", i+1);
fflush(stdout);
}
void do_move(int i, int j) {
assert (0 <= i and i < 8);
assert (0 <= j and j < 8);
printf("move %d %d\n", i+1, j+1);
fflush(stdout);
}
void do_change(int i) {
assert (0 <= i and i < 8);
printf("change %d\n", i+1);
fflush(stdout);
}
void do_pass() {
printf("pass\n");
fflush(stdout);
}
void do_sell(vector<int> const & x) {
printf("sell %d", int(x.size()));
for (int it : x) printf(" %d", it+1);
printf("\n");
fflush(stdout);
}
void do_sell(array<bool, n> const & x) {
vector<int> y;
repeat (i,n) if (x[i]) y.push_back(x[i]);
do_sell(y);
}
array<vector<int>, d_max+1> compute_sellables(array<int, n> const & a) {
array<vector<int>, d_max+1> dp = {};
repeat (i,n) {
repeat_reverse (j,d_max) if (0 < a[i]+j and a[i]+j <= d_max and (j == 0 or not dp[j].empty())) {
vector<int> ndp = dp[j];
ndp.push_back(i);
if (dp[a[i]+j].empty() or ndp.size() < dp[a[i]+j].size()) {
dp[a[i]+j] = ndp;
}
}
}
return dp;
}
void solve(int turn) {
int d, t; scanf("%d%d", &d, &t);
array<int,n> c; repeat (i,n) scanf("%d", &c[i]);
array<int,n> a; repeat (i,n) scanf("%d", &a[i]);
int sum_a = whole(accumulate, a, 0);
if (d < sum_a/2 or sum_a < d) {
repeat (i,n) {
if (a[i] == 0) {
do_fill(i);
return;
}
}
do_pass();
return;
}
auto sellable = compute_sellables(a);
if (not sellable[d].empty()) {
do_sell(sellable[d]);
return;
}
repeat (i,n) {
if (a[i] == 0) {
do_fill(i);
return;
}
}
repeat (i,n) {
if (a[i] < c[i]) {
do_fill(i);
return;
}
}
do_pass();
}
int main() {
repeat (turn, total_turn) {
solve(turn);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 石油王Xの憂鬱 |
User |
kimiyuki |
Language |
C++14 (GCC 5.4.1) |
Score |
5230976 |
Code Size |
3341 Byte |
Status |
AC |
Exec Time |
46 ms |
Memory |
724 KB |
Compile Error
./Main.cpp: In function ‘void solve(int)’:
./Main.cpp:74:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int d, t; scanf("%d%d", &d, &t);
^
./Main.cpp:75:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
array<int,n> c; repeat (i,n) scanf("%d", &c[i]);
^
./Main.cpp:76:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
array<int,n> a; repeat (i,n) scanf("%d", &a[i]);
^
Judge Result
Set Name |
test_01 |
test_02 |
test_03 |
test_04 |
test_05 |
test_06 |
test_07 |
test_08 |
test_09 |
test_10 |
test_11 |
test_12 |
test_13 |
test_14 |
test_15 |
test_16 |
test_17 |
test_18 |
test_19 |
test_20 |
test_21 |
test_22 |
test_23 |
test_24 |
test_25 |
test_26 |
test_27 |
test_28 |
test_29 |
test_30 |
test_31 |
test_32 |
test_33 |
test_34 |
test_35 |
test_36 |
test_37 |
test_38 |
test_39 |
test_40 |
test_41 |
test_42 |
test_43 |
test_44 |
test_45 |
test_46 |
test_47 |
test_48 |
test_49 |
test_50 |
Score / Max Score |
105429 / 417500 |
113535 / 417500 |
103825 / 417500 |
96617 / 417500 |
92567 / 417500 |
108501 / 417500 |
121863 / 417500 |
92163 / 417500 |
111173 / 417500 |
100788 / 417500 |
98034 / 417500 |
108681 / 417500 |
100090 / 417500 |
111097 / 417500 |
102298 / 417500 |
124736 / 417500 |
110934 / 417500 |
108927 / 417500 |
116536 / 417500 |
105828 / 417500 |
109133 / 417500 |
103651 / 417500 |
88857 / 417500 |
96771 / 417500 |
106023 / 417500 |
101945 / 417500 |
98662 / 417500 |
103430 / 417500 |
103330 / 417500 |
114619 / 417500 |
108119 / 417500 |
103180 / 417500 |
99270 / 417500 |
96726 / 417500 |
99037 / 417500 |
106746 / 417500 |
101200 / 417500 |
105918 / 417500 |
92100 / 417500 |
104501 / 417500 |
112016 / 417500 |
97632 / 417500 |
105747 / 417500 |
100293 / 417500 |
104380 / 417500 |
109445 / 417500 |
107751 / 417500 |
105180 / 417500 |
98990 / 417500 |
112702 / 417500 |
Status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
test_01 |
subtask_01_01.txt |
test_02 |
subtask_01_02.txt |
test_03 |
subtask_01_03.txt |
test_04 |
subtask_01_04.txt |
test_05 |
subtask_01_05.txt |
test_06 |
subtask_01_06.txt |
test_07 |
subtask_01_07.txt |
test_08 |
subtask_01_08.txt |
test_09 |
subtask_01_09.txt |
test_10 |
subtask_01_10.txt |
test_11 |
subtask_01_11.txt |
test_12 |
subtask_01_12.txt |
test_13 |
subtask_01_13.txt |
test_14 |
subtask_01_14.txt |
test_15 |
subtask_01_15.txt |
test_16 |
subtask_01_16.txt |
test_17 |
subtask_01_17.txt |
test_18 |
subtask_01_18.txt |
test_19 |
subtask_01_19.txt |
test_20 |
subtask_01_20.txt |
test_21 |
subtask_01_21.txt |
test_22 |
subtask_01_22.txt |
test_23 |
subtask_01_23.txt |
test_24 |
subtask_01_24.txt |
test_25 |
subtask_01_25.txt |
test_26 |
subtask_01_26.txt |
test_27 |
subtask_01_27.txt |
test_28 |
subtask_01_28.txt |
test_29 |
subtask_01_29.txt |
test_30 |
subtask_01_30.txt |
test_31 |
subtask_01_31.txt |
test_32 |
subtask_01_32.txt |
test_33 |
subtask_01_33.txt |
test_34 |
subtask_01_34.txt |
test_35 |
subtask_01_35.txt |
test_36 |
subtask_01_36.txt |
test_37 |
subtask_01_37.txt |
test_38 |
subtask_01_38.txt |
test_39 |
subtask_01_39.txt |
test_40 |
subtask_01_40.txt |
test_41 |
subtask_01_41.txt |
test_42 |
subtask_01_42.txt |
test_43 |
subtask_01_43.txt |
test_44 |
subtask_01_44.txt |
test_45 |
subtask_01_45.txt |
test_46 |
subtask_01_46.txt |
test_47 |
subtask_01_47.txt |
test_48 |
subtask_01_48.txt |
test_49 |
subtask_01_49.txt |
test_50 |
subtask_01_50.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask_01_01.txt |
AC |
42 ms |
720 KB |
subtask_01_02.txt |
AC |
44 ms |
720 KB |
subtask_01_03.txt |
AC |
42 ms |
720 KB |
subtask_01_04.txt |
AC |
45 ms |
720 KB |
subtask_01_05.txt |
AC |
45 ms |
720 KB |
subtask_01_06.txt |
AC |
45 ms |
720 KB |
subtask_01_07.txt |
AC |
44 ms |
720 KB |
subtask_01_08.txt |
AC |
41 ms |
720 KB |
subtask_01_09.txt |
AC |
41 ms |
716 KB |
subtask_01_10.txt |
AC |
44 ms |
720 KB |
subtask_01_11.txt |
AC |
45 ms |
720 KB |
subtask_01_12.txt |
AC |
45 ms |
716 KB |
subtask_01_13.txt |
AC |
44 ms |
716 KB |
subtask_01_14.txt |
AC |
44 ms |
720 KB |
subtask_01_15.txt |
AC |
43 ms |
724 KB |
subtask_01_16.txt |
AC |
44 ms |
724 KB |
subtask_01_17.txt |
AC |
42 ms |
720 KB |
subtask_01_18.txt |
AC |
43 ms |
724 KB |
subtask_01_19.txt |
AC |
42 ms |
724 KB |
subtask_01_20.txt |
AC |
44 ms |
724 KB |
subtask_01_21.txt |
AC |
42 ms |
720 KB |
subtask_01_22.txt |
AC |
45 ms |
720 KB |
subtask_01_23.txt |
AC |
43 ms |
596 KB |
subtask_01_24.txt |
AC |
43 ms |
724 KB |
subtask_01_25.txt |
AC |
39 ms |
596 KB |
subtask_01_26.txt |
AC |
45 ms |
712 KB |
subtask_01_27.txt |
AC |
45 ms |
720 KB |
subtask_01_28.txt |
AC |
44 ms |
720 KB |
subtask_01_29.txt |
AC |
42 ms |
720 KB |
subtask_01_30.txt |
AC |
46 ms |
720 KB |
subtask_01_31.txt |
AC |
44 ms |
720 KB |
subtask_01_32.txt |
AC |
41 ms |
716 KB |
subtask_01_33.txt |
AC |
42 ms |
720 KB |
subtask_01_34.txt |
AC |
42 ms |
692 KB |
subtask_01_35.txt |
AC |
43 ms |
596 KB |
subtask_01_36.txt |
AC |
46 ms |
592 KB |
subtask_01_37.txt |
AC |
43 ms |
720 KB |
subtask_01_38.txt |
AC |
45 ms |
724 KB |
subtask_01_39.txt |
AC |
43 ms |
716 KB |
subtask_01_40.txt |
AC |
42 ms |
720 KB |
subtask_01_41.txt |
AC |
44 ms |
724 KB |
subtask_01_42.txt |
AC |
44 ms |
720 KB |
subtask_01_43.txt |
AC |
45 ms |
720 KB |
subtask_01_44.txt |
AC |
44 ms |
716 KB |
subtask_01_45.txt |
AC |
43 ms |
720 KB |
subtask_01_46.txt |
AC |
44 ms |
724 KB |
subtask_01_47.txt |
AC |
43 ms |
596 KB |
subtask_01_48.txt |
AC |
42 ms |
720 KB |
subtask_01_49.txt |
AC |
46 ms |
720 KB |
subtask_01_50.txt |
AC |
42 ms |
720 KB |