Submission #933812

# Submission time Handle Problem Language Result Execution time Memory
933812 2024-02-26T11:03:10 Z raul2008487 Boxes with souvenirs (IOI15_boxes) C++17
10 / 100
0 ms 352 KB
#include <bits/stdc++.h>
#include "boxes.h"
#define ll int
#define in insert
#define pb push_back
#define vl vector<ll>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;
const ll inf = 100000000000000000;
long long delivery(int N, int K, int L, int p[]) {
    ll n = N, k = K, ans = inf, i, j;
    vl dpp(n + 2), dps(n + 2);
    dpp[0] = dps[n + 1] = 0;
    for(i = 1; i <= n; i++){
        if(i > k){
            dpp[i] = dpp[i - k] + min(p[i - 1] * 2, L);
        }
        else{
            dpp[i] = min(p[i - 1] * 2, L);
        }
        //dpp[i] = dpp[pr] + p[i - 1] + min(L - p[i - 1], p[i - 1]);
    }
    for(i = n; i > 0; i--){
        ll nxt = min(i + k, n + 1);
        if((i + k) <= n){
            dps[i] = dps[i + k] + min(L, 2 * (L - p[i - 1]));
        }
        else{
            dps[i] = min(L, 2 * (L - p[i - 1]));
        }
        //dps[i] = dps[nxt] + (L - p[i - 1]) + min(L - p[i - 1], p[i - 1]);
    }
    for(i = 0; i <= n; i++){
        ans = min(ans, (dpp[i] + dps[i + 1]));
    }
    return ans;
}

Compilation message

boxes.cpp:12:16: warning: overflow in conversion from 'long int' to 'int' changes value from '100000000000000000' to '1569325056' [-Woverflow]
   12 | const ll inf = 100000000000000000;
      |                ^~~~~~~~~~~~~~~~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:27:12: warning: unused variable 'nxt' [-Wunused-variable]
   27 |         ll nxt = min(i + k, n + 1);
      |            ^~~
boxes.cpp:14:36: warning: unused variable 'j' [-Wunused-variable]
   14 |     ll n = N, k = K, ans = inf, i, j;
      |                                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -