Submission #213799

#TimeUsernameProblemLanguageResultExecution timeMemory
213799DodgeBallManBali Sculptures (APIO15_sculpture)C++14
100 / 100
260 ms544 KiB
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 2e3 + 10; long mx[N], mn[N], a[N], ans; int n, l, r; int main() { scanf("%d %d %d",&n,&l,&r); for( int i = 1 ; i <= n ; i++ ) scanf("%d",&a[i]); for( int bit = 61 ; bit >= 0 ; bit-- ) { for( int i = 1 ; i <= n ; i++ ) { long sum = 0; mx[i] = -1e9, mn[i] = 1e9; for( int j = i ; j >= 1 ; j-- ) { sum += a[j]; if( sum - ( sum & ans ) < ( 1ll << bit ) && mn[j-1] + 1 <= r ) mn[i] = min( mn[i], mn[j-1] + 1 ), mx[i] = max( mx[i], mx[j-1] + 1 ); } } if( mn[n] > r || mx[n] < l ) ans |= ( 1ll << bit ); } printf("%lld",ans); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:12:53: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
     for( int i = 1 ; i <= n ; i++ ) scanf("%d",&a[i]);
                                                ~~~~~^
sculpture.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&l,&r);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:12:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( int i = 1 ; i <= n ; i++ ) scanf("%d",&a[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...