Submission #814350

#TimeUsernameProblemLanguageResultExecution timeMemory
814350vjudge1코알라 (JOI13_koala)C++17
20 / 100
2061 ms19404 KiB
#include<bits/stdc++.h> #define MASK(i) (1 << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define fi first #define se second #define ull unsigned long long #define ll long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define nl cout << "\n" #define ___ << " " << #define mem(a, b) memset((a), (b), sizeof((a))) #define all(c) (c).begin(), (c).end() #define Times cerr << "\nTime run: " << clock() / 1000.0 << " ms\n" #define file "G:\\My Drive\\TIN HOC\\hoang" using namespace std; template<class T1, class T2> void mini(T1 &a, T2 b) {if (a > b) a = b;} template<class T1, class T2> void maxi(T1 &a, T2 b) {if (a < b) a = b;} const int oo = 1e9 + 7; const int mod = 1e9 + 7; const int N = 2e6 + 5; const int LOG = 20; ll k, m, d, a, n; ll t[N], b[N]; ll dp[N]; void inp() { cin >> k >> m >> d >> a >> n; for (int i = 1; i <= n; i++) cin >> t[i] >> b[i]; } void solve() { //fi = max{fj } mem(dp, -0x3f); dp[0] = 0; t[0] = k; t[n + 1] = m; for (int i = 1; i <= n + 1; i++) { for (int j = 0; j < i; j++) { ll lost = dp[j] - ((t[i] - t[j] + d - 1) / d) * a; maxi(dp[i], lost); } dp[i] += b[i]; } cout << dp[n + 1]; } void run_with_file() { if (fopen(file".inp", "r")) { freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); } } int main() { cin.tie(0)->sync_with_stdio(0); run_with_file(); int test_case = 1; //cin >> test_case; while (test_case--) { inp(); solve(); } Times; }

Compilation message (stderr)

koala.cpp: In function 'void run_with_file()':
koala.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(file".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(file".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...