Submission #68400

#TimeUsernameProblemLanguageResultExecution timeMemory
68400BTheroSemiexpress (JOI17_semiexpress)C++17
18 / 100
36 ms1116 KiB
// Why I am so dumb? :c #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; typedef long long ll; const int MAXN = (int)3e2 + 5; int dp[MAXN][MAXN]; bool good[MAXN]; int p[MAXN]; int n, m, k; int a, b, c; int lim; void solve() { scanf("%d %d %d", &n, &m, &k); scanf("%d %d %d", &a, &b, &c); scanf("%d", &lim); for (int i = 1, x; i <= m; ++i) { scanf("%d", &x); good[x] = 1; } for (int i = 1, v = 1; i <= n; ++i) { if (good[i]) { v = i; } p[i] = v; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= k; ++j) { dp[i][j] = -n; } } dp[1][1] = 0; for (int i = 2; i <= n; ++i) { for (int j = 2; j <= k; ++j) { for (int pr = p[i - 1]; pr < i; ++pr) { int cost = (p[i - 1] - 1) * b + (pr - p[i - 1]) * c; int cnt = 0; for (int x = pr + 1; x < i; ++x) { if (cost + (x - pr) * a <= lim) { ++cnt; } } if (good[i]) { if ((i - 1) * b <= lim) { ++cnt; } } else { if (cost + (i - pr) * c <= lim) { ++cnt; } } dp[i][j] = max(dp[i][j], dp[pr][j - 1] + cnt); } } } printf("%d\n", dp[n][k]); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &a, &b, &c);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &lim);
  ~~~~~^~~~~~~~~~~~
semiexpress.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...