Submission #4036659

Source Code Expand

Copy
```#include <numeric>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <iostream>
using namespace std;

int D, T, C[8], A[8];

void input() {
scanf(" %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
&D, &T, &C[0], &C[1], &C[2], &C[3], &C[4], &C[5], &C[6], &C[7],
&A[0], &A[1], &A[2], &A[3], &A[4], &A[5], &A[6], &A[7]);
}

void fill(int i) { cout << "fill " << i+1 << endl; }
void move(int i, int j) { cout << "move " << i+1 << ' ' << j+1 << endl; }
void change(int i) { cout << "change " << i+1 << endl; }
void pass() { cout << "pass" << endl; }
void sell(vector<int> &v) {
cout << "sell " << v.size();
for (int i : v) cout << ' ' << i+1;
cout << endl;
}

bool sell_if_possible() {
int buf[51] = {};
memset(buf, -1, sizeof(buf));
buf[0] = 0;
for (int i = 0; i < 8; i++) {
if (A[i] == 0) continue;
for (int a = D - A[i]; a >= 0; a--)
if (buf[a] >= 0 && buf[a+A[i]] < 0) buf[a+A[i]] = i;
}
if (buf[D] < 0) return false;
vector<int> v;
int a = D;
while (a > 0) { v.push_back(buf[a]); a -= A[buf[a]]; }
sell(v);
return true;
}

int main() {
int CNT = 1000;
while (CNT--) {
int to_fill = -1, c_max = 3, *p;
input();
if (accumulate(C, C+8, 0) < 50) c_max = 4;
if (D > 32 && sell_if_possible()) goto next;
for (int i = 0; i < 8; i++) {
if (A[i] == 0 && C[i] > c_max) { c_max = C[i]; to_fill = i; }
}
if (to_fill >= 0) { fill(to_fill); goto next; }
p = min_element(C, C+8);
if (*p <= c_max) {
change(p-C); goto next;
}
pass();
next:;
}
}
```

#### Submission Info

Submission Time 2019-01-18 20:34:57+0900 A - 石油王Xの憂鬱 kozima C++14 (GCC 5.4.1) 7116686 1769 Byte AC 55 ms 724 KB

#### Compile Error

```./Main.cpp: In function ‘void input()’:
./Main.cpp:14:66: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
&A[0], &A[1], &A[2], &A[3], &A[4], &A[5], &A[6], &A[7]);
^
```

#### Judge Result

Set Name Score / Max Score Test Cases
Case Name Status Exec Time Memory