답안 #207756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207756 2020-03-08T20:04:32 Z super_j6 Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
70 ms 129404 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<long long, long long>
#define f first
#define s second

const long long inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 202;
int n, m;
pi a[maxn];
long long dp[maxn][maxn][maxn][2];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++) cin >> a[i].f;
	for(int i = 1; i <= n; i++) cin >> a[i].s;
	a[n + 1].f = m;
	sort(a + 1, a + n + 1);
	
	int ret = 0;
	memset(dp, inf, sizeof(dp));
	dp[0][0][n + 1][0] = dp[0][0][n + 1][1] = 0;
	for(int i = 0; i <= n; i++)
	for(int j = 0; j <= n; j++)
	for(int k = n + 1; k > j; k--){
		if(dp[i][j][k][0] != inf){
			ret = i;
			dp[i][j + 1][k][0] = min(dp[i][j + 1][k][0], dp[i][j][k][0] + a[j + 1].f - a[j].f);
			dp[i][j][k - 1][1] = min(dp[i][j][k - 1][1], dp[i][j][k][0] + a[j].f + m - a[k - 1].f);
		}
		if(dp[i][j][k][1] != inf){
			ret = i;
			dp[i][j][k - 1][1] = min(dp[i][j][k - 1][1], dp[i][j][k][1] + a[k].f - a[k - 1].f);
			dp[i][j + 1][k][0] = min(dp[i][j + 1][k][0], dp[i][j][k][1] + a[j + 1].f + m - a[k].f);
		}
		if(min(dp[i][j][k][0], dp[i][j][k][1]) != inf){
			if(dp[i][j + 1][k][0] <= a[j + 1].s) dp[i + 1][j + 1][k][0] = min(dp[i + 1][j + 1][k][0], dp[i][j + 1][k][0]);
			if(dp[i][j][k - 1][1] <= a[k - 1].s) dp[i + 1][j][k - 1][1] = min(dp[i + 1][j][k - 1][1], dp[i][j][k - 1][1]);
		}
	}
	
	cout << ret << endl;

	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:29:28: warning: overflow in implicit constant conversion [-Woverflow]
  memset(dp, inf, sizeof(dp));
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 129272 KB Output is correct
2 Correct 67 ms 129400 KB Output is correct
3 Correct 70 ms 129400 KB Output is correct
4 Correct 66 ms 129400 KB Output is correct
5 Correct 65 ms 129404 KB Output is correct
6 Correct 65 ms 129400 KB Output is correct
7 Incorrect 66 ms 129376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 129272 KB Output is correct
2 Correct 67 ms 129400 KB Output is correct
3 Correct 70 ms 129400 KB Output is correct
4 Correct 66 ms 129400 KB Output is correct
5 Correct 65 ms 129404 KB Output is correct
6 Correct 65 ms 129400 KB Output is correct
7 Incorrect 66 ms 129376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 129272 KB Output is correct
2 Correct 67 ms 129400 KB Output is correct
3 Correct 70 ms 129400 KB Output is correct
4 Correct 66 ms 129400 KB Output is correct
5 Correct 65 ms 129404 KB Output is correct
6 Correct 65 ms 129400 KB Output is correct
7 Incorrect 66 ms 129376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 129272 KB Output is correct
2 Correct 67 ms 129400 KB Output is correct
3 Correct 70 ms 129400 KB Output is correct
4 Correct 66 ms 129400 KB Output is correct
5 Correct 65 ms 129404 KB Output is correct
6 Correct 65 ms 129400 KB Output is correct
7 Incorrect 66 ms 129376 KB Output isn't correct
8 Halted 0 ms 0 KB -