QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149593#2785. Boxes with souvenirsAbdelmagedNour#Compile Error//C++20506b2023-08-24 22:32:332023-08-24 22:32:36

Judging History

你现在查看的是测评时间为 2023-08-24 22:32:36 的历史记录

  • [2024-07-04 01:51:30]
  • 管理员手动重测该提交记录
  • 测评结果:10
  • 用时:0ms
  • 内存:4068kb
  • [2023-08-24 22:32:36]
  • 评测
  • [2023-08-24 22:32:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//#include "grader.cpp"
#include "boxes.h"

long long delivery(int N, int K, int L, int p[]){
    vector<long long>pre(K+1),suf(K+1);
    long long res=LLONG_MAX;
    for(int i=K-1;i<N;i++)suf[i%K]+=L-p[i];
    for(int i=K-1;i<N;i++){
        int l=p[i-K+1],r=p[i];
        suf[i%K]-=L-p[i];
        if(i>=K)pre[i%K]+=p[i-K];
        int cost=min({L,2*r,2*(L-l)});
        res=min(res,cost+2*pre[i%K]+2*suf[(i+1)%K]);
    }
    return res;
}

Details

cc1plus: fatal error: implementer.cpp: No such file or directory
compilation terminated.