답안 #140732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140732 2019-08-04T19:10:26 Z BlueDiamond Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N = 2000 + 7;
int n, L, R;
int a[N];
int mi[N];

bool can(ll x)
{
        /// a | b | c | d <= x => a <= x, b <= x, c <= x, d <= x
        int need = 0;
        int i = 1;
        ll sau = 0;
        while (i <= n)
        {
                int j = i;
                if (a[i] > x)
                        return 0;
                ll cur = a[i];
                while (j + 1 <= n && cur + a[j + 1] <= x)
                {
                        j++;
                        cur += a[j];
                }
                need++;
                i = j + 1;
                sau |= cur;
        }
        return (need <= R && sau <= x);
}

int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(0), cout.tie(0);

        cin >> n >> L >> R;
        for (int i = 1; i <= n; i++)
                cin >> a[i];

        if (L == 1)
        {
                ll lo = 0, hi = 0;
                for (int i = 1; i <= n; i++)
                        hi += a[i];
                ll res = 0;
                while (lo <= hi)
                {
                        ll mid = (lo + hi) / 2;
                        if (can(mid))
                        {
                                res = mid;
                                hi = mid - 1;
                        }
                        else
                                lo = mid + 1;
                }
                cout << res << "\n";
        }

        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -