Submission #859723

# Submission time Handle Problem Language Result Execution time Memory
859723 2023-10-10T14:33:46 Z activedeltorre Peru (RMI20_peru) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <queue>

using namespace std;
priority_queue<pair<long long,long long> >pq;
priority_queue<pair<long long,long long> >pq2;
long long v[2500005];
long long dp[2500005];
signed main()
{
    long long n,i,j,k,l;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    long long maxim=0,a,b;
    for(i=1;i<=k;i++)
    {
        maxim=max(maxim,v[i]);
        dp[i]=maxim;
        pq.push({v[i],i});
        pq2.push({-maxim,i});
    }
    for(i=k+1;i<=n+k-1;i++)
    {
        pq.push({v[i],i});
        while(pq.top().second<=i-k)
        {
            pq.pop();
        }
        while(pq2.top().second<i-k)
        {
            pq2.pop();
        }
        a=pq.top().first;
        b=pq2.top().first;
        dp[i]=pq.top().first-pq2.top().first;
        pq2.push({-dp[i],i});
    }
    dp[n+k]=1e9;
    for(i=n+k-1;i>=1;i--)
    {
        dp[i]=min(dp[i],dp[i+1]);
    }
    long long suma=0,mod=1000000007;
    for(i=1;i<=n;i++)
    {
        suma=(suma*23+dp[i])%mod;
    }
    cout<<suma;
    return 0;
}

Compilation message

peru.cpp: In function 'int main()':
peru.cpp:11:19: warning: unused variable 'j' [-Wunused-variable]
   11 |     long long n,i,j,k,l;
      |                   ^
peru.cpp:11:23: warning: unused variable 'l' [-Wunused-variable]
   11 |     long long n,i,j,k,l;
      |                       ^
peru.cpp:17:23: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   17 |     long long maxim=0,a,b;
      |                       ^
peru.cpp:17:25: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   17 |     long long maxim=0,a,b;
      |                         ^
/usr/bin/ld: /tmp/ccXLu2ni.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJdP1Ri.o:peru.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccXLu2ni.o: in function `main':
grader.cpp:(.text.startup+0x144): undefined reference to `solve(int, int, int*)'
collect2: error: ld returned 1 exit status