Submission #1084442

#TimeUsernameProblemLanguageResultExecution timeMemory
1084442_rain_Discharging (NOI20_discharging)C++14
36 / 100
8 ms3164 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define fixbug true

const ll INF = (ll)4e18+7;
const int maxn = 1e5;
ll a[maxn+2] ;
int n;

namespace subtask1{
    bool check(){
        return n <= 1500;
    }
    const int N = 1500;
    ll f[N+2] , sum[N+2] = {};
    void main_code(){
        for (int i = 1; i <= n; ++i) f[i] = INF , sum[i] = INF;
        for (int i = 1; i <= n; ++i){
            ll mx = a[i];
            for (int j = i; j >= 1; --j){
                mx = max(mx , a[j]);
                //ll v = f[j - 1] + sum[j - 1] * i - sum[j - 1] * (j + 1) + mx * i - mx * (j + 1);
                f[i] = min(f[i] , f[j - 1] + mx * (n - j + 1));
            }
        }
        cout << f[n];
        return;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #define name "main"
    if (fopen(name".inp","r")){
        freopen(name".inp","r",stdin);
    }

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

    if (subtask1::check()) {
        subtask1::main_code();
        exit(0);
    }
    //subtask2::main_code();
    exit(0);
}

Compilation message (stderr)

Discharging.cpp: In function 'int main()':
Discharging.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen(name".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...