Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstring>
- #include <cassert>
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
- #define REP(i, n) FOR (i, 0, n)
- #define _ << " _ " <<
- #define TRACE(x) cerr << #x << " = " << x << endl
- #define debug(...) fprintf(stderr, __VA_ARGS__)
- #define debug
- #define TRACE(x)
- using namespace std;
- typedef long long llint;
- int n, c, w;
- vector<int> v;
- multiset<int> s;
- int bestw;
- void decline() {
- printf("decline\n");
- fflush(stdout);
- }
- void accept() {
- printf("accept\n");
- fflush(stdout);
- }
- void stop() {
- printf("stop\n");
- fflush(stdout);
- exit(0);
- }
- void solve() {
- REP(mask, (1 << n)) {
- int sum = 0;
- REP(i, n)
- if (mask & (1 << i))
- sum += v[i];
- if (sum > bestw && sum <= c) {
- bestw = sum;
- s.clear();
- REP(i, n)
- if (mask & (1 << i))
- s.insert(v[i]);
- }
- }
- }
- void go_zero() {
- while (w > 0) {
- int tw;
- scanf("%d",&tw);
- if (tw < w) {
- accept();
- w = tw;
- }
- else
- decline();
- }
- }
- int main(void) {
- scanf("%d %d %d",&n,&c,&w);
- accept();
- go_zero();
- while ((int)v.size() < n) {
- int tw;
- scanf("%d",&tw);
- if (tw > w) {
- v.push_back(tw - w);
- accept();
- w = tw;
- }
- else
- decline();
- }
- //debug("skupio sve stvari\n");
- solve();
- // debug("solved\n");
- // TRACE(bestw);
- go_zero();
- while (w < bestw) {
- int tw;
- scanf("%d",&tw);
- int d = tw - w;
- //TRACE(d);
- if (tw == bestw)
- break;
- if (s.find(d) != s.end()) {
- accept();
- s.erase(s.find(d));
- w = tw;
- } else
- decline();
- }
- stop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement