# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120030 | kirakosyan | Schools (IZhO13_school) | C++17 | 2098 ms | 9364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<random>
#include<cmath>
#include<stack>
#include<map>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;
ll pv(ll a, ll b) {
if (b == 0)return 1;
ll res = (pv(a, b / 2));
if (b % 2) {
return (((res * res) % mod) * (a % mod)) % mod;
}
else {
return (res * res) % mod;
}
}
vector<ll>a, b;
vector<vector<ll>>gp;
ll f = 0;
const ll N = 1e7 + 5;
// dp=vector<ll>(max(sum,(1ll<<m))+5);
void solve() {
ll n, m, s; cin >> n >> m >> s;
vector<ll>v(n), a(n);
for (ll i = 0; i < n; i++) {
cin >> v[i] >> a[i];
}
ll mx = 0;
for (ll i = 1; i < (1 << n); i++){
vector<ll>a1, v1;
for (ll j = 0; j < n; j++) {
if (i & (1 << j)) {
//sum += a[j];
//vis[j] = 1;
v1.push_back(v[j]);
}
else a1.push_back(a[j]);
}
sort(v1.rbegin(), v1.rend());
sort(a1.rbegin(), a1.rend());
ll sum = 0;
for (ll j = 0; j < min(m,ll(v1.size())); j++) {
sum += v1[j];
}
for (ll j = 0; j < min(s,ll(a1.size())); j++) {
sum += a1[j];
}
mx = max(mx, sum);
}
cout << mx << endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cin.tie(nullptr);
ll _ = 1;
// cin >> _;
while (_--)
{
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |