제출 #1242126

#제출 시각아이디문제언어결과실행 시간메모리
1242126khanhdangiuuBali Sculptures (APIO15_sculpture)C++20
50 / 100
138 ms488 KiB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define priority_queue priority_queue<array<long long,2>, vector<array<long long,2>>, greater<array<long long,2>>>
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define pii pair<int,int>
#define pli pair<long long,int> 
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define pi 3.14159265358979323846 
#define pb push_back
#define fi first
#define se second
#define ar array
#define int long long

void chay()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define task "Hi"
    freopen(task".INP", "r", stdin);
    freopen(task".OUT", "w", stdout);
}

const int N = 2e5, INF = 2e9+7;
const int block = 600;
const long long INFLL = 2e18+7;
long long M = 1e9+7;
int n, a, b, dung[N+5], c[N+5];
ll maxx;
bool ok[N+5];

bool check(ll maxx)
{
    for (int i = 1; i <= n; i++) ok[i] = false;
    for (int i = 1; i <= n; i++) dung[i] = INF;
    ok[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        ll tong = 0;
        for (int j = i; j >= 1; j--)
        {
            tong += c[j];
            if (tong > maxx) break;
            if (!((tong | maxx) == maxx)) continue;
            if (ok[j-1])
            {
                dung[i] = min(dung[i], dung[j-1] + 1);
                ok[i] = true;
            }
        }
    }
    return dung[n] <= b;
}

void solve()
{
    cin>>n>>a>>b;
    for (int i = 1; i <= n; i++) cin>>c[i];
    maxx = (1ll<<61) - 1;
    for (int i = 60; i >= 0; i--)
    {
        if (check(maxx - (1ll<<i)))
        {
            maxx -= (1ll<<i);
        }
    }
    cout<<maxx;
}
 
signed main ()
{
    //chay();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;   
    //cin>>t; 
    while (t--)
    {
        solve();
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'void chay()':
sculpture.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen(task".INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen(task".OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...