답안 #889743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889743 2023-12-20T06:41:48 Z UmairAhmadMirza Aliens (IOI16_aliens) C++14
0 / 100
1 ms 600 KB
#pragma once

#include <bits/stdc++.h>
using namespace std;
int const N=505;
long long const inf=1e9;
long long dp[N][N];
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){
	for (int i = 1; i <=n; ++i)
		for(int j = 0; j <=k; ++j)
			dp[i][j]=inf;
	vector<long long> v;
	v.push_back(r[0]);
	for (int i = 1; i < n; ++i)
		if(r[i]!=r[i-1])
			v.push_back(r[i]);
	n=v.size();
	dp[0][0]=0;
	k=min(n,k);
	for (int i = 1; i <=n; ++i){
		for(int j = 1; j <=k; ++j){
			dp[i][j]=dp[i][j-1];
			for (int ii = 0; ii < i; ++ii){
				long long sm=(abs(v[i-1]-v[ii])+1);
				sm*=sm;
				dp[i][j]=min(dp[i][j],dp[ii][j-1]+sm);
			}
		}
	}
	return dp[n][k];
}

Compilation message

aliens.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct answer: answer = 1
2 Correct 0 ms 344 KB Correct answer: answer = 4
3 Correct 1 ms 348 KB Correct answer: answer = 1
4 Incorrect 0 ms 600 KB Wrong answer: output = 2, expected = 5
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -