Submission #422121

#TimeUsernameProblemLanguageResultExecution timeMemory
422121MarcoMeijerBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms300 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll delivery(int n, int k, int l, int p[]) {
    int i=0;
    ll ans = 0;
    while(i < n) {
        int bg = p[i], ed;
        RE(j,k) {
            if(i == n)
                break;
            ed = p[i++];
        }
        ll add = l;
        add = min(add, ed*2ll);
        add = min(add, l*2ll - bg*2ll);
        ans += add;
    }
    return ans;
}

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:43:24: warning: 'ed' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |         add = min(add, ed*2ll);
      |                        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...