Advertisement
YEZAELP

C. Save More Mice

Oct 29th, 2021
1,083
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using lli = long long;
  5.  
  6. void Solve(){
  7.     int n, k;
  8.     scanf("%d%d", &n, &k);
  9.     int ar[k + 1];
  10.     for(int i=1;i<=k;i++)
  11.         scanf("%d", &ar[i]);
  12.     sort(ar + 1, ar + k + 1);
  13.     int cnt = 0;
  14.     lli dis = 0;
  15.     for(int i=k;i>=1;i--){
  16.         if((lli) ar[i] > dis) cnt ++;
  17.         dis += (lli)(n - ar[i]);
  18.     }
  19.     printf("%d\n", cnt);
  20. }
  21.  
  22. int main(){
  23.  
  24.     int Q;
  25.     scanf("%d", &Q);
  26.  
  27.     while(Q --){
  28.         Solve();
  29.     }
  30.  
  31.     return 0;
  32. }
Advertisement
RAW Paste Data Copied
Advertisement