답안 #859726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859726 2023-10-10T14:39:34 Z activedeltorre Peru (RMI20_peru) C++14
0 / 100
1 ms 2392 KB
#include <iostream>
#include <queue>
#include "peru.h"
using namespace std;
priority_queue<pair<long long,long long> >pq;
priority_queue<pair<long long,long long> >pq2;
long long dp[5000005];

int solve(int n, int k, int* v)
{
    long long maxim=0,a,b,i;
    for(i=0;i<k;i++)
    {
        maxim=max(maxim,1LL*v[i]);
        dp[i]=maxim;
        pq.push({v[i],i});
        pq2.push({-maxim,i});
    }
    for(i=k;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-1]=1e17;
    for(i=n+k-2;i>=0;i--)
    {
        dp[i]=min(dp[i],dp[i+1]);
    }
    long long suma=0,mod=1000000007;
    for(i=0;i<n;i++)
    {
        suma=(suma*23+dp[i])%mod;
    }
    return suma;
}
/*
#include<iostream>
//#include "peru.h"
using namespace std;

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:11:23: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   11 |     long long maxim=0,a,b,i;
      |                       ^
peru.cpp:11:25: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   11 |     long long maxim=0,a,b,i;
      |                         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -