답안 #457767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
457767 2021-08-07T11:30:03 Z mariowong Bootfall (IZhO17_bootfall) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

int ct[250005],n,a[505],sum; 
bool dp[250005],gg[250005];
vector <int> ans;
int main() {
	ios::sync_with_stdio(false); 
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	for (int i=0;i<=n;i++){
		for (int j=1;j<=n*500;j++){
			dp[j]=false;
			gg[j]=false;
		}
		dp[0]=true;
		for (int j=1;j<=n;j++){
			if (j != i){
				for (int k=j*500;k>=a[j];k--){
					dp[k]=dp[k]|dp[k-a[j]];
				}	
			}
		}
		for (int j=0;j<=n*500;j++){
			if (dp[j] && !gg[max(j,sum-j-a[i])-min(j,sum-j-a[i])]){
				ct[max(j,sum-j-a[i])-min(j,sum-j-a[i])]++;
				gg[max(j,sum-j-a[i])-min(j,sum-j-a[i])]=true;
			}
		}
	} 
	for (int i=1;i<=n*500;i++){
		if (ct[i] == n+1)
		ans.push_back(i);
	}
	cout << (int)ans.size() << "\n";
	for (int i=0;i<ans.size();i++){
		cout << ans[i] << " ";
	}
	cout << "\n";
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for (int i=0;i<ans.size();i++){
      |               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -