제출 #558604

#제출 시각아이디문제언어결과실행 시간메모리
558604n0sk1llBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
1 ms340 KiB
#include "boxes.h"
#include <bits/stdc++.h>

using namespace std;
long long int typedef li;

list<int> poz;

long long delivery(int n, int k, int s, int p[])
{
    sort(p,p+n);
    for (int i=0;i<n;i++) poz.push_back(p[i]);

    li ret=0;
    while (!poz.empty())
    {
        if (poz.front()<s-poz.back())
        {
            int aman=0;
            for (int i=0;i<k;i++)
            {
                aman=poz.front();
                poz.pop_front();
                if (poz.empty() || aman+s-poz.back()<poz.front()-aman) break;
            }
            ret+=min(s,2*aman);
        }
        else
        {
            int aman=0;
            for (int i=0;i<k;i++)
            {
                aman=s-poz.back();
                poz.pop_back();
                if (poz.empty() || aman+poz.front()<s-aman-poz.back()) break;
            }
            ret+=min(s,2*aman);
        }
    }

    return ret;
}
#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...