Advertisement
Ritam_C

codeforces AccidentalVictory

Feb 17th, 2021
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ull unsigned long long int
  4. #define ld long double
  5. #define pb push_back
  6. #define p_b pop_back
  7. #define si stack<int>
  8. #define sll stack<ll>
  9. #define sc stack<char>
  10. #define vi vector<int>
  11. #define vll vector<ll>
  12. #define mii map<int, int>
  13. #define msi map<string, int>
  14. #define mci map<char, int>
  15. #define qc queue<char>
  16. #define qi queue<int>
  17. #define qll queue<ll>
  18. using namespace std;
  19.  
  20. int main(){
  21.     ios_base::sync_with_stdio(false);
  22.     cin.tie(NULL);
  23.     int t;
  24.     cin >> t;
  25.     while(t--){
  26.         int n;
  27.         cin >> n;
  28.         map<ll, int> m;
  29.         set<ll> s;
  30.         vll v;
  31.         for(int i = 0; i < n; i++){
  32.             ll a;
  33.             cin >> a;
  34.             m[a]++;
  35.             v.pb(a);
  36.         }
  37.  
  38.         if(n == 1){
  39.             cout << "1\n";
  40.             cout << v[0] << "\n";
  41.         } else{
  42.             ll sum = 0, p = 0, tot = 0;;
  43.             for(auto i = m.begin(); i != m.end()--; i++){
  44.                 auto k = i;
  45.                 k++;
  46.                 if((i->first)*(i->second)+sum < k->first){
  47.                     p = i->first;
  48.                     tot += i->second;
  49.                 }
  50.  
  51.                 sum += (i->first)*(i->second);
  52.             }
  53.  
  54.             cout << n-tot << "\n";
  55.             for(int i = 1; i <= n; i++){
  56.                 if(v[i-1] > p){
  57.                     cout << i << " ";
  58.                 }
  59.             }
  60.             cout << "\n";
  61.         }
  62.     }
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement