Submission #106235

#TimeUsernameProblemLanguageResultExecution timeMemory
106235abilBali Sculptures (APIO15_sculpture)C++14
0 / 100
3 ms384 KiB
#include <bits/stdc++.h> #define int long long #define mk make_pair #define sc second #define fr first #define pb emplace_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define Scan(a) scanf ("%I64d", &a) #define scan(a) scanf ("%d", &a) #define pi pair < int, int > using namespace std; const long long INF = (int)1e18 + 7; const int N = (int)2007; const int mod = 1000000007; pi dp[N][N]; int y[N]; int n, a, b; int ans; main(){ ans = INF; cin >> n >> a >> b; for (int i = 1; i <= n; i++){ scanf("%lld", &y[i]); } for (int i = 1; i <= n; i++){ for (int j = 0; j <= n; j++){ dp[i][j] = {INF, INF}; } } for (int i = 1; i <= n; i++){ for (int g = 1; g <= min(i, b); g++){ if ((dp[i - 1][g].fr | (dp[i - 1][g].sc + y[i])) < ((dp[i - 1][g - 1].fr | dp[i - 1][g - 1].sc) | y[i])){ dp[i][g] = {dp[i - 1][g].fr, (dp[i - 1][g].sc + y[i])}; } else { dp[i][g] = { (dp[i - 1][g - 1].fr | dp[i - 1][g - 1].sc) , y[i]}; } //cout << dp[i][g].fr << ' ' << dp[i][g].sc << ' ' << i << ' ' << g << endl; //system("pause"); } } for (int g = a; g <= b; g++) ans = min(ans, (dp[n][g].fr | dp[n][g].sc)); cout << ans; }

Compilation message (stderr)

sculpture.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld", &y[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...