Submission #990089

# Submission time Handle Problem Language Result Execution time Memory
990089 2024-05-29T14:18:01 Z haiphong5g0 Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
74 ms 156936 KB
#include <bits/stdc++.h>
#define task "CAU5"
#define pl pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (ll i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (ll i=a; i>=b; i+=c)
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll Mod = 998244353;
const int maxn = 1e7;
const ll Inf = 1e16;
ll delivery(int n,int k, int l, int A[])
{
    ll L[maxn+1], R[maxn+1], ans = Inf;
    FOR(i, 1, n, 1) {
        ll ans = Inf;
        L[i] = (i >= k ? L[i-k] : 0) + A[i-1]*2;
        R[i] = (i >= k ? R[i-k] : 0) + (l - A[n-i])*2;
    }
    FOR(i, 0, n, 1) ans = min(ans, L[i] + R[n-i]);
    FOR(i, 0, n-k, 1) ans = min(ans, L[i] + R[n-i-k] + k);
    return ans;
}
/*int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(nullptr); cout.tie(nullptr);
    int t; ///Setup();
    for (t=1; t--;)
    {
        ///Read();
        cout << delivery(n, k, l, A);
    }
}*/

Compilation message

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:20:12: warning: declaration of 'ans' shadows a previous local [-Wshadow]
   20 |         ll ans = Inf;
      |            ^~~
boxes.cpp:18:30: note: shadowed declaration is here
   18 |     ll L[maxn+1], R[maxn+1], ans = Inf;
      |                              ^~~
boxes.cpp:20:12: warning: unused variable 'ans' [-Wunused-variable]
   20 |         ll ans = Inf;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 156928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 156752 KB Output is correct
2 Incorrect 74 ms 156936 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 156756 KB Output is correct
2 Incorrect 72 ms 156756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 156928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 156928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 156928 KB Output isn't correct
2 Halted 0 ms 0 KB -