Submission #884258

#TimeUsernameProblemLanguageResultExecution timeMemory
884258abcvuitunggioRarest Insects (IOI22_insects)C++17
99.89 / 100
42 ms856 KiB
#include "insects.h" int state[2001],a[2001],cnt,cur; int min_cardinality(int n){ for (int i=0;i<n;i++){ move_inside(i); state[i]=1; a[i]=press_button(); if (a[i]>1){ move_outside(i); state[i]=0; } else cnt++; } cur=cnt; int l=2,r=n/cnt,kq=1; while (l<=r){ int mid=(l+r)>>1; int mx=0; for (int i=0;i<n;i++) if (state[i]&&a[i]>mid){ move_outside(i); cur--; state[i]=0; if (a[i]>mx) mx=a[i]; else a[i]=0; } for (int i=0;i<n;i++){ if (state[i]||a[i]>mid) continue; move_inside(i); a[i]=press_button(); if (a[i]>mid) move_outside(i); else{ cur++; state[i]=1; } } if (cur==mid*cnt){ kq=mid; l=mid+1; } else r=mid-1; } return kq; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...