Submission #217409

# Submission time Handle Problem Language Result Execution time Memory
217409 2020-03-29T14:32:56 Z Just_Solve_The_Problem 코알라 (JOI13_koala) C++11
20 / 100
10 ms 384 KB
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int N = (int)1e5 + 7;

int k, m, d, a, n;
int t[N], b[N];
ll dp[N];

ll get(int i, int j) {
  int dis = t[j] - t[i];
  return (dis + d - 1) / d * 1ll * a;
}

main() {
  scanf("%d %d %d %d %d", &k, &m, &d, &a, &n);
  if (n > 1000) {
    return 0;
  }
  t[0] = k;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &t[i], &b[i]);
  }
  t[n + 1] = m;
  for (int i = 1; i <= n + 1; i++) {
    dp[i] = -1e18;
    for (int j = 0; j < i; j++) {
      dp[i] = max(dp[i], dp[j] - get(j, i));
    }
    dp[i] += b[i];
  }
  cout << dp[n + 1];
}

Compilation message

koala.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
koala.cpp: In function 'int main()':
koala.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d %d", &k, &m, &d, &a, &n);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &t[i], &b[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 10 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -