# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
725533 |
2023-04-17T15:06:10 Z |
vjudge1 |
Schools (IZhO13_school) |
C++17 |
|
2000 ms |
15844 KB |
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ld long double
#define ll long long
#define S second
#define F first
using namespace __gnu_pbds;
using namespace std;
typedef tree<long long, null_type, less_equal<long long>,
rb_tree_tag, tree_order_statistics_node_update> Tree;
const ll INF = 9223372036854775807LL;
const ll inf = 2147483647;
const ll MAXN = 300010;
const ll MOD = 1e9 + 7;
const ld PI = acos(-1);
const ll NROOT = 320;
ll binpow(ll a, ll b) {
ll res = 1;
for (;b; b /= 2, a *= a, a %= MOD)
if (b & 1) res *= a, res %= MOD;
return res % MOD;
}
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll invmod(ll a) {return binpow(a, MOD - 2);}
vector<pair<int, int>> v(MAXN);
int dp(int i, int M, int S, int m, int s) {
if (S == s && m == M) return 0;
int ans = 0;
if (M > m) ans = max(ans, dp(i + 1, M, S, m + 1, s) + v[i].F);
if (S > s) ans = max(ans, dp(i + 1, M, S, m, s + 1) + v[i].S);
return ans;
}
int32_t main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, s; cin >> n >> m >> s;
for (int i = 1; i <= n; i ++) {
cin >> v[i].F >> v[i].S;
}
sort(v.rbegin(), v.rend());
int ans = dp(0, m, s, 0, 0);
for (int i = 0; i < n; i ++)
swap(v[i].F, v[i].S);
sort(v.rbegin(), v.rend());
ans = max(ans, dp(0, s, m, 0, 0));
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2644 KB |
Output is correct |
2 |
Correct |
14 ms |
2644 KB |
Output is correct |
3 |
Correct |
14 ms |
2644 KB |
Output is correct |
4 |
Execution timed out |
2073 ms |
2644 KB |
Time limit exceeded |
5 |
Incorrect |
199 ms |
2644 KB |
Output isn't correct |
6 |
Execution timed out |
2080 ms |
2676 KB |
Time limit exceeded |
7 |
Execution timed out |
2071 ms |
2644 KB |
Time limit exceeded |
8 |
Execution timed out |
2059 ms |
2900 KB |
Time limit exceeded |
9 |
Execution timed out |
2079 ms |
2932 KB |
Time limit exceeded |
10 |
Execution timed out |
2064 ms |
2900 KB |
Time limit exceeded |
11 |
Execution timed out |
2041 ms |
2900 KB |
Time limit exceeded |
12 |
Execution timed out |
2055 ms |
2812 KB |
Time limit exceeded |
13 |
Execution timed out |
2049 ms |
4692 KB |
Time limit exceeded |
14 |
Execution timed out |
2062 ms |
4464 KB |
Time limit exceeded |
15 |
Execution timed out |
2058 ms |
3020 KB |
Time limit exceeded |
16 |
Execution timed out |
2061 ms |
13808 KB |
Time limit exceeded |
17 |
Execution timed out |
2077 ms |
14452 KB |
Time limit exceeded |
18 |
Execution timed out |
2070 ms |
13456 KB |
Time limit exceeded |
19 |
Execution timed out |
2072 ms |
14704 KB |
Time limit exceeded |
20 |
Execution timed out |
2083 ms |
15844 KB |
Time limit exceeded |