# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009204 | ivopav | Schools (IZhO13_school) | C++17 | 188 ms | 262144 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 <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
int main(){
// ios_base::sync_with_stdio(false);
//cin.tie(NULL);
long long int n;
long long int m;
long long int k;
cin >> n >> m >> k;
vector<long long int> gla={};
vector<long long int> spr={};
for (long long int i=0;i<n;i++){
long long int unos;
long long int unos2;
cin >> unos >> unos2;
gla.push_back(unos);
spr.push_back(unos2);
}
vector<vector<vector<long long int>>> dp(n+1,vector<vector<long long int>>(m+1,vector<long long int>(k+1,0)));
for (long long int i=0;i<n;i++){
for (long long int j=0;j<m+1;j++){
for (long long int l=0;l<k+1;l++){
// cout << i << " " << j << " " << l << " " << dp[i][j][l] << "\n";
dp[i+1][j][l]=max(dp[i][j][l],dp[i+1][j][l]);
if (j!=m){
dp[i+1][j+1][l]=max(dp[i][j][l]+gla[i],dp[i+1][j+1][l]);
}
if (l!=k){
dp[i+1][j][l+1]=max(dp[i][j][l]+spr[i],dp[i+1][j][l+1]);
}
}
}
}
cout << dp[n][m][k] << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |