Submission #814350

# Submission time Handle Problem Language Result Execution time Memory
814350 2023-08-08T07:00:12 Z vjudge1 코알라 (JOI13_koala) C++17
20 / 100
2000 ms 19404 KB
#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

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 time Memory Grader output
1 Correct 9 ms 15952 KB Output is correct
2 Correct 8 ms 15956 KB Output is correct
3 Correct 8 ms 15956 KB Output is correct
4 Correct 6 ms 15948 KB Output is correct
5 Correct 8 ms 15956 KB Output is correct
6 Correct 9 ms 15956 KB Output is correct
7 Correct 6 ms 15956 KB Output is correct
8 Correct 9 ms 15956 KB Output is correct
9 Correct 7 ms 15956 KB Output is correct
10 Correct 10 ms 16024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 19404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2003 ms 19404 KB Time limit exceeded
2 Halted 0 ms 0 KB -