Submission
Status:
(PPPPP-SSSSSSS)(PPPPPPPPP)(-SSSSSSSSS)(-SSSSSSSSS)(PP-SSSSSSSSSSS)(PP-SSSSSSSSSSSSSSSS)(PP-SSSSSSSSSSSSSSSSSSS)
Subtask/Task Score:
{0/4}{4/4}{0/5}{0/7}{0/25}{0/34}{0/21}
Score: 4
User: Trin1506
Problemset: ร้านปลอดภาษี (Duty Free)
Language: cpp
Time: 0.143 second
Submitted On: 2026-04-24 17:33:57
#include <vector>
using namespace std;
int minimum_bag_rearrangement_time(vector<int> a) {
int n = a.size();
vector<int> cnt(n + 1, 0);
for (int x : a) cnt[x]++;
int rounds = 0;
while(true){
int need = 1;
bool used_any = false;
for (int x = 1; x <= n; x++) {
while (cnt[x] > 0 && x >= need) {
cnt[x]--;
need++;
used_any = true;
}
}
if (!used_any) break;
rounds++;
}
return rounds - 1;
}