Submission #995568

#TimeUsernameProblemLanguageResultExecution timeMemory
995568assanaliBali Sculptures (APIO15_sculpture)C++17
0 / 100
0 ms348 KiB
/* author: CRISTIANO RONALDO #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; can do: find_by_order, order_of_key __builtin_clz(x): the number of zeros at the beginning of the number __builtin_ctz(x): the number of zeros at the end of the number __builtin_popcount(x): the number of ones in the number __builtin_parity(x): the parity (even or odd) of the number of ones mt19937 rng(15); mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count()); */ #include <bits/stdc++.h> #define ll long long #define all(a) a.begin(), a.end() #define F first #define S second #define pb push_back #define ull unsigned long long #define ld long double #define lv v+v #define rv v+v+1 #define files freopen("aa.txt", "r", stdin), freopen("aa.txt", "w", stdout) #define pll pair <long long, long long> #define pii pair <int, int> using namespace std; long long mod = 1e9 + 7; const ll N = 2e5 + 10; const ll M = 2e3 + 10; const ll P = 337ll; const ld EPS = 1e-7; const ll block = 325; const ll inf = 2e18; ll n,A,B,a[N],off=0,bt[30],cur,len,take=0,nw; bool getbit(ll number, ll index) { return ((number >> index) & 1LL); } bool bad(ll fir, ll sec) { ll tmp = fir; tmp ^= sec; tmp &= fir; return (tmp > 0); } bool check(ll need) { cur=nw=len=0; nw++; // cout<<"\n\n"<<need<<":\n"; for(ll i = 1; i<=n; i++) { cur += a[i]; len++; if(bad(cur, need)) { // cout<<i<<" "<<cur<<" "<<len<<" "; ll val=cur,r=-1; for(ll j = i+1; j<=n; j++) { val += a[j]; if(!bad(val, need)) { r=j; break; } } // cout<<r<<"\n"; if(r != -1) { i=r; } else if(len == 1){ return false; } else { len=cur=0; i--; nw++; } } } // cout<<nw; return (nw <= B); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); for(ll i = 0; i<30; i++) { bt[i] = (1LL << i); off |= bt[i]; } cin>>n>>A>>B; for(ll i = 1; i<=n; i++) { cin>>a[i]; } for(ll i = 30 - 1; i>=0; i--) { off ^= bt[i]; if(!check(off)) { off |= bt[i]; } } cout<<off; return 0; } // equal, min, max, 1, random, build /* 6 1 3 8 1 2 1 5 4 */
#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...