QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#884932#9879. ReTravelRyan123WA 28ms7756kbC++14834b2025-02-06 11:55:192025-02-06 11:55:31

Judging History

This is the latest submission verdict.

  • [2025-02-06 11:55:31]
  • Judged
  • Verdict: WA
  • Time: 28ms
  • Memory: 7756kb
  • [2025-02-06 11:55:19]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 505;

int mnx[N][N], mny[N][N];
int x[N], y[N];
long long f[N][N];

int main(){
    int n;
    scanf("%d", &n);

    for(int i = 1; i <= n; i ++)scanf("%d%d", &x[i], &y[i]);

    for(int i = 1; i <= n; i ++){
        mnx[i][i] = x[i], mny[i][i] = y[i];
        for(int j = i + 1; j <= n; j ++){
            mnx[i][j] = min(mnx[i][j - 1], x[j]);
            mny[i][j] = min(mny[i][j - 1], y[j]);
        }
    }

    for(int l = n; l >= 1; l --){
        f[l][l] = x[l] + y[l];
        for(int r = l + 1; r <= n; r ++){
            f[l][r] = 2e18;
            for(int k = 1; k < r; k ++){
                f[l][r] = min(f[l][r], f[l][k] + f[k + 1][r]);
            }
            f[l][r] -= mnx[l][r] + mny[l][r];
        }
    }

    printf("%lld\n", f[1][n]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5964kb

input:

2
3 3
1 2

output:

6

result:

ok "6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 5964kb

input:

3
2 2
3 3
1 3

output:

7

result:

ok "7"

Test #3:

score: -100
Wrong Answer
time: 28ms
memory: 7756kb

input:

500
906691059 413653999
813847339 955892128
451585301 43469773
278009742 548977048
521760889 434794718
985946604 841597326
891047768 325679554
511742081 384452587
626401695 957413342
975078788 234551094
541903389 149544006
302621084 150050891
811538590 101823753
663968655 858351976
268979133 9768326...

output:

-260834067979

result:

wrong answer 1st words differ - expected: '202616034783', found: '-260834067979'