Submission #958648

# Submission time Handle Problem Language Result Execution time Memory
958648 2024-04-06T09:42:46 Z Yang8on Lamps (JOI19_lamps) C++14
0 / 100
1 ms 860 KB
#include <bits/stdc++.h>
#define Y8o "moomoo"
#define maxn 100005
#define ll long long
#define pii pair<int, int>
#define gb(i, j) ((i >> j) & 1)

using namespace std;

/// okay?
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r) {
    return uniform_int_distribution<ll> (l, r) (rng);
}
void iof() { /// ------------------inp_out file!-----------------///
    if(fopen(Y8o".inp", "r"))
    {
        freopen(Y8o".inp", "r", stdin);
        freopen(Y8o".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
void ctime() { /// ------------------check time!-----------------///
    cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
/// okay!

int n, m;
int v[maxn], a[maxn];
int dp[maxn];

void prepare()
{
    for(int i = 1; i <= maxn - 5; i ++) dp[i] = 1e9;
    dp[0] = 0;

    for(int i = 1; i <= maxn - 5; i ++)
        for(int j = 1; j <= m; j ++) if(i >= v[j])
            dp[i] = min(dp[i], dp[i - v[j]] + 1);

}

void solve()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i ++) cin >> v[i];

    prepare();

    ll ans = 0, tmp = 0;
    for(int i = 1; i <= n; i ++)
    {
        ll x;
        cin >> x;
        ans += dp[x - tmp];
        tmp = max(0ll, x - 1);
    }

    cout << ans;
}


int main()
{
    iof();

    int nTest = 1;
//    cin >> nTest;

    while(nTest --) {
        solve();
    }

    ctime();
    return 0;
}

Compilation message

lamp.cpp: In function 'void iof()':
lamp.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
lamp.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(Y8o".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Incorrect 1 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -