Submission #433363

#TimeUsernameProblemLanguageResultExecution timeMemory
433363frodakcinJelly Flavours (IOI20_jelly)C++17
100 / 100
62 ms460 KiB
#include "jelly.h" #include <algorithm> #include <cstring> #include <vector> #include <numeric> bool ckmax(auto& a, const auto& b) {return b>a?a=b,1:0;} bool ckmin(auto& a, const auto& b) {return b<a?a=b,1:0;} const int MN = 2e3+10; const int MV = 1e4+10; struct st { public: int v, bv; st inc() {return {v+1, bv};} void buy(int cost) {++v, bv-=cost;} bool operator > (const st& o) const {return v > o.v || !(o.v > v) && bv > o.bv;} } dp[MV]; int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) { int N = a.size(); std::vector<int> ord(N); std::iota(ord.begin(), ord.end(), 0); std::sort(ord.begin(), ord.end(), [&](int u, int v){return b[u]<b[v];}); for(int i=0;i<=x;++i) dp[i]={0,y}; for(int i=0;i<N;++i) { int k=ord[i]; for(int j=0;j<=x;++j) { if(dp[j].bv >= b[k]) dp[j].buy(b[k]); if(j+a[k]<=x) ckmax(dp[j], dp[j+a[k]].inc()); } } return dp[0].v; }

Compilation message (stderr)

jelly.cpp:7:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    7 | bool ckmax(auto& a, const auto& b) {return b>a?a=b,1:0;}
      |            ^~~~
jelly.cpp:7:27: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    7 | bool ckmax(auto& a, const auto& b) {return b>a?a=b,1:0;}
      |                           ^~~~
jelly.cpp:8:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    8 | bool ckmin(auto& a, const auto& b) {return b<a?a=b,1:0;}
      |            ^~~~
jelly.cpp:8:27: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    8 | bool ckmin(auto& a, const auto& b) {return b<a?a=b,1:0;}
      |                           ^~~~
jelly.cpp: In member function 'bool st::operator>(const st&) const':
jelly.cpp:19:69: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   19 |   bool operator > (const st& o) const {return v > o.v || !(o.v > v) && bv > o.bv;}
      |                                                          ~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...