Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cassert>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <set>
  8.  
  9. #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
  10. #define REP(i, n) FOR (i, 0, n)
  11. #define _ << " _ " <<
  12. #define TRACE(x) cerr << #x << " = " << x << endl
  13. #define debug(...) fprintf(stderr, __VA_ARGS__)
  14. #define debug
  15. #define TRACE(x)
  16.  
  17. using namespace std;
  18.  
  19. typedef long long llint;
  20.  
  21. int n, c, w;
  22. vector<int> v;
  23.  
  24. multiset<int> s;
  25. int bestw;
  26.  
  27. void decline() {
  28. printf("decline\n");
  29. fflush(stdout);
  30. }
  31.  
  32. void accept() {
  33. printf("accept\n");
  34. fflush(stdout);
  35. }
  36.  
  37. void stop() {
  38. printf("stop\n");
  39. fflush(stdout);
  40. exit(0);
  41. }
  42.  
  43. void solve() {
  44. REP(mask, (1 << n)) {
  45. int sum = 0;
  46. REP(i, n)
  47. if (mask & (1 << i))
  48. sum += v[i];
  49. if (sum > bestw && sum <= c) {
  50. bestw = sum;
  51. s.clear();
  52. REP(i, n)
  53. if (mask & (1 << i))
  54. s.insert(v[i]);
  55. }
  56. }
  57. }
  58.  
  59. void go_zero() {
  60. while (w > 0) {
  61. int tw;
  62. scanf("%d",&tw);
  63. if (tw < w) {
  64. accept();
  65. w = tw;
  66. }
  67. else
  68. decline();
  69. }
  70. }
  71.  
  72. int main(void) {
  73. scanf("%d %d %d",&n,&c,&w);
  74. accept();
  75.  
  76. go_zero();
  77.  
  78. while ((int)v.size() < n) {
  79. int tw;
  80. scanf("%d",&tw);
  81. if (tw > w) {
  82. v.push_back(tw - w);
  83. accept();
  84. w = tw;
  85. }
  86. else
  87. decline();
  88. }
  89.  
  90. //debug("skupio sve stvari\n");
  91.  
  92. solve();
  93.  
  94. // debug("solved\n");
  95. // TRACE(bestw);
  96.  
  97. go_zero();
  98.  
  99. while (w < bestw) {
  100. int tw;
  101. scanf("%d",&tw);
  102. int d = tw - w;
  103. //TRACE(d);
  104.  
  105. if (tw == bestw)
  106. break;
  107.  
  108. if (s.find(d) != s.end()) {
  109. accept();
  110. s.erase(s.find(d));
  111. w = tw;
  112. } else
  113. decline();
  114. }
  115.  
  116. stop();
  117.  
  118. return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement