Submission #432067

# Submission time Handle Problem Language Result Execution time Memory
432067 2021-06-17T20:14:57 Z peuch Carnival Tickets (IOI20_tickets) C++17
0 / 100
1 ms 204 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;


long long find_maximum(int k, vector<vector<int> > x) {
	
	int n = x.size();
	int m = x[0].size();
	
	vector<int> dp (n);
	vector<vector<bool> > bt (n, vector<bool> (n, 0));
	vector<vector<pair<int, int> > > ord (n, vector<pair<int, int> > (m));
	vector<vector<int> > ans (n, vector<int> (m, -1));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++)
			ord[i][j] = make_pair(x[i][j], j);
		sort(ord[i].begin(), ord[i].end());
//		printf("Para pilha %d, fundo = %d, topo = %d\n", i, ord[i][0].first, ord[i][m - 1].first);
	}
	
	for(int i = 0; i < n; i++){
		for(int j = n / 2; j >= 0; j--){
			dp[j] = dp[j] - ord[i][0].first;
			if(j != 0 && dp[j - 1] + ord[i][m - 1].first > dp[j]) dp[j] = dp[j - 1] + ord[i][m - 1].first, bt[i][j] = 1;
//			printf("dp[%d][%d] = %d\n", i, j, dp[j]);
		}
	}
	
	int curI = n - 1, curJ = n / 2;
	while(curI >= 0){
		if(bt[curI][curJ]) curJ--, ans[curI][ord[curI][m - 1].second] = 0;
		else ans[curI][ord[curI][0].second] = 0;
		curI--;
	}
	
	allocate_tickets(ans);
	return dp[n / 2];	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Contestant returned 18919508441 but the tickets gives a total value of 1035741873
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Contestant returned 1891298252 but the tickets gives a total value of 1689590890
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB There is no ticket of color 0 on day 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB There is no ticket of color 0 on day 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB There is no ticket of color 0 on day 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB There is no ticket of color 0 on day 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Contestant returned 18919508441 but the tickets gives a total value of 1035741873
5 Halted 0 ms 0 KB -