Submission #129376

# Submission time Handle Problem Language Result Execution time Memory
129376 2019-07-12T07:30:11 Z ksmzzang2003 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A,B,N;
vector <ll> arr,psum;

ll f(int i,int bit,int ans) // 0~i에서 bit 안쓰고 최소개수
{
    if(i==0)
    {
        if(arr[i] & 1<<bit) return 1987654321*1987654321;
        else return 1;
    }
    ll ret=1987654321*1987654321;
    for(int k=0; k<i; k++)
    {
        ll x = psum[i]-psum[k]-ans;
        if(x<0) continue;
        if(x & 1<<bit)
            continue;
        if(x > 1<<bit) continue;
        ret=min(ret,1+f(k,bit,ans));
    }
    ll x = psum[i]-ans;
    if(x<0) printf("");
    else if(x & 1<<bit) printf("");
    else if(x > 1<<bit) printf("");
    else ret=min(ret,1LL);

    return ret;
}

int main()
{
    scanf("%d %d %d",&N,&A,&B);
    arr.resize(N);
    psum.resize(N);
    for(ll i=0; i<N; i++)
    {
        scanf("%d",&arr[i]);
        if(i==0)
            psum[i] = arr[i];
        else
            psum[i] = psum[i-1] + arr[i];
    }
    ll ans=0;
    for(ll i=50; i>=0; i--)
        if(f(N-1,i,ans)>B)
            ans+=(1<<i);
    printf("%lld",ans);
}

Compilation message

sculpture.cpp: In function 'll f(int, int, int)':
sculpture.cpp:11:46: warning: integer overflow in expression [-Woverflow]
         if(arr[i] & 1<<bit) return 1987654321*1987654321;
                                    ~~~~~~~~~~^~~~~~~~~~~
sculpture.cpp:14:22: warning: integer overflow in expression [-Woverflow]
     ll ret=1987654321*1987654321;
            ~~~~~~~~~~^~~~~~~~~~~
sculpture.cpp:25:22: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     if(x<0) printf("");
                      ^
sculpture.cpp:26:34: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     else if(x & 1<<bit) printf("");
                                  ^
sculpture.cpp:27:34: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     else if(x > 1<<bit) printf("");
                                  ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:35:30: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll* {aka long long int*}' [-Wformat=]
     scanf("%d %d %d",&N,&A,&B);
                      ~~      ^
sculpture.cpp:35:30: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll* {aka long long int*}' [-Wformat=]
sculpture.cpp:35:30: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'll* {aka long long int*}' [-Wformat=]
sculpture.cpp:40:27: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type* {aka long long int*}' [-Wformat=]
         scanf("%d",&arr[i]);
                           ^
sculpture.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&N,&A,&B);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -