Submission #441624

# Submission time Handle Problem Language Result Execution time Memory
441624 2021-07-05T15:17:46 Z Vladth11 Peru (RMI20_peru) C++14
Compilation error
0 ms 0 KB
int solve(int n, int k, int* v) {
    ll sol = 0;
    for(ll i = 0; i < n; i++)
        a[i + 1] = v[i];
    put[0] = 1;
    for(ll i = 1; i <= n; i++) {
        put[i] = put[i - 1] * 23;
        put[i] %= MOD;
    }
    multiset <ll> st;
    for(ll i = 1; i <= n; i++) {
        while(dq.size() && dq.front() < i - k + 1) {
            ll x = dp[dq.front()];
            dq.pop_front();
            if(dq.size()){
                x += a[dq.front()];
                auto it = st.find(x);
                st.erase(it);
            }
        }
        while(dq.size() && a[dq.back()] <= a[i]) {
            ll x = a[dq.back()];
            dq.pop_back();
            if(dq.size()){
                x += dp[dq.back()];
                auto it = st.find(x);
                st.erase(it);
            }
        }
        if(dq.size())
            st.insert(a[i] + dp[dq.back()]);
        dq.push_back(i);
        if(st.size()) {
            dp[i] = min((ll)(*st.begin()), dp[max(i - k, 0LL)] + a[dq.front()]);
            //dp[i] %= MOD;
        } else {
            dp[i] = dp[max(0LL, i - k)] + a[dq.front()];
            //dp[i] %= MOD;
        }
        sol += ((dp[i] % MOD) * put[n - i]) % MOD;
        sol %= MOD;
    }
    return sol;
}

Compilation message

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:2:5: error: 'll' was not declared in this scope
    2 |     ll sol = 0;
      |     ^~
peru.cpp:3:11: error: expected ';' before 'i'
    3 |     for(ll i = 0; i < n; i++)
      |           ^~
      |           ;
peru.cpp:3:19: error: 'i' was not declared in this scope
    3 |     for(ll i = 0; i < n; i++)
      |                   ^
peru.cpp:4:9: error: 'a' was not declared in this scope
    4 |         a[i + 1] = v[i];
      |         ^
peru.cpp:5:5: error: 'put' was not declared in this scope
    5 |     put[0] = 1;
      |     ^~~
peru.cpp:6:11: error: expected ';' before 'i'
    6 |     for(ll i = 1; i <= n; i++) {
      |           ^~
      |           ;
peru.cpp:6:19: error: 'i' was not declared in this scope
    6 |     for(ll i = 1; i <= n; i++) {
      |                   ^
peru.cpp:8:19: error: 'MOD' was not declared in this scope
    8 |         put[i] %= MOD;
      |                   ^~~
peru.cpp:10:5: error: 'multiset' was not declared in this scope
   10 |     multiset <ll> st;
      |     ^~~~~~~~
peru.cpp:10:19: error: 'st' was not declared in this scope; did you mean 'std'?
   10 |     multiset <ll> st;
      |                   ^~
      |                   std
peru.cpp:11:11: error: expected ';' before 'i'
   11 |     for(ll i = 1; i <= n; i++) {
      |           ^~
      |           ;
peru.cpp:11:19: error: 'i' was not declared in this scope
   11 |     for(ll i = 1; i <= n; i++) {
      |                   ^
peru.cpp:12:15: error: 'dq' was not declared in this scope
   12 |         while(dq.size() && dq.front() < i - k + 1) {
      |               ^~
peru.cpp:13:15: error: expected ';' before 'x'
   13 |             ll x = dp[dq.front()];
      |               ^~
      |               ;
peru.cpp:16:17: error: 'x' was not declared in this scope
   16 |                 x += a[dq.front()];
      |                 ^
peru.cpp:16:22: error: 'a' was not declared in this scope
   16 |                 x += a[dq.front()];
      |                      ^
peru.cpp:21:15: error: 'dq' was not declared in this scope
   21 |         while(dq.size() && a[dq.back()] <= a[i]) {
      |               ^~
peru.cpp:21:28: error: 'a' was not declared in this scope
   21 |         while(dq.size() && a[dq.back()] <= a[i]) {
      |                            ^
peru.cpp:22:15: error: expected ';' before 'x'
   22 |             ll x = a[dq.back()];
      |               ^~
      |               ;
peru.cpp:25:17: error: 'x' was not declared in this scope
   25 |                 x += dp[dq.back()];
      |                 ^
peru.cpp:25:22: error: 'dp' was not declared in this scope
   25 |                 x += dp[dq.back()];
      |                      ^~
peru.cpp:30:12: error: 'dq' was not declared in this scope
   30 |         if(dq.size())
      |            ^~
peru.cpp:31:23: error: 'a' was not declared in this scope
   31 |             st.insert(a[i] + dp[dq.back()]);
      |                       ^
peru.cpp:31:30: error: 'dp' was not declared in this scope
   31 |             st.insert(a[i] + dp[dq.back()]);
      |                              ^~
peru.cpp:32:9: error: 'dq' was not declared in this scope
   32 |         dq.push_back(i);
      |         ^~
peru.cpp:34:13: error: 'dp' was not declared in this scope
   34 |             dp[i] = min((ll)(*st.begin()), dp[max(i - k, 0LL)] + a[dq.front()]);
      |             ^~
peru.cpp:34:47: error: 'max' was not declared in this scope
   34 |             dp[i] = min((ll)(*st.begin()), dp[max(i - k, 0LL)] + a[dq.front()]);
      |                                               ^~~
peru.cpp:34:66: error: 'a' was not declared in this scope
   34 |             dp[i] = min((ll)(*st.begin()), dp[max(i - k, 0LL)] + a[dq.front()]);
      |                                                                  ^
peru.cpp:34:21: error: 'min' was not declared in this scope
   34 |             dp[i] = min((ll)(*st.begin()), dp[max(i - k, 0LL)] + a[dq.front()]);
      |                     ^~~
peru.cpp:37:13: error: 'dp' was not declared in this scope
   37 |             dp[i] = dp[max(0LL, i - k)] + a[dq.front()];
      |             ^~
peru.cpp:37:24: error: 'max' was not declared in this scope
   37 |             dp[i] = dp[max(0LL, i - k)] + a[dq.front()];
      |                        ^~~
peru.cpp:37:43: error: 'a' was not declared in this scope
   37 |             dp[i] = dp[max(0LL, i - k)] + a[dq.front()];
      |                                           ^
peru.cpp:40:9: error: 'sol' was not declared in this scope; did you mean 'solve'?
   40 |         sol += ((dp[i] % MOD) * put[n - i]) % MOD;
      |         ^~~
      |         solve
peru.cpp:40:18: error: 'dp' was not declared in this scope
   40 |         sol += ((dp[i] % MOD) * put[n - i]) % MOD;
      |                  ^~
peru.cpp:40:26: error: 'MOD' was not declared in this scope
   40 |         sol += ((dp[i] % MOD) * put[n - i]) % MOD;
      |                          ^~~
peru.cpp:43:12: error: 'sol' was not declared in this scope; did you mean 'solve'?
   43 |     return sol;
      |            ^~~
      |            solve