답안 #166684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166684 2019-12-03T13:13:10 Z abil Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 620 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

int a[N];
set<int > s;
main()
{
	int n, sum = 0;
	scanf("%d", &n);
	for(int i = 0;i < n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	n++;
	for(int i = 1;i <= sum; i++){
		a[n - 1] = i;
		sum += i;
		bool f = true;
		for(int q = 0;q < n; q++){
			vector<bool > dp(N,false);
			dp[0] = true;
			for(int j = 0;j < n; j++){
				if(j == q){
					continue;
				}
				for(int k = sum - a[j];k >= 0; k--){
					if(dp[k]){
						dp[k + a[j]] = true;
					}
				}
			}
			if(!dp[(sum - a[q]) / 2] || (sum - a[q]) % 2 == 1){
				f = false;
				break;
			}
		}
		sum -= i;
		if(f){
			s.insert(i);
		}
	}
	cout << s.size() << endl;
	for(auto to : s){
		cout << to << " ";
	}
}

Compilation message

bootfall.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bootfall.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 13 ms 504 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 192 ms 504 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 13 ms 504 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 192 ms 504 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
10 Correct 46 ms 528 KB Output is correct
11 Correct 116 ms 620 KB Output is correct
12 Correct 19 ms 376 KB Output is correct
13 Correct 15 ms 376 KB Output is correct
14 Correct 341 ms 604 KB Output is correct
15 Correct 78 ms 580 KB Output is correct
16 Correct 109 ms 488 KB Output is correct
17 Correct 31 ms 504 KB Output is correct
18 Correct 74 ms 508 KB Output is correct
19 Correct 58 ms 524 KB Output is correct
20 Correct 49 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 13 ms 504 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 192 ms 504 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
10 Correct 46 ms 528 KB Output is correct
11 Correct 116 ms 620 KB Output is correct
12 Correct 19 ms 376 KB Output is correct
13 Correct 15 ms 376 KB Output is correct
14 Correct 341 ms 604 KB Output is correct
15 Correct 78 ms 580 KB Output is correct
16 Correct 109 ms 488 KB Output is correct
17 Correct 31 ms 504 KB Output is correct
18 Correct 74 ms 508 KB Output is correct
19 Correct 58 ms 524 KB Output is correct
20 Correct 49 ms 504 KB Output is correct
21 Execution timed out 1068 ms 504 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 13 ms 504 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 192 ms 504 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
10 Correct 46 ms 528 KB Output is correct
11 Correct 116 ms 620 KB Output is correct
12 Correct 19 ms 376 KB Output is correct
13 Correct 15 ms 376 KB Output is correct
14 Correct 341 ms 604 KB Output is correct
15 Correct 78 ms 580 KB Output is correct
16 Correct 109 ms 488 KB Output is correct
17 Correct 31 ms 504 KB Output is correct
18 Correct 74 ms 508 KB Output is correct
19 Correct 58 ms 524 KB Output is correct
20 Correct 49 ms 504 KB Output is correct
21 Execution timed out 1068 ms 504 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 13 ms 504 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 192 ms 504 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
10 Correct 46 ms 528 KB Output is correct
11 Correct 116 ms 620 KB Output is correct
12 Correct 19 ms 376 KB Output is correct
13 Correct 15 ms 376 KB Output is correct
14 Correct 341 ms 604 KB Output is correct
15 Correct 78 ms 580 KB Output is correct
16 Correct 109 ms 488 KB Output is correct
17 Correct 31 ms 504 KB Output is correct
18 Correct 74 ms 508 KB Output is correct
19 Correct 58 ms 524 KB Output is correct
20 Correct 49 ms 504 KB Output is correct
21 Execution timed out 1068 ms 504 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 13 ms 504 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 192 ms 504 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
10 Correct 46 ms 528 KB Output is correct
11 Correct 116 ms 620 KB Output is correct
12 Correct 19 ms 376 KB Output is correct
13 Correct 15 ms 376 KB Output is correct
14 Correct 341 ms 604 KB Output is correct
15 Correct 78 ms 580 KB Output is correct
16 Correct 109 ms 488 KB Output is correct
17 Correct 31 ms 504 KB Output is correct
18 Correct 74 ms 508 KB Output is correct
19 Correct 58 ms 524 KB Output is correct
20 Correct 49 ms 504 KB Output is correct
21 Execution timed out 1068 ms 504 KB Time limit exceeded
22 Halted 0 ms 0 KB -