답안 #1056574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056574 2024-08-13T10:08:18 Z dozer 메기 농장 (IOI22_fish) C++17
0 / 100
25 ms 8880 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define ll long long
#define LL node * 2
#define RR node * 2 + 1
#define MAXN 300005

const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;

ll dp[2][MAXN], arr[MAXN];

long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
	int n = N, m = M;
    vector<array<int, 3>> v;
    for (int i = 0; i < m; i++) arr[X[i]] = W[i];
   	dp[0][0] = 0;
 	dp[1][0] = arr[0];
 	for (int i = 1; i < N; i++){
 		dp[0][i] = max(dp[0][i - 1], dp[1][i - 1]);
 		dp[1][i] = arr[i] + dp[0][i - 1];
 	}

 	return max(dp[0][N - 1], dp[1][N - 1]);

}

/*

int main() {
	fileio();
	int N, M;
	assert(2 == scanf("%d %d", &N, &M));

	std::vector<int> X(M), Y(M), W(M);
	for (int i = 0; i < M; ++i) {
		assert(3 == scanf("%d %d %d", &X[i], &Y[i], &W[i]));
	}

	long long result = max_weights(N, M, X, Y, W);
	printf("%lld\n", result);
	return 0;
}
*/

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:23:6: warning: unused variable 'n' [-Wunused-variable]
   23 |  int n = N, m = M;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 6236 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Incorrect 9 ms 8880 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Incorrect 9 ms 8880 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 6236 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -