Submission #1174143
Source Code Expand
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
putchar('\n');
}
const int N = 8;
const int TURN = 1000;
int D, T, C[8], A[8];
VI cans;
int dp[64];
bool sellable() {
LL orr = 1;
REP (i, N) {
orr |= orr << A[i];
}
if (orr & (1LL<<D)) {
memset(dp, -1, sizeof dp);
dp[0] = -2;
REP (i, N) for (int j=D-A[i]; j>=0; j--) if (dp[j+A[i]] == -1 && dp[j] != -1) dp[j+A[i]] = i;
cans.clear();
int d = D;
while (d) {
cans.push_back(dp[d]);
d -= A[dp[d]];
}
return true;
} else {
return false;
}
}
int sum_oil() {
int s = 0;
REP (i, N) s += A[i];
return s;
}
int get_empty() {
VI v;
REP (i, N) if (A[i] == 0) v.push_back(i);
if (v.empty()) return N;
else return v[rand() % v.size()];
}
int get_max_empty() {
int k = N;
REP (i, N) if (A[i] == 0 && (k == N || C[k] < C[i])) k = i;
return k;
}
void O_fill(int i) {
printf("fill %d\n", i+1); fflush(stdout);
}
void O_move(int i, int j) {
}
void O_change(int i) {
printf("change %d\n", i+1); fflush(stdout);
}
void O_pass() {
puts("pass"); fflush(stdout);
}
void O_sell() {
printf("sell %d ", (int)cans.size());
EACH (e, cans) ++*e;
rprintf("%d", cans.begin(), cans.end());
fflush(stdout);
}
int main() {
REP (turn, TURN) {
scanf("%d%d", &D, &T);
REP (i, N) scanf("%d", C+i);
REP (i, N) scanf("%d", A+i);
if (D >= 29 && sellable()) {
O_sell();
} else {
int k = get_max_empty();
if (k < N && C[k] >= 4) {
O_fill(k);
} else if (*min_element(C, C+N) <= 3) {
O_change(min_element(C, C+N) - C);
} else {
O_pass();
}
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 石油王Xの憂鬱 |
User |
natsugiri |
Language |
C++14 (GCC 5.4.1) |
Score |
7136279 |
Code Size |
2415 Byte |
Status |
AC |
Exec Time |
43 ms |
Memory |
724 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:94:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &D, &T);
^
./Main.cpp:95:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP (i, N) scanf("%d", C+i);
^
./Main.cpp:96:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP (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 |
139038 / 417500 |
136494 / 417500 |
154483 / 417500 |
141957 / 417500 |
144004 / 417500 |
147112 / 417500 |
154994 / 417500 |
141937 / 417500 |
144534 / 417500 |
146620 / 417500 |
160280 / 417500 |
143514 / 417500 |
149492 / 417500 |
152418 / 417500 |
137985 / 417500 |
152403 / 417500 |
133202 / 417500 |
132420 / 417500 |
150440 / 417500 |
133189 / 417500 |
153643 / 417500 |
145948 / 417500 |
128402 / 417500 |
140633 / 417500 |
140696 / 417500 |
145139 / 417500 |
143408 / 417500 |
139706 / 417500 |
142591 / 417500 |
143417 / 417500 |
150474 / 417500 |
143069 / 417500 |
143019 / 417500 |
137730 / 417500 |
142421 / 417500 |
145857 / 417500 |
143268 / 417500 |
141498 / 417500 |
137595 / 417500 |
140103 / 417500 |
141044 / 417500 |
137897 / 417500 |
138853 / 417500 |
131030 / 417500 |
148605 / 417500 |
135181 / 417500 |
141124 / 417500 |
130668 / 417500 |
137657 / 417500 |
149087 / 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 |
41 ms |
720 KB |
subtask_01_02.txt |
AC |
43 ms |
720 KB |
subtask_01_03.txt |
AC |
40 ms |
720 KB |
subtask_01_04.txt |
AC |
41 ms |
720 KB |
subtask_01_05.txt |
AC |
40 ms |
720 KB |
subtask_01_06.txt |
AC |
39 ms |
720 KB |
subtask_01_07.txt |
AC |
42 ms |
720 KB |
subtask_01_08.txt |
AC |
39 ms |
720 KB |
subtask_01_09.txt |
AC |
41 ms |
720 KB |
subtask_01_10.txt |
AC |
41 ms |
720 KB |
subtask_01_11.txt |
AC |
40 ms |
720 KB |
subtask_01_12.txt |
AC |
41 ms |
720 KB |
subtask_01_13.txt |
AC |
40 ms |
716 KB |
subtask_01_14.txt |
AC |
41 ms |
596 KB |
subtask_01_15.txt |
AC |
40 ms |
720 KB |
subtask_01_16.txt |
AC |
39 ms |
720 KB |
subtask_01_17.txt |
AC |
42 ms |
720 KB |
subtask_01_18.txt |
AC |
39 ms |
716 KB |
subtask_01_19.txt |
AC |
42 ms |
720 KB |
subtask_01_20.txt |
AC |
42 ms |
720 KB |
subtask_01_21.txt |
AC |
40 ms |
716 KB |
subtask_01_22.txt |
AC |
41 ms |
724 KB |
subtask_01_23.txt |
AC |
40 ms |
720 KB |
subtask_01_24.txt |
AC |
40 ms |
716 KB |
subtask_01_25.txt |
AC |
41 ms |
720 KB |
subtask_01_26.txt |
AC |
39 ms |
696 KB |
subtask_01_27.txt |
AC |
39 ms |
720 KB |
subtask_01_28.txt |
AC |
41 ms |
720 KB |
subtask_01_29.txt |
AC |
43 ms |
716 KB |
subtask_01_30.txt |
AC |
40 ms |
720 KB |
subtask_01_31.txt |
AC |
43 ms |
592 KB |
subtask_01_32.txt |
AC |
40 ms |
716 KB |
subtask_01_33.txt |
AC |
40 ms |
716 KB |
subtask_01_34.txt |
AC |
39 ms |
592 KB |
subtask_01_35.txt |
AC |
40 ms |
724 KB |
subtask_01_36.txt |
AC |
41 ms |
720 KB |
subtask_01_37.txt |
AC |
42 ms |
716 KB |
subtask_01_38.txt |
AC |
41 ms |
712 KB |
subtask_01_39.txt |
AC |
42 ms |
720 KB |
subtask_01_40.txt |
AC |
37 ms |
596 KB |
subtask_01_41.txt |
AC |
42 ms |
724 KB |
subtask_01_42.txt |
AC |
39 ms |
720 KB |
subtask_01_43.txt |
AC |
43 ms |
588 KB |
subtask_01_44.txt |
AC |
40 ms |
720 KB |
subtask_01_45.txt |
AC |
40 ms |
716 KB |
subtask_01_46.txt |
AC |
41 ms |
720 KB |
subtask_01_47.txt |
AC |
40 ms |
720 KB |
subtask_01_48.txt |
AC |
40 ms |
720 KB |
subtask_01_49.txt |
AC |
41 ms |
712 KB |
subtask_01_50.txt |
AC |
39 ms |
720 KB |