제출 #1258012

#제출 시각아이디문제언어결과실행 시간메모리
1258012avighna선물 (IOI25_souvenirs)C++20
21 / 100
12 ms400 KiB
#include <cassert> #include <utility> #include <vector> std::pair<std::vector<int>, long long> transaction(long long M); void buy_souvenirs(int N, long long P0) { std::vector<int> have(N); // for each type we want have[i] == i std::vector<long long> a(N); // retreived array a[0] = P0; for (int i = 1; i < N; ++i) { if (have[i] == i) { continue; } auto [got, rem] = transaction(a[i - 1] - 1); // it can either be -1 or -2 if (rem == 0) { // it was -1, or it could be -2 and the last element is 1 a[i] = a[i - 1] - 1 - (got.size() > 1 and got.back() == N - 1); } else { a[i] = a[i - 1] - 2; // it was -2 } for (int &x : got) { have[x]++; } while (have[i] < i) { transaction(a[i]); have[i]++; } } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...