답안 #45697

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45697 2018-04-16T03:51:50 Z Talant Bali Sculptures (APIO15_sculpture) C++17
0 / 100
2 ms 692 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)1e18 + 7;
const int N = (int)2e5 + 7;

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

int calc (int l,int r) {
      return (p[r] - p[l - 1]);
}
void compute (int k,int l,int r,int L,int R) {
      if (l > r)
            return;
      int opt = -1;
      int m = (r + l) >> 1;

      for (int i = L; i <= min(R,m); i ++) {
            int now = dp[i][k - 1] | calc(i + 1,m);
            if (dp[m][k] > now) {
                  dp[m][k] = now,opt = i;
            }
      }
      compute(k,l,m - 1,L,opt);
      compute(k,m + 1,r,opt,R);
}
main () {
      scanf ("%lld%lld%lld", &n,&a,&b);

      for (int i = 1; i <= n; i ++)
            for (int j = 1; j <= b; j ++)
                  dp[i][j] = inf;

      for (int i = 1; i <= n; i ++) {
            scanf ("%lld", &ar[i]);
            p[i] = p[i - 1] + ar[i];
            dp[i][1] = p[i];
      }
      if (a <= 1)
            mn = dp[n][1];

      for (int i = 2; i <= b; i ++) {
            compute(i,1,n,1,n);
            if (i >= a)
                  mn = min(mn,dp[n][i]);
      }
      cout << mn << endl;
}
/**
6 1 3
8 1 2 1 5 4
**/

Compilation message

sculpture.cpp:40:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:41:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf ("%lld%lld%lld", &n,&a,&b);
       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:48:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf ("%lld", &ar[i]);
             ~~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 564 KB Output is correct
2 Incorrect 2 ms 564 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Incorrect 2 ms 628 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 692 KB Output is correct
2 Incorrect 2 ms 692 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 692 KB Output is correct
2 Incorrect 2 ms 692 KB Output isn't correct
3 Halted 0 ms 0 KB -