Submission #1064230

#TimeUsernameProblemLanguageResultExecution timeMemory
1064230p4r4d0_xSchools (IZhO13_school)C++17
10 / 100
103 ms32596 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define PUT(a, b) freopen(a, "r", stdin); freopen(b, "w", stdout); #define all(a) a.begin(), a.end() #define answerNO {cout << "NO" << endl; return;} #define answerYES {cout << "YES" << endl; return;} using namespace std; #define ff first #define ss second #define pb push_back #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ll mod = 1e9 + 7; void solve(){ ll n, m, s; cin >> n >> m >> s; vector<pair<pair<ll, ll>, int>> a(n), b(n); rep(i, n){ cin >> a[i].ff.ff >> a[i].ff.ss; b[i].ff.ff = a[i].ff.ss; b[i].ff.ss = a[i].ff.ff; a[i].ss = i; b[i].ss = i; } sort(all(a)); sort(all(b)); reverse(all(a)); reverse(all(b)); vector<bool> vis(1e5 + 26, 0); ll ans1 = 0, ans2 = 0; replr(i, 0, m - 1){ ans1 += a[i].ff.ff; vis[a[i].ss] = 1; } ll cnt = 0; rep(i, n){ if(!vis[b[i].ss] && cnt < s){ ans1 += b[i].ff.ff; cnt++; } } vis = vector<bool>(1e5 + 26, 0); replr(i, 0, s - 1){ ans2 += b[i].ff.ff; vis[b[i].ss] = 1; } cnt = 0; rep(i, n){ if(cnt < m && !vis[a[i].ss]){ ans2 += a[i].ff.ff; cnt++; } } cout << max(ans1, ans2) << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); //PUT("traffic.in", "traffic.out"); int t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...