Submission #1009212

#TimeUsernameProblemLanguageResultExecution timeMemory
1009212ivopavSchools (IZhO13_school)C++17
30 / 100
2102 ms262144 KiB
#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<long long int>> dp(m+1,vector<long long int>(k+1,0)); vector<vector<long long int>> dp2(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"; dp2[j][l]=max(dp[j][l],dp2[j][l]); if (j!=m){ dp2[j+1][l]=max(dp[j][l]+gla[i],dp2[j+1][l]); } if (l!=k){ dp2[j][l+1]=max(dp[j][l]+spr[i],dp2[j][l+1]); } } } dp=dp2; } cout << dp2[m][k] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...