제출 #1143185

#제출 시각아이디문제언어결과실행 시간메모리
1143185Sang선물상자 (IOI15_boxes)C++20
0 / 100
0 ms328 KiB
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define task "kbsiudthw"

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;

const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 2277;



long long delivery(int N, int K, int L, int p[]) {
    int re = N % K;
    if (re == 0){
        int ans = 0;
        for (int i = K; i <= N; i += K){
            ans += min({p[i-1]*2, L, 2 * (L - p[i-K])});
        }
        return ans;
    }
    int c1 = min({p[re - 1] * 2, L, 2 * (L - p[0])});
    int c2 = min({p[N-1]*2, L, 2 * (L - p[N-re])});
    if (c1 > c2){
        int ans = c2;
        for (int i = K; i <= N - re; i += K){
            ans += min({p[i-1]*2, L, 2 * (L - p[i-K])});
        }
        return ans;
    }
    int ans = c1;
    for (int i = K + re; i <= N; i += K){
        ans += min({p[i-1]*2, L, 2 * (L - p[i-K])});
    }
    return ans;
}

//signed main(){
//    ios_base::sync_with_stdio(0);
//    cin.tie(0); cout.tie(0);
//    if (fopen(task".inp", "r")){
//        freopen(task".inp", "r", stdin);
//        freopen(task".out", "w", stdout);
//    }
//    int p[] = {1, 2, 5};
//    cout << delivery(3, 2, 8, p);
//
//    return 0;
//}
#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...