답안 #1085262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085262 2024-09-07T19:07:37 Z CodeAssignment 메기 농장 (IOI22_fish) C++17
0 / 100
31 ms 7004 KB
#include "fish.h"
#include "bits/stdc++.h"
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define trav(a, x) for (auto &a : x)

using namespace std;

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
	ll m = M;
	ll ans = 0;
	if (count(all(Y), 0) == M) {
		vector<pair<ll, ll>> tmp(m);
		rep(i, 0, m) {
			tmp[i] = {X[i], W[i]};
		}
		sort(all(tmp));
		vector<int> w(m);
		rep(i, 0, m) w[i] = tmp[i].second;

		ll dp[m][2][2]; // [pos][include cur][pier]
		memset(dp, 0, sizeof(dp));
		rep(i, 1, m) {
			dp[i][1][1] = 0; // cant include cur and have pier on cur;
			dp[i][1][0] = max(dp[i-1][0][1], dp[i-1][1][1]) + w[i];
			dp[i][0][0] = max(dp[i-1][0][0], dp[i-1][1][0]);
			dp[i][0][1] = max({dp[i-1][0][0] + w[i-1], dp[i-1][0][1], dp[i-1][1][0], dp[i-1][1][1]});
		}
		rep(i, 0, 2) rep(j, 0, 2) {
			ans = max(dp[m-1][i][j], ans);
		}
	}
	else {
		rep(i, 0, m) {
			ans += W[i];	
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 3676 KB Output is correct
2 Correct 17 ms 4444 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 31 ms 7004 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 3676 KB Output is correct
2 Correct 17 ms 4444 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
4 Halted 0 ms 0 KB -