답안 #872635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872635 2023-11-13T13:20:35 Z imarn Peru (RMI20_peru) C++14
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define vi vector<int>
#define vpii vector<pii>
#define ll long long
using namespace std;
const int inf=1e9+7;
int solve(int n, int k, int* v){
    int a[n+1];
    ll pw[n+1];pw[0]=1;
    for(int i=1;i<=n;i++)pw[i]=(pw[i-1]*23)%inf;v++;
    for(int i=1;i<=n;i++)a[i]=*(v),v++;
    deque<int>dq;ll dp[n+1];dp[0]=0;
    for(int i=1;i<=n;i++){
        while(!dq.empty()&&i-dq.front()>k)dq.pop_front();
        while(!dq.empty()&&a[dq.back()]<a[i])dq.pop_back();dq.pb(i);
        dp[i] = dp[max(i-k,0)]+a[dq.front()];
        for(int j=1;j<dq.size();j++){
            dp[i] = min(dp[i],dp[dq[j-1]]+a[dq[j]]);
        }
    }ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[i]*pw[n-i];
        ans%=inf;
    }return (ans%inf+inf)%inf;
}

Compilation message

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |     for(int i=1;i<=n;i++)pw[i]=(pw[i-1]*23)%inf;v++;
      |     ^~~
peru.cpp:18:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   18 |     for(int i=1;i<=n;i++)pw[i]=(pw[i-1]*23)%inf;v++;
      |                                                 ^
peru.cpp:23:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   23 |         while(!dq.empty()&&a[dq.back()]<a[i])dq.pop_back();dq.pb(i);
      |         ^~~~~
peru.cpp:23:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   23 |         while(!dq.empty()&&a[dq.back()]<a[i])dq.pop_back();dq.pb(i);
      |                                                            ^~
peru.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int j=1;j<dq.size();j++){
      |                     ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -