Submission

Status:

(PPP-SSSSSSSSS)(-SSSSSSSS)(PP-SSSSSSS)(PP-SSSSSSS)(PP-SSSSSSSSSSS)(PPP-SSSSSSSSSSSSSSS)(PPP-SSSSSSSSSSSSSSSSSS)

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: 0.173 second

Submitted On: 2026-03-26 17:57:17

#include<bits/stdc++.h>
#include "duty_free.h"
using namespace std;

// you can write more function here
int minimum_bag_rearrangement_time(std::vector<int> max_allowed_positions) {
    int n=max_allowed_positions.size();
    vector<bool> mp(n+1,false);
    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];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[res[j]]=false;

                }
                res.clear();
            }
        }

    }
  return c;
}