제출 #800643

#제출 시각아이디문제언어결과실행 시간메모리
800643FEDIKUS버섯 세기 (IOI20_mushrooms)C++17
80.71 / 100
7 ms348 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int maxn=20010; int count_mushrooms(int n) { vector<int> aovi={0}; vector<int> bovi; int ret=1; for(int i=1;i<n;i++){ if(aovi.size()>=bovi.size()){ vector<int> tmp; for(int j=i;j<min(i+int(aovi.size()),n);j++){ tmp.push_back(aovi[j-i]); tmp.push_back(j); } int klkb=use_machine(tmp); i+=aovi.size()-1; if(klkb&1) bovi.push_back(tmp.back()); else aovi.push_back(tmp.back()); klkb=klkb/2+(klkb&1); int klka=tmp.size()/2-klkb; ret+=klka; }else{ vector<int> tmp; for(int j=i;j<min(i+int(bovi.size()),n);j++){ tmp.push_back(bovi[j-i]); tmp.push_back(j); } int klka=use_machine(tmp); i+=bovi.size()-1; if(klka&1) aovi.push_back(tmp.back()); else bovi.push_back(tmp.back()); klka=klka/2+(klka&1); ret+=klka; } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...