Submission #756379

# Submission time Handle Problem Language Result Execution time Memory
756379 2023-06-11T16:12:12 Z Olympia Schools (IZhO13_school) C++17
30 / 100
157 ms 262144 KB
#include <vector>
#include <iostream>
#include <cassert>
#include <random>
#include <cmath>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
using namespace std;
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M, S;
    cin >> N >> M >> S;
    vector<pair<int64_t,int64_t>> vec(N);
    for (int i = 0; i < N; i++) {
    	cin >> vec[i].first >> vec[i].second;
    }
    int64_t dp[N + 1][M + 1][S + 1];
    for (int n = 0; n <= N; n++) {
    	for (int m = 0; m <= M; m++) {
    		for (int s = 0; s <= S; s++) {
    			if (n == 0 and m == 0 and s == 0) {
    				dp[n][m][s] = 0;
    			} else if (n == 0) {
    				dp[n][m][s] = -(int64_t)1e17;
    			} else {
    				dp[n][m][s] = dp[n - 1][m][s];
    			}
    			if (n != 0 and m != 0) {
    				dp[n][m][s] = max(dp[n][m][s], dp[n - 1][m - 1][s] + vec[n - 1].first);
    			} 
    			if (n != 0 and s != 0) {
    				dp[n][m][s] = max(dp[n][m][s], dp[n - 1][m][s - 1] + vec[n - 1].second);
    			}
    			//cout << n << " " << m << " " << s << " " << dp[n][m][s] << endl;
    		}
    	}
    }
    cout << dp[N][M][S] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 232 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 6 ms 6740 KB Output is correct
7 Runtime error 118 ms 262144 KB Execution killed with signal 9
8 Runtime error 110 ms 262144 KB Execution killed with signal 9
9 Runtime error 110 ms 262144 KB Execution killed with signal 9
10 Runtime error 105 ms 262144 KB Execution killed with signal 9
11 Runtime error 112 ms 262144 KB Execution killed with signal 9
12 Runtime error 118 ms 262144 KB Execution killed with signal 9
13 Runtime error 110 ms 262144 KB Execution killed with signal 9
14 Runtime error 114 ms 262144 KB Execution killed with signal 9
15 Runtime error 134 ms 262144 KB Execution killed with signal 9
16 Runtime error 130 ms 262144 KB Execution killed with signal 9
17 Runtime error 153 ms 262144 KB Execution killed with signal 9
18 Runtime error 137 ms 262144 KB Execution killed with signal 9
19 Runtime error 141 ms 262144 KB Execution killed with signal 9
20 Runtime error 157 ms 262144 KB Execution killed with signal 9