Advertisement
OIQ

Untitled

OIQ
Nov 27th, 2019
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <utility>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10.     int n, t;
  11.  
  12.     cin >> n >> t;
  13.  
  14.  
  15.     vector <pair<int, int>> v;
  16.  
  17.     for (int i = 0; i < n; i++) {
  18.         int a, b;
  19.  
  20.         cin >> a >> b;
  21.         v.push_back(pair<int, int>(a + b, i + 1));
  22.     }
  23.  
  24.     sort(v.begin(), v.end());
  25.  
  26.     int ans = 0;
  27.  
  28.     for (int i = 0; i < t; i++) {
  29.         ans += v[i].first;
  30.     }
  31.  
  32.     cout << ans << endl;
  33.     vector <int> pos;
  34.     for (int i = 0; i < t; i++) {
  35.         pos.push_back(v[i].second);
  36.     }
  37.  
  38.     sort(pos.begin(), pos.end());
  39.  
  40.     for (int i = 0; i < pos.size(); i++)
  41.         cout << pos[i] << " ";
  42.  
  43.  
  44.     return 0;
  45. }
Advertisement
RAW Paste Data Copied
Advertisement