Submission #1250735

#TimeUsernameProblemLanguageResultExecution timeMemory
1250735yeyso2Souvenirs (IOI25_souvenirs)C++20
3 / 100
12 ms412 KiB
#include "souvenirs.h" #include <utility> #include <vector> #include <bits/stdc++.h> using namespace std; void buy_souvenirs(int N, long long P0) { vector<int> P(N, 0); vector<int> quantity_owned(N, 0); P[0] = P0; int last_price = P0; for(int i = 1; i < N - 1; i ++){ while(quantity_owned[i] < i){ if(quantity_owned[i] == 0){ pair<vector<int>, long long> res = transaction(last_price - 1); // we bought the souvenir and have $1 leftover if(res.second == 1){ P[i] = last_price - 2; quantity_owned[i] ++; } // we bought the souvenir as well as the very last one as it happens to cost $1 if(res.first.size() > 1){ P[i] = last_price - 2; quantity_owned[i] ++; quantity_owned[N-1] ++; } // we bought only the souvenir and have nothing left if(res.second == 0 && res.first.size() == 1){ P[i] = last_price - 1; quantity_owned[i] ++; } last_price = P[i]; } else { pair<vector<int>, long long> res = transaction(P[i]); quantity_owned[i] ++; } } } /*for(int i = 0; i < (int)P.size(); i ++){ cout << P[i] << " "; }*/ while(quantity_owned[N-1] < N-1){ pair<vector<int>, long long> res = transaction(last_price - 1); quantity_owned[N-1] ++; } //pair<vector<int>, long long> res = transaction(P0 - 1); return; } /* #!/bin/bash task="souvenirs" grader_name="grader" g++ -std=gnu++20 -Wall -O2 -pipe -static -g -o main grader.cpp souvenirs.cpp 5 7 5 4 3 2 */
#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...