답안 #45823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45823 2018-04-16T08:30:43 Z Talant Bali Sculptures (APIO15_sculpture) C++17
0 / 100
169 ms 188960 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long

using namespace std;

typedef long long ll;

const long long inf = (long long)1e15 + 7;
const long long N = (long long)2e5 + 7;

long long n,a,b;
long long ar[N],p[N];
set<int> dp[2002][2002];
long long mn = inf;

long long calc (long long l,long long r) {
      return (p[r] - p[l - 1]);
}

main () {
      cin >> n >> a >> b;

      for (long long i = 1; i <= n; i ++) {
            cin >> ar[i];
            p[i] = p[i - 1] + ar[i];
            dp[i][1].insert(p[i]);
      }
      for (long long j = 2; j <= b; j ++) {
            for (long long i = j; i <= n; i ++) {
                  for (long long l = 1; l < i; l ++) {
                        int mnx = inf;
                        for (auto to : dp[l][j - 1]) {
                              mnx = min(mnx,to | calc(l + 1,i));
                        }
                        for (auto to : dp[l][j - 1]) {
                              if (!(mnx & to))
                                    dp[i][j].insert(to);
                        }
                        dp[i][j].insert(mnx);
                  }
            }
      }
      for (long long i = a; i <= b; i ++) {
            for (auto to : dp[n][i])
                  mn = min(mn,to);
      }

      cout << mn << endl;
}
/**
6 1 3
8 1 2 1 5 4
**/

Compilation message

sculpture.cpp:26:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 164 ms 188536 KB Output is correct
2 Correct 157 ms 188648 KB Output is correct
3 Correct 155 ms 188648 KB Output is correct
4 Correct 157 ms 188648 KB Output is correct
5 Correct 157 ms 188832 KB Output is correct
6 Incorrect 156 ms 188832 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 188832 KB Output is correct
2 Correct 152 ms 188832 KB Output is correct
3 Correct 169 ms 188852 KB Output is correct
4 Correct 162 ms 188852 KB Output is correct
5 Correct 153 ms 188852 KB Output is correct
6 Incorrect 158 ms 188860 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 188860 KB Output is correct
2 Correct 155 ms 188860 KB Output is correct
3 Correct 155 ms 188920 KB Output is correct
4 Correct 153 ms 188920 KB Output is correct
5 Correct 163 ms 188920 KB Output is correct
6 Incorrect 159 ms 188924 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 188924 KB Output is correct
2 Correct 157 ms 188924 KB Output is correct
3 Correct 155 ms 188924 KB Output is correct
4 Correct 155 ms 188960 KB Output is correct
5 Correct 151 ms 188960 KB Output is correct
6 Incorrect 155 ms 188960 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 188960 KB Output is correct
2 Correct 155 ms 188960 KB Output is correct
3 Correct 151 ms 188960 KB Output is correct
4 Correct 150 ms 188960 KB Output is correct
5 Correct 154 ms 188960 KB Output is correct
6 Incorrect 152 ms 188960 KB Output isn't correct
7 Halted 0 ms 0 KB -