Submission #1247044

#TimeUsernameProblemLanguageResultExecution timeMemory
1247044nikulid버섯 세기 (IOI20_mushrooms)C++20
0 / 100
0 ms404 KiB
#include "mushrooms.h" using namespace std; #define pb push_back int count_mushrooms(int n) { int answer; int cnt0=1, cnt1=0; vector<int> ones, zeros={0}; vector<int> m = {0}; for(int i=1; i<min(100, n); i++){ m.pb(i); if(use_machine(m)){ ones.pb(i); cnt1++; } else{ zeros.pb(i); cnt0++; } m = {0}; } int next_unknown = 100; if(cnt0 >= cnt1){ answer = n-cnt1; while(next_unknown < n){ m = {zeros[0]}; for(int i=1; i<cnt0; i++){ if(next_unknown >= n)break; m.pb(next_unknown); m.pb(zeros[i]); next_unknown++; } answer -= use_machine(m)/2; } return answer; } else{ answer = cnt0; while(next_unknown < n){ m = {ones[0]}; for(int i=1; i<cnt1; i++){ if(next_unknown >= n)break; m.pb(next_unknown); m.pb(ones[i]); } answer += use_machine(m)/2; } return answer; } }
#Verdict Execution timeMemoryGrader output
Fetching results...