Submission #465068

#TimeUsernameProblemLanguageResultExecution timeMemory
465068jamezzzGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++17
15 / 100
346 ms780388 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #include <ext/rope> using namespace __gnu_cxx; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; //less_equal for identical elements #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define LINF 1023456789123456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vll; mt19937 rng(time(0)); int n,memo[405][405][405][3]; char c; vi v[3]; int dp(int i,int j,int k,int pv){ int p=i+j+k; if(p==n)return 0; if(p!=0&&memo[i][j][k][pv]!=-1)return memo[i][j][k][pv]; int res=INF; if(pv!=0&&i<sz(v[0]))mnto(res,dp(i+1,j,k,0)+max(0,v[0][i]-p)); if(pv!=1&&j<sz(v[1]))mnto(res,dp(i,j+1,k,1)+max(0,v[1][j]-p)); if(pv!=2&&k<sz(v[2]))mnto(res,dp(i,j,k+1,2)+max(0,v[2][k]-p)); if(pv==-1)return res; return memo[i][j][k][pv]=res; } int main(){ sf("%d",&n); for(int i=0;i<n;++i){ sf(" %c",&c); if(c=='R')v[0].pb(i); if(c=='G')v[1].pb(i); if(c=='Y')v[2].pb(i); } memset(memo,-1,sizeof memo); int ans=dp(0,0,0,-1); if(ans==INF)ans=-1; pf("%d\n",ans); }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:57:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |  sf("%d",&n);
      |    ^
joi2019_ho_t3.cpp:59:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |   sf(" %c",&c);
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...