Submission #584857

# Submission time Handle Problem Language Result Execution time Memory
584857 2022-06-28T05:31:24 Z 조영욱(#8382) 도장 모으기 (JOI14_stamps) C++14
0 / 100
1000 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

int n;
long long t;
long long dp[3002];
long long u[3002];
long long v[3002];
long long d[3002];
long long e[3002];

long long f(int l,int r) {
    assert(l<=n+1&&r<=n+1);
    if (l>r) {
        return 0;
    }
    long long ret=0;
    for(int i=l;i<=r;i++) {
        ret+=u[i]+v[i];
    }
    return ret;
}

long long g(int l,int r) {
    assert(l<=n+1&&r<=n+1);
    if (l>r) {
        return 0;
    }
    long long ret=0;
    for(int i=l;i<=r;i++) {
        ret+=min(u[i]+v[i],d[i]+e[i]);
    }
    return ret;
}

int main(void) {
    scanf("%d %lld",&n,&t);
    for(int i=1;i<=n;i++) {
        scanf("%lld %lld %lld %lld",&u[i],&v[i],&d[i],&e[i]);
    }
    for(int i=1;i<=n+1;i++) {
        dp[i]=1e18;
        for(int j=0;j<i;j++) {
            for(int k=0;k<=i;k++) {
                dp[i]=min(dp[i],dp[j]+f(j+1,k-1)+v[k]+d[k]+g(max(j+1,k+1),i-1)+u[i]+e[i]+(i-j)*t+2*(i-k)*t);
            }
        }
    }
    printf("%lld",dp[n+1]);
}

Compilation message

stamps.cpp: In function 'int main()':
stamps.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %lld",&n,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~
stamps.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         scanf("%lld %lld %lld %lld",&u[i],&v[i],&d[i],&e[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 424 KB Time limit exceeded
2 Halted 0 ms 0 KB -