답안 #441606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441606 2021-07-05T14:34:45 Z Vladth11 Peru (RMI20_peru) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#include "peru.h"

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <long double, pii> muchie;
typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> OST;

const ll NMAX = 2500002;
const ll INF = (1LL << 60);
const ll HALF = (1LL << 59);
const ll MOD = 1000000007;
const ll BLOCK = 318;
const ll base = 31;
const ll nr_of_bits = 21;
const ll LIMIT = 1000;

ll dp[NMAX];
ll a[NMAX];
ll put[NMAX];
deque <int> dq;

int solve(int n, int k, int* v) {
    ll sol = 0;
    for(int i = 0; i < n; i++)
        a[i + 1] = v[i];
    put[0] = 1;
    for(int i = 1; i <= n; i++) {
        put[i] = put[i - 1] * 23;
        put[i] %= MOD;
    }
    multiset <ll> st;
    for(int 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(x);
            }
        }
        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, 0)] + a[dq.front()]);
            dp[i] %= MOD;
        } else {
            dp[i] = dp[max(0, i - k)] + a[dq.front()];
            dp[i] %= MOD;
        }
        sol += (dp[i] * put[n - i]) % MOD;
        sol %= MOD;
    }
    return sol;
}

static int s[2500005];
static int n, k;
int main() {
    cin>> n >> k;
    for(int i = 0; i < n; i++) {
        cin>> s[i];
    }
    int ans = solve(n, k, s);
    cout<< ans <<"\n";
    return 0;
}

Compilation message

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:56:22: warning: variable 'it' set but not used [-Wunused-but-set-variable]
   56 |                 auto it = st.find(x);
      |                      ^~
/usr/bin/ld: /tmp/ccl5GhUD.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccVIbDKG.o:peru.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status