Submission
Status:
(P-SSSSSSSSSSS)(P-SSSSSSS)(-SSSSSSSSS)(-SSSSSSSSS)(-SSSSSSSSSSSSS)(TSSSSSSSSSSSSSSSSSS)(TSSSSSSSSSSSSSSSSSSSSS)
Subtask/Task Score:
{0/4}{0/4}{0/5}{0/7}{0/25}{0/34}{0/21}
Score: 0
User: GGEZLOLx3D
Problemset: ร้านปลอดภาษี (Duty Free)
Language: cpp
Time: 1.093 second
Submitted On: 2026-03-26 17:47:16
#include<bits/stdc++.h>
#include "duty_free.h"
using namespace std;
// you can write more function here
map<int,bool> mp;
int minimum_bag_rearrangement_time(std::vector<int> max_allowed_positions) {
int n=max_allowed_positions.size();
vector<int> res;
int c=0,i,j;
for(i=0;i<n;i++){
if(!mp[max_allowed_positions[i]]){
mp[max_allowed_positions[i]]=true;
res.push_back(max_allowed_positions[i]);
}
else{
bool ch=false;
for(j=max_allowed_positions[i]-1;j>=1;j--){
if(!mp[j]){
mp[j]=true;
res.push_back(j);
ch=true;
break;
}
}
if(ch){
continue;
}
else{
c++;
for(j=0;j<res.size();j++){
mp[j]=true;
}
res.clear();
}
}
}
return c;
}