Submission #46266

#TimeUsernameProblemLanguageResultExecution timeMemory
46266iletavcioskiBali Sculptures (APIO15_sculpture)C++17
0 / 100
2 ms564 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; typedef unsigned long long ll; ll funkcija(ll x,ll y) { string s1="",s2=""; while(x>=0) { s1+=(x%2+'0'); x/=2; if(x==0) break; } while(y>=0) { s2+=(y%2+'0'); y/=2; if(y==0) break; } if(s1.size()<s2.size()) swap(s1,s2); while(s2.size()<s1.size()) s2+='0'; reverse(s1.begin(),s1.end()); reverse(s2.begin(),s2.end()); string ss=""; for(int i=0;i<s1.size();i++) if(s1[i]=='1'||s2[i]=='1') ss+='1'; else ss+='0'; reverse(ss.begin(),ss.end()); ll bb=0; for(int i=0;i<ss.size();i++) { if(ss[i]=='1') bb+=pow(2,double(i)); } return bb; } int main() { ios_base::sync_with_stdio(false); int n,a,b; cin>>n>>a>>b; if(n<=500) { vector<ll> v; static ll dp[2000+1][2000+1]; for(int i=0;i<=n;i++) { for(int j=0;j<=b;j++) { dp[i][j]=18446744073709551615; } } dp[0][0]=0; v.push_back((ll)0); for(int i=0;i<n;i++) { ll aa; cin>>aa; v.push_back(aa); } for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { ll brojac=0; for(int k=i;k>=1;k--) { brojac+=v[k]; if(dp[k-1][j-1]==18446744073709551615) continue; ll broj=(brojac|dp[k-1][j-1]); dp[i][j]=min(dp[i][j],broj); } } } ll maxi=18446744073709551615; for(int i=a;i<=b;i++) maxi=min(maxi,dp[n][i]); cout<<maxi<<endl; return 0; } else { vector<ll> v; vector<ll> dp(n+1,18446744073709551615); dp[0]=0; v.push_back(-1); for(int i=0;i<n;i++) { ll a; cin>>a; v.push_back(a); } for(int i=1;i<=n;i++) { ll brojac=0; int broj=0; if(dp[i-1]!=18446744073709551615) { for(int j=i;j<=n;j++) { brojac+=v[j]; broj++; if(broj>=a&&broj<=b&&i-1!=0) { dp[j]=min(dp[j],(brojac|dp[i-1])); } else if(i-1==0&&broj>=a&&broj<=b) { dp[j]=min(dp[j],brojac); } } } } cout<<dp[n]<<endl; return 0; } return 0; }

Compilation message (stderr)

sculpture.cpp:59:22: warning: integer constant is so large that it is unsigned
             dp[i][j]=18446744073709551615;
                      ^~~~~~~~~~~~~~~~~~~~
sculpture.cpp:78:34: warning: integer constant is so large that it is unsigned
                 if(dp[k-1][j-1]==18446744073709551615)
                                  ^~~~~~~~~~~~~~~~~~~~
sculpture.cpp:85:13: warning: integer constant is so large that it is unsigned
     ll maxi=18446744073709551615;
             ^~~~~~~~~~~~~~~~~~~~
sculpture.cpp:94:23: warning: integer constant is so large that it is unsigned
     vector<ll> dp(n+1,18446744073709551615);
                       ^~~~~~~~~~~~~~~~~~~~
sculpture.cpp:107:21: warning: integer constant is so large that it is unsigned
         if(dp[i-1]!=18446744073709551615)
                     ^~~~~~~~~~~~~~~~~~~~
sculpture.cpp: In function 'll funkcija(ll, ll)':
sculpture.cpp:32:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s1.size();i++)
                 ~^~~~~~~~~~
sculpture.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<ss.size();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...