//暴力AC了 #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() {     int n,m;     while (cin >> n>>m)     {         int cnt = 1;         vector<pair<int, int>> higher;         vector<pair<int, int>> data;         while (n--)         {                          int high;             cin >> high;             pair<int,int> hh;             hh.first = high;             hh.second = cnt;             cnt++;             higher.push_back(hh);         }         sort(higher.begin(), higher.end());         int count = 0;         while (m--)         {             if ((higher.front().first == higher.back().first)&&                 ((higher.front().first+1) == higher.back().first))                 break;             pair<int, int> dd;             higher.back().first--;             higher.front().first++;             dd.first = higher.back().second;             dd.second = higher.front().second;             data.push_back(dd);             sort(higher.begin(), higher.end());             count++;         }         cout << higher.back().first - higher.front().first             << " " << count << endl;         for (auto i : data)         {             cout << i.first << " " << i.second << endl;         }     }     return 0; }
点赞 评论

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务