QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620469#3558. Constellation 3Dimash#0 3ms10620kbC++231.3kb2024-10-07 18:20:222024-10-07 18:20:23

Judging History

This is the latest submission verdict.

  • [2024-10-07 18:20:23]
  • Judged
  • Verdict: 0
  • Time: 3ms
  • Memory: 10620kb
  • [2024-10-07 18:20:22]
  • Submitted

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;
const int  N = 2e3 + 12, MOD = (int)1e9 + 7;

int n, m, a[N], x[N], y[N], c[N][N], sf[N][N];
ll dp[N][N], s[N];
void test() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] = n - a[i];
    }
    cin >> m;
    ll f = 0;
    for(int i = 1; i <= m; i++) {
        cin >> x[i] >> y[i];
        y[i] = n - y[i] + 1;
        cin >> c[x[i]][y[i]];
        f += c[x[i]][y[i]];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = a[i]; j >= 1; j--) {
            sf[i][j] = max(sf[i][j + 1], c[i][j]);
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= a[i]; j++) {
            // dp[i][j] = dp[i][j - 1];
            if(a[i - 1] >= j) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j] + sf[i - 1][j + 1]);
            } else {
                dp[i][j] = max(dp[i][j], s[i - 1]);
            }
            s[i] = max(s[i], dp[i][j] + c[i][j]);
            // cout << dp[i][j] + c[i][j] << ' ';
        }
        // cout << '\n';
        s[i] = max(s[i - 1], s[i]);
    }

    cout << f - s[n] << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 

    int t = 1; 
    // cin >> t;

    while(t--) 
        test();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 10620kb

input:

297
296 275 40 154 200 77 201 106 133 163 127 268 225 154 27 202 272 176 133 116 151 11 262 281 188 152 249 53 133 106 160 62 104 210 54 201 184 110 199 217 155 193 168 239 277 22 230 187 201 14 85 100 159 129 69 241 150 10 20 263 285 76 219 52 40 241 126 182 23 55 243 145 203 163 251 243 13 292 249...

output:

2514335

result:

wrong answer 1st lines differ - expected: '4354552', found: '2514335'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%