Submission #200522

#TimeUsernameProblemLanguageResultExecution timeMemory
200522arnold518스트랩 (JOI14_straps)C++14
100 / 100
173 ms63780 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2000; const ll INF = 1e18; int N, A[MAXN+10], B[MAXN+10]; ll dp[MAXN+10][MAXN*2+10]; ll solve(int pos, int val) { if(pos==N+1) { if(val>=-1) return 0; else return -INF; } ll &ret=dp[pos][val+MAXN]; if(ret!=-1) return ret; ret=-INF; ret=max(ret, solve(pos+1, val)); ret=max(ret, solve(pos+1, min(N, val+A[pos]))+B[pos]); return ret; } int main() { int i, j; scanf("%d", &N); for(i=1; i<=N; i++) scanf("%d%d", &A[i], &B[i]), A[i]--; memset(dp, -1, sizeof(dp)); printf("%lld\n", solve(1, 0)); }

Compilation message (stderr)

straps.cpp: In function 'int main()':
straps.cpp:33:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
straps.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
straps.cpp:35:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%d%d", &A[i], &B[i]), A[i]--;
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...