답안 #1055815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055815 2024-08-13T05:48:45 Z pawned 메기 농장 (IOI22_fish) C++17
3 / 100
48 ms 15700 KB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;

#include "fish.h"

ll max_weights(int N, int M, vector<int> X_g, vector<int> Y_g, vector<int> W_g) {
	vi a(N);
	for (int i = 0; i < M; i++) {
		a[X_g[i]] += W_g[i];
	}
/*	cout<<"a: ";
	for (ll x : a)
		cout<<x<<" ";
	cout<<endl;*/
	vi dp(N + 1, 0);
	// dp[i]: max sum till i, exclusive
	for (int i = 1; i <= N; i++) {
		dp[i] = dp[i - 1];
		if (i >= 2)
			dp[i] = max(dp[i], dp[i - 2] + a[i - 2]);
		if (i >= 3)
			dp[i] = max(dp[i], dp[i - 3] + a[i - 3] + a[i - 1]);
	}
	return dp[N];
}

// subtasks 1, 2: greedy
// subtask 3: dp

// code subtask 3 first to verify correct dp
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4956 KB Output is correct
2 Correct 14 ms 5912 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 48 ms 15192 KB Output is correct
6 Correct 47 ms 15700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Incorrect 9 ms 3932 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21049836049923'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Incorrect 9 ms 3932 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21049836049923'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4956 KB Output is correct
2 Correct 14 ms 5912 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 48 ms 15192 KB Output is correct
6 Correct 47 ms 15700 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -