제출 #1258586

#제출 시각아이디문제언어결과실행 시간메모리
1258586Samuraj선물 (IOI25_souvenirs)C++20
67 / 100
12 ms412 KiB
#include "souvenirs.h" #include <bits/stdc++.h> using namespace std; #define st first #define nd second #define pb push_back #define rep(i,a,b) for(int i = a; i <= b; i++) #define irep(i,a,b) for(int i = a; i >= b; i--) typedef long long ll; typedef long double ld; //typedef __int128 int128; typedef vector<int> vi; typedef pair<int,int> pi; typedef pair<double,double> pd; typedef pair<ll,ll> pl; const int max_n = 107; int ile[max_n]; ll c[max_n]; void get_c(int n, ll val){ //cout << "get_c, val: " << val << '\n'; pair<vi,ll> v = transaction(val); for(auto x:v.st) ile[x]++; ll whole_cost = val-v.nd; //cout << "whole_cost: " << whole_cost << " v.st: "; //for(auto x:v.st) cout << x << ' '; //cout << '\n'; if(v.st.size() == 1){ //cout << "size = 1\n"; c[v.st[0]] = whole_cost; if(v.st[0] != n-1) get_c(n,whole_cost-1); return; } //dopoki nie mamy kolejnego kosztu! while(!c[v.st[1]]){ ll s = 0; ll x = whole_cost; for(auto x:v.st){ if(c[x]) x -= c[x]; else s++; } //cout << "petla dla val: " << val << " s: " << s << " x: " << x << '\n'; ll max_a = ((x-s*(s-1)/2)/s); get_c(n,max_a); } for(auto x:v.st) whole_cost -= c[x]; c[v.st[0]] = whole_cost; if(!c[v.st[0]+1] && v.st[0] != n-1) get_c(n,c[v.st[0]]-1); return; } void buy_souvenirs(int n, ll p0){ get_c(n,p0-1); rep(i,1,n-1){ //cout << "i: " << i << " c: " << c[i] << '\n'; while(ile[i] < i){ ile[i]++; transaction(c[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...