Submission #886021

# Submission time Handle Problem Language Result Execution time Memory
886021 2023-12-11T11:42:25 Z thinknoexit Catfish Farm (IOI22_fish) C++17
0 / 100
99 ms 23976 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
using ll = long long;
struct A {
    int v, w;
    ll ans;
    bool operator < (const A& o) const {
        return v < o.v;
    }
};
vector<A> pos[100100];
int n, m;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    for (int i = 0;i < M;i++) {
        pos[X[i] + 1].push_back({ Y[i] + 1, W[i], 0 });
    }
    pos[0].push_back({ 0, 0, 0 });
    for (int i = 1;i <= N;i++) {
        pos[i].push_back({ 0, 0, 0 });
        sort(pos[i].begin(), pos[i].end());
        int n = pos[i - 1].size(), m = pos[i].size();
        // a[i-1] <= a[i]
        ll sum = 0;
        ll mx = 0;
        for (int j = 0, p = 0;j < m;j++) {
            while (p < n && pos[i - 1][p].v <= pos[i][j].v) {
                sum += pos[i - 1][p].w;
                mx = max(mx, pos[i - 1][p].ans - sum);
                p++;
            }
            pos[i][j].ans = max(pos[i][j].ans, sum + mx);
        }
        // a[i-1] > a[i]
        sum = 0;
        mx = 0;
        for (int j = m - 1, p = n - 1;j >= 0;j--) {
            sum += pos[i][j].w;
            while (p >= 0 && pos[i - 1][p].v >= pos[i][j].v) {
                mx = max(mx, pos[i - 1][p].ans - sum);
                p--;
            }
            pos[i][j].ans = max(pos[i][j].ans, sum + mx);
        }
    }
    ll mx = 0;
    for (auto& x : pos[N]) {
        mx = max(mx, x.ans);
    }
    return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 30 ms 10084 KB Output is correct
2 Correct 36 ms 11456 KB Output is correct
3 Correct 7 ms 5724 KB Output is correct
4 Correct 8 ms 5724 KB Output is correct
5 Incorrect 99 ms 23976 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '44945481875572'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Incorrect 56 ms 14656 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80843694005164'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5724 KB Output is correct
2 Correct 7 ms 5788 KB Output is correct
3 Incorrect 22 ms 8920 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '14779656400360'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5724 KB Output is correct
2 Correct 7 ms 5788 KB Output is correct
3 Incorrect 22 ms 8920 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '14779656400360'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 10084 KB Output is correct
2 Correct 36 ms 11456 KB Output is correct
3 Correct 7 ms 5724 KB Output is correct
4 Correct 8 ms 5724 KB Output is correct
5 Incorrect 99 ms 23976 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '44945481875572'
6 Halted 0 ms 0 KB -