답안 #342888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342888 2021-01-03T06:50:49 Z vonatlus Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 636 KB
/// wa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;
const int B = 3e5;

bitset<B> dp, tmp;
   
int cnt[B];

void ma1n() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0, mx = 0;
    for (int& x : a) {
        cin >> x, s += x;
        mx = max(mx, x);
    }
    for (int i = -1; i < n; ++i) {
        dp.reset();
        dp.set(s, 1);
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            int x = a[j];
            for (int b = 0; b <= s*2; ++b) {
                if (dp[b]) {
                    int d = b+x;
                    if (d <= s*2) 
                        tmp[d] = 1;
                    d = b-x;
                    if (d >= 0) 
                        tmp[d] = 1;
                }
            }
            dp = tmp;
            tmp.reset();
        }
        if (i == -1 && !dp[s]) cout << 0, exit(0);
        for (int b = 0; b <= s; ++b) {
            if (dp[b]) {
                cnt[s-b]++;
            }
        }
    }
    vector<int> ans;
    for (int i = 0; i <= s; ++i) {
        if (cnt[i] == n) {
            ans.pb(i);
        }
    }
    cout << sz(ans) << "\n";
    for (int x : ans) cout << x << " ";
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 6 ms 492 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 6 ms 492 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 62 ms 492 KB Output is correct
22 Correct 74 ms 492 KB Output is correct
23 Correct 27 ms 492 KB Output is correct
24 Correct 139 ms 492 KB Output is correct
25 Correct 254 ms 636 KB Output is correct
26 Correct 264 ms 492 KB Output is correct
27 Correct 243 ms 620 KB Output is correct
28 Correct 254 ms 620 KB Output is correct
29 Correct 252 ms 620 KB Output is correct
30 Correct 194 ms 492 KB Output is correct
31 Correct 217 ms 492 KB Output is correct
32 Correct 177 ms 628 KB Output is correct
33 Correct 255 ms 492 KB Output is correct
34 Correct 264 ms 620 KB Output is correct
35 Correct 249 ms 492 KB Output is correct
36 Correct 171 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 6 ms 492 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 62 ms 492 KB Output is correct
22 Correct 74 ms 492 KB Output is correct
23 Correct 27 ms 492 KB Output is correct
24 Correct 139 ms 492 KB Output is correct
25 Correct 254 ms 636 KB Output is correct
26 Correct 264 ms 492 KB Output is correct
27 Correct 243 ms 620 KB Output is correct
28 Correct 254 ms 620 KB Output is correct
29 Correct 252 ms 620 KB Output is correct
30 Correct 194 ms 492 KB Output is correct
31 Correct 217 ms 492 KB Output is correct
32 Correct 177 ms 628 KB Output is correct
33 Correct 255 ms 492 KB Output is correct
34 Correct 264 ms 620 KB Output is correct
35 Correct 249 ms 492 KB Output is correct
36 Correct 171 ms 492 KB Output is correct
37 Execution timed out 1090 ms 492 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 6 ms 492 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 62 ms 492 KB Output is correct
22 Correct 74 ms 492 KB Output is correct
23 Correct 27 ms 492 KB Output is correct
24 Correct 139 ms 492 KB Output is correct
25 Correct 254 ms 636 KB Output is correct
26 Correct 264 ms 492 KB Output is correct
27 Correct 243 ms 620 KB Output is correct
28 Correct 254 ms 620 KB Output is correct
29 Correct 252 ms 620 KB Output is correct
30 Correct 194 ms 492 KB Output is correct
31 Correct 217 ms 492 KB Output is correct
32 Correct 177 ms 628 KB Output is correct
33 Correct 255 ms 492 KB Output is correct
34 Correct 264 ms 620 KB Output is correct
35 Correct 249 ms 492 KB Output is correct
36 Correct 171 ms 492 KB Output is correct
37 Execution timed out 1090 ms 492 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 6 ms 492 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 62 ms 492 KB Output is correct
22 Correct 74 ms 492 KB Output is correct
23 Correct 27 ms 492 KB Output is correct
24 Correct 139 ms 492 KB Output is correct
25 Correct 254 ms 636 KB Output is correct
26 Correct 264 ms 492 KB Output is correct
27 Correct 243 ms 620 KB Output is correct
28 Correct 254 ms 620 KB Output is correct
29 Correct 252 ms 620 KB Output is correct
30 Correct 194 ms 492 KB Output is correct
31 Correct 217 ms 492 KB Output is correct
32 Correct 177 ms 628 KB Output is correct
33 Correct 255 ms 492 KB Output is correct
34 Correct 264 ms 620 KB Output is correct
35 Correct 249 ms 492 KB Output is correct
36 Correct 171 ms 492 KB Output is correct
37 Execution timed out 1090 ms 492 KB Time limit exceeded
38 Halted 0 ms 0 KB -