This Problem was very nice! Feeling Happy To Be Able To Solve By Myself

Правка en1, от deydhananjoy5, 2022-12-07 13:27:26

bool canISaveMidMice(int mid, vector<int>a, int n) { // 0 1 2 3 4 5 6 7 8 9 10 //1 2 3 4 5 6 7 | 8 9 10 11 //n = 11 int mouse = 0, sum = 0, ind = a.size() - mid ;//11 - 4 = 6 while(ind < a.size()) { if(mouse >= a[ind])return false; sum += (n - a[ind]); mouse += (n - a[ind]); ind++; } return true; } void solve() { int n, k; cin>>n>>k; _vi v(k); for(auto &it : v)cin>>it; sort(_a(v)); int l = 0, h = k; int ans = 0; while(l <= h) { int mid = l - ((l - h)/2); if(canISaveMidMice(mid, v, n) == false) { h = mid - 1; } else { ans = max(ans, mid); // debug(ans); l = mid + 1; } } cout<<ans<<endl; return; } [Problem Link](https://mirror.codeforces.com/problemset/problem/1593/C)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский deydhananjoy5 2022-12-07 13:29:11 131
en1 Английский deydhananjoy5 2022-12-07 13:27:26 954 Initial revision (published)