QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#675776#9442. Music GameZvezdy#WA 10ms89916kbC++141.1kb2024-10-25 19:22:232024-10-25 19:22:24

Judging History

你现在查看的是最新测评结果

  • [2024-10-25 19:22:24]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:89916kb
  • [2024-10-25 19:22:23]
  • 提交

answer

#include<bits/stdc++.h>

const int N=100+5;
const int M=1000+5;
int n;

std::array<int,N>arr;

std::array<std::array<int,M*N>,N>save1,save2;

int f1(int i,int high){
	if(i>n){
		return 0;
	}
	if(save1[i][high]!=-1){
		return save1[i][high];
	}
	int res=arr[i]+f1(i+1,high+arr[i]);
	if(high>=arr[i]){
		res=std::min(res,f1(i+1,high-arr[i]));
	}
	save1[i][high]=res;
	return res;
}

int f2(int i,int high){
	if(i==0){
		return 0;
	}
	if(save2[i][high]!=-1){
		return save2[i][high];
	}
	int res=arr[i]+f2(i-1,high+arr[i]);
	if(high>=arr[i]){
		res=std::min(res,f2(i-1,high-arr[i]));
	}
	save2[i][high]=res;
	return res;
}

void Main_work(){
	std::cin>>n;
	--n;
	for(int i=0;i<=100;++i){
		std::fill(save1[i].begin(),save1[i].end(),-1);
		std::fill(save2[i].begin(),save2[i].end(),-1);
	}
	for(int i=1;i<=n;++i){
		std::cin>>arr[i];
	}
	save1[1][0]=f1(1,0);
	save2[n][0]=f2(n,0);

	int ans=0x7fffffff;
	std::cout<<std::min(save1[1][0],save2[n][0]);
	//std::cout<<save1[1][0]<<" "<<save2[n][0];
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0),std::cout.tie(0);
	Main_work();
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 10ms
memory: 89916kb

input:

2
3 3 5
2 4 7

output:

3

result:

wrong answer 1st words differ - expected: '831870305', found: '3'