这是一个测试
做测试
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" struct pos { int day, night; }; bool cmp(pos a, pos b) { return a.night - a.day > b.night - b.day; } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n, k; cin >> n >> k; vector<pos>a(n + 1); for (int i = 1; i <= n; i++)cin >> a[i].day >> a[i].night; sort(a.begin() + 1, a.end(), cmp); ll ans = 0; int cnt = 0; for (int i = 1; i <= n; i++) { if (cnt <= k) { ans += a[i].night; } else { ans += a[i].day; } cnt++; } cout << ans; return 0; }
标签:int,ll,pos,测试,night,day From: https://www.cnblogs.com/zhujio/p/17215704.html