답안 #217399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217399 2020-03-29T14:21:04 Z Just_Solve_The_Problem 코알라 (JOI13_koala) C++11
0 / 100
2000 ms 3448 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);
  m -= k - 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &t[i], &b[i]);
    t[i] -= k - 1;
  }
  t[n + 1] = m;
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 0; j < i; j++) {
      dp[i] = max(dp[i], dp[j] + b[i] - get(j, 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:22: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]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 3448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2085 ms 3308 KB Time limit exceeded
2 Halted 0 ms 0 KB -