답안 #321206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321206 2020-11-11T13:56:32 Z wildturtle 선물상자 (IOI15_boxes) C++14
10 / 100
1 ms 388 KB
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,ans,dp[10000007],dp1[10000007];
long long delivery(int N, int K, int L, int p[]) {
    for(long long i=0;i<N;i++) {
        if(i<K) dp[i+1]=2*p[i];
        else dp[i+1]=2*p[i]+dp[i-K+1];
     //   cout<<dp[i+1]<<" ";
    }
    //cout<<endl;
    for(long long i=N-1;i>=0;i--) {
        if(i<N-K+1) dp1[i+1]=2*(L-p[i]);
        else dp1[i+1]=2*(L-p[i])+dp1[i+K+1];
      //  cout<<dp1[i+1]<<" ";
    }
    //cout<<endl;
    //cout<<ans<<endl;
    ans=min(dp[N],dp1[1]);
    for(long long i=1;i<=N-K+1;i++) {
        ans=min(ans,dp[i-1]+L+dp1[i+K]);
    }
    for(long long i=1;i<N;i++)
    ans=min(ans,dp[i]+dp1[i+1]);
    return ans;
}/*
int main() {
    int A[]={1,2,5};
    cout<<delivery(3,2,8,A);
}*/

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:6:19: warning: declaration of 'i' shadows a global declaration [-Wshadow]
    6 |     for(long long i=0;i<N;i++) {
      |                   ^
boxes.cpp:4:19: note: shadowed declaration is here
    4 | long long a,b,c,d,i,e,f,g,n,m,k,l,ans,dp[10000007],dp1[10000007];
      |                   ^
boxes.cpp:12:19: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   12 |     for(long long i=N-1;i>=0;i--) {
      |                   ^
boxes.cpp:4:19: note: shadowed declaration is here
    4 | long long a,b,c,d,i,e,f,g,n,m,k,l,ans,dp[10000007],dp1[10000007];
      |                   ^
boxes.cpp:20:19: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   20 |     for(long long i=1;i<=N-K+1;i++) {
      |                   ^
boxes.cpp:4:19: note: shadowed declaration is here
    4 | long long a,b,c,d,i,e,f,g,n,m,k,l,ans,dp[10000007],dp1[10000007];
      |                   ^
boxes.cpp:23:19: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   23 |     for(long long i=1;i<N;i++)
      |                   ^
boxes.cpp:4:19: note: shadowed declaration is here
    4 | long long a,b,c,d,i,e,f,g,n,m,k,l,ans,dp[10000007],dp1[10000007];
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 388 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -