Submission #129381

#TimeUsernameProblemLanguageResultExecution timeMemory
129381ksmzzang2003Bali Sculptures (APIO15_sculpture)C++14
0 / 100
3 ms380 KiB
#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(bit==0) { printf(""); } if(i==0) { if(arr[i] & 1LL<<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 & 1LL<<bit) continue; if(x > 1LL<<bit) continue; ret=min(ret,1+f(k,bit,ans)); } ll x = psum[i]-ans; if(x<0) printf(""); else if(x & 1LL<<bit) printf(""); else if(x > 1LL<<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+=(1LL<<i); printf("%lld",ans); }

Compilation message (stderr)

sculpture.cpp: In function 'll f(int, int, int)':
sculpture.cpp:11:18: warning: zero-length gnu_printf format string [-Wformat-zero-length]
         printf("");
                  ^
sculpture.cpp:15:48: warning: integer overflow in expression [-Woverflow]
         if(arr[i] & 1LL<<bit) return 1987654321*1987654321;
                                      ~~~~~~~~~~^~~~~~~~~~~
sculpture.cpp:18:22: warning: integer overflow in expression [-Woverflow]
     ll ret=1987654321*1987654321;
            ~~~~~~~~~~^~~~~~~~~~~
sculpture.cpp:28:22: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     if(x<0) printf("");
                      ^
sculpture.cpp:29:36: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     else if(x & 1LL<<bit) printf("");
                                    ^
sculpture.cpp:30:36: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     else if(x > 1LL<<bit) printf("");
                                    ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:38: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:38:30: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll* {aka long long int*}' [-Wformat=]
sculpture.cpp:38:30: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'll* {aka long long int*}' [-Wformat=]
sculpture.cpp:43: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:38: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:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...