This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long delivery(int nbEquipes, int maxPorte, int nbSections, int positions[]) {
vector<long long> tempsAvant(nbEquipes, 0), tempsApres(nbEquipes, 0);
sort(positions, positions + nbEquipes);
int nbPorte = 0;
long long curSomme = 0;
for(int iEquipe = 0;iEquipe < nbEquipes;iEquipe++) {
int allerRetour = min(nbSections, 2 * positions[iEquipe]);
tempsAvant[iEquipe] = curSomme + allerRetour;
nbPorte++;
if(nbPorte == maxPorte) {
curSomme += allerRetour;
nbPorte = 0;
}
}
nbPorte = 0;
curSomme = 0;
for(int iEquipe = nbEquipes - 1;iEquipe >= 0;iEquipe--) {
int allerRetour = min(nbSections, 2 * (nbSections - positions[iEquipe]));
tempsApres[iEquipe] = curSomme + allerRetour;
nbPorte++;
if(nbPorte == maxPorte) {
curSomme += allerRetour;
nbPorte = 0;
}
}
long long minTemps = min(tempsAvant[nbEquipes - 1], tempsApres[0]);
for(int iEquipe = 0;iEquipe < nbEquipes - 1;iEquipe++) {
minTemps = min(minTemps, tempsAvant[iEquipe] + tempsApres[iEquipe + 1]);
}
return minTemps;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |