# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
106235 | 2019-04-17T15:30:08 Z | abil | Bali Sculptures (APIO15_sculpture) | C++14 | 3 ms | 384 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 3 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |