제출 #684830

#제출 시각아이디문제언어결과실행 시간메모리
684830vjudge1K개의 묶음 (IZhO14_blocks)C++14
53 / 100
1083 ms80204 KiB
#include <bits/stdc++.h>
using namespace std; 

const int mod = 1e9 + 7; 
const auto seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937_64 ran(seed);

#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define REP(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FOD(i,r,l) for(int i=r; i>=l; i--)


int n, k; 
int a[200000];
int f[100004][102];

signed main(){
#define task "a"
    if(fopen(task".inp","r")) {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }

    cin >> n >> k; 

    memset(f, 0x3f, sizeof f);
    f[0][1] = 0 ; 
    FOR(i ,1, n) cin >> a[i], f[i][1] = max(f[i-1][1], a[i]);

    FOR(i ,1, n){
        FOR(j ,2, k){
            int mx = 0; 
            FOD(x ,i, 2){
                mx = max(mx , a[x]); 
                f[i][j] = min(f[i][j], f[x - 1][j - 1] + mx);
            }
        }
    }

    cout << f[n][k]; 
}










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

blocks.cpp: In function 'int main()':
blocks.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         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...