답안 #916292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916292 2024-01-25T15:31:07 Z hariaakas646 Bali Sculptures (APIO15_sculpture) C++14
21 / 100
1000 ms 30808 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, l, r) for(int i=l; i<r; i++)
#define frange(i, l) forr(i, 0, l)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef long long lli;
typedef vector<vi> vvi;
typedef vector<lli> vll;
typedef vector<bool> vb;
typedef set<int> seti;
typedef multiset<int> mseti;

void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
}

// int dp[101][2049] = {int(1e9)};

int main() {
    // usaco();
    int n, a, b;
    scd(n);
    scd(a);
    scd(b);

    vll vec(n+1);
    forr(i, 1, n+1) sclld(vec[i]);

    // forr(i, 0, n+1) {
    //     forr(j, 0, 2049) dp[i][j] = 1e9;
    // }

    vector<map<lli, int>> dp(n+1);
    dp[0][0] = 0;
    
    forr(j, 0, n) {
        for(auto k : dp[j]) {
            lli v = 0;
            forr(l, j+1, n+1) {
                v += vec[l];
                if(dp[l].find(k.f | v) == dp[l].end()) dp[l][k.f|v] = k.s+1;
                else
                dp[l][k.f | v] = min(dp[l][k.f | v], k.s + 1); 
            }
            
        }
    }
    

    lli mi = 1e18;

    // forr(i, a, b+1) {
    //     frange(k, 513) {
    //         if(dp[i][n][k]) mi = min(mi, k);
    //     }
    // }

    // frange(k, 2049) {
    //     if(dp[n][k] <= b) mi = min(mi, k);
    // }
    for(auto k : dp[n]) {
        if(k.s <= b) mi = min(mi, k.f);
    }

    // forr(i, 1, 1<<n) {
    //     if(a <= __builtin_popcount(i) && __builtin_popcount(i) <= b && (i & (1<<(n-1)))) {
    //         lli tot = 0;
    //         lli v = 0;
    //         frange(j, n) {
    //             v += vec[j];
    //             if(i & (1<<j)) {
    //                 tot = tot | v;
    //                 v = 0;
    //             }
    //         }
    //         mi = min(mi, tot);
    //     }
    // }
    
    printf("%lld", mi);
}

Compilation message

sculpture.cpp: In function 'void usaco()':
sculpture.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
sculpture.cpp:35:5: note: in expansion of macro 'scd'
   35 |     scd(n);
      |     ^~~
sculpture.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
sculpture.cpp:36:5: note: in expansion of macro 'scd'
   36 |     scd(a);
      |     ^~~
sculpture.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
sculpture.cpp:37:5: note: in expansion of macro 'scd'
   37 |     scd(b);
      |     ^~~
sculpture.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
sculpture.cpp:40:21: note: in expansion of macro 'sclld'
   40 |     forr(i, 1, n+1) sclld(vec[i]);
      |                     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 544 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 3 ms 608 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 5 ms 604 KB Output is correct
25 Correct 9 ms 780 KB Output is correct
26 Correct 18 ms 860 KB Output is correct
27 Correct 25 ms 1116 KB Output is correct
28 Correct 37 ms 1104 KB Output is correct
29 Correct 22 ms 1040 KB Output is correct
30 Correct 22 ms 860 KB Output is correct
31 Correct 44 ms 1372 KB Output is correct
32 Correct 43 ms 1444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 408 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 436 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 436 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 5 ms 572 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 4 ms 856 KB Output is correct
35 Correct 10 ms 600 KB Output is correct
36 Correct 18 ms 860 KB Output is correct
37 Correct 24 ms 1096 KB Output is correct
38 Correct 32 ms 1116 KB Output is correct
39 Correct 22 ms 1048 KB Output is correct
40 Correct 24 ms 860 KB Output is correct
41 Correct 42 ms 1440 KB Output is correct
42 Correct 49 ms 1316 KB Output is correct
43 Correct 455 ms 17236 KB Output is correct
44 Execution timed out 1053 ms 30808 KB Time limit exceeded
45 Halted 0 ms 0 KB -