研发笔试第二题 #include<bits/stdc++.h> using namespace std; int main() { int K, N = 0; int g_i = 0; int count = 0; cin >> N >> K; vector<int>g; while (N--) { cin >> g_i; g.push_back(g_i); } sort(g.rbegin(), g.rend()); while (g[K - 1] > 0) { for (int i = 0; i < K; i++) { g[i] -= 1; } count++; sort(g.rbegin(), g.rend()); } cout << count; system("pause"); return 0; }
点赞 10

相关推荐

牛至超人:把哈工大,再加大加粗,看见闪闪发光的哈工大字样,面试官直接流口水
投递字节跳动等公司6个岗位
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务