제출 #1319351

#제출 시각아이디문제언어결과실행 시간메모리
1319351Trisanu_Das선물 (IOI25_souvenirs)C++20
4 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; #include "souvenirs.h" void buy_souvenirs(int N, long long P0) { vector<long long> P(N, -1); vector<long long> got(N, 0); P[0] = P0; for (int i = N - 1; i >= 1; --i) { long long S = 0; for (int j = i + 1; j < N; ++j) { if (P[j] != -1) S += (long long)(j - i) * P[j]; } long long M = P0 - 1 - S; if (M < 0) M = 0; auto result = transaction(M); auto &L = result.first; long long R = result.second; long long paid = M - R; long long known_sum = 0; vector<bool> inL(N, false); for (int t : L) { inL[t] = true; got[t]++; } for (int j = i + 1; j < N; ++j) if (inL[j] && P[j] != -1) known_sum += P[j]; long long Pi = paid - known_sum; P[i] = Pi; } for (int i = 1; i < N; ++i) { long long need = i - got[i]; while (need > 0) { transaction(P[i]); --need; } } }
#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...