제출 #701343

#제출 시각아이디문제언어결과실행 시간메모리
701343Do_you_copyK개의 묶음 (IZhO14_blocks)C++17
53 / 100
1094 ms79432 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define int long long
using namespace std;
using ll = long long;
using pii = pair <int, int>;

const int maxN = 1e5 + 1;
const int inf = 0x3f3f3f3f3f3f3f3f;
//const int Mod =
int n, k;
int a[maxN];
ll dp[maxN][101];
void Init(){
    cin >> n >> k;
    memset(dp, 0x3f, sizeof(dp));
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    dp[0][0] = 0;
    for (int i = 1; i <= k; ++i){
        for (int j = 1; j <= n; ++j){
            int maxx = 0;
            for (int g = j; g >= 1; --g){
                maxx = max(maxx, a[g]);
                dp[j][i] = min(dp[j][i], dp[g - 1][i - 1] + maxx);
            }
        }
    }
    cout << dp[n][k];
}

#define taskname "test"
signed main(){
    faster
    if (fopen(taskname ".inp", "r")){
        freopen(taskname ".inp", "r", stdin);
        freopen(taskname ".ans", "w", stdout);
    }
    int tt = 1;
    //cin >> tt;
    while (tt--){
        Init();
    }
    if (fopen("timeout.txt", "r")){
        ofstream timeout("timeout.txt");
        cerr << "Time elapsed: " << signed(double(clock()) / CLOCKS_PER_SEC * 1000) << "ms\n";
        timeout << signed(double(clock()) / CLOCKS_PER_SEC * 1000);
        timeout.close();
    }
}

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

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