Submission #806325

# Submission time Handle Problem Language Result Execution time Memory
806325 2023-08-04T05:59:05 Z urd05 Fun Palace (CCO18_fun) C++17
3 / 25
154 ms 78620 KB
#include <bits/stdc++.h>
using namespace std;

int n;
int e;
int a[1000];
int b[1000];
int dp[1000][20001];
int temp[20001];
const int MAX=20000;
int nt[20005];

int main() {
    scanf("%d%d",&n,&e);
    for(int i=0;i<n-1;i++) {
        scanf("%d %d",&a[i],&b[i]);
    }
    for(int i=0;i<=MAX;i++) {
        dp[n-1][i]=i;
        nt[i]=-1;
    }
    for(int i=n-2;i>=0;i--) {
        temp[b[i]]=dp[i+1][b[i]]-b[i];
        for(int j=b[i]+1;j<=MAX;j++) {
            temp[j]=max(temp[j-1],dp[i+1][j]-j);
        }
        for(int j=0;j<=MAX;j++) {
            if (j>0) {
                dp[i][j]=max(dp[i][j],dp[i][j-1]);
            }
            dp[i][j]=max(dp[i][j],dp[i+1][j]);
            int now=0;
            if (j<a[i]) {
                now=dp[i+1][b[i]]+j;
            }
            else if (j<a[i]+b[i]) {
                now=dp[i+1][j-a[i]]+a[i];
            }
            else {
                now=dp[i+1][j];
            }
            dp[i][j]=max(dp[i][j],now);
        }
        for(int j=0;j<a[i]+b[i];j++) {
            nt[j]=i;
        }
    }
    printf("%d",dp[0][e-1]);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d%d",&n,&e);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d %d",&a[i],&b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 624 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Incorrect 154 ms 78620 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 624 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Incorrect 32 ms 16048 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 624 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Incorrect 154 ms 78620 KB Output isn't correct
17 Halted 0 ms 0 KB -