Submission #625495

# Submission time Handle Problem Language Result Execution time Memory
625495 2022-08-10T13:43:56 Z I_love_Hoang_Yen Catfish Farm (IOI22_fish) C++17
9 / 100
94 ms 19796 KB
#include "bits/stdc++.h"
using namespace std;

#define int long long
struct Fish {
    int col, row;
    int weight;
};
bool operator < (const Fish& a, const Fish& b) {
    if (a.col != b.col) return a.col < b.col;
    return a.row < b.row;
}

// fishes are on even columns -> build piers on odd columns
// & catch all fishes
int sub1(const std::vector<Fish>& fishes) {
    int res = 0;
    for (const auto& fish : fishes) {
        res += fish.weight;
    }
    return res;
}

// fishes are on first 2 columns
int sub2(int n, const std::vector<Fish>& fishes) {
    std::vector<int> zeroes(n);  // prefix sum of fish weights at column == 0
    std::vector<int> ones(n);    // prefix sum of fish weights at column == 1
    for (const auto& fish : fishes) {
        if (fish.col == 0) zeroes[fish.row] += fish.weight;
        if (fish.col == 1) ones[fish.row] += fish.weight;
    }

    std::partial_sum(zeroes.begin(), zeroes.end(), zeroes.begin());
    std::partial_sum(ones.begin(), ones.end(), ones.begin());

    int res = ones.back();  // init: only catch fishes at column == 1
    for (int i = 0; i < n; ++i) {
        // build pier until at column 1, row 0-i
        if (n == 2) res = std::max(res, zeroes[i]);
        else res = std::max(res, zeroes[i] + ones.back() - ones[i]);
    }
    return res;
}

#undef int
long long max_weights(
        int n, int nFish,
        std::vector<int> xs,
        std::vector<int> ys,
        std::vector<int> ws) {
    std::vector<Fish> fishes;
    for (int i = 0; i < nFish; ++i) {
        fishes.push_back({xs[i], ys[i], ws[i]});
    }

    if (std::all_of(xs.begin(), xs.end(), [] (int x) { return x % 2 == 0; })) {
        return sub1(fishes);
    }
    if (*std::max_element(xs.begin(), xs.end()) <= 1) {
        return sub2(n, fishes);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 5320 KB Output is correct
2 Correct 29 ms 5808 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 93 ms 19796 KB Output is correct
6 Correct 94 ms 19792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 50 ms 10384 KB Output is correct
3 Correct 64 ms 11204 KB Output is correct
4 Correct 23 ms 5320 KB Output is correct
5 Correct 31 ms 5804 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 26 ms 5448 KB Output is correct
13 Correct 30 ms 6460 KB Output is correct
14 Correct 26 ms 5468 KB Output is correct
15 Correct 30 ms 6088 KB Output is correct
16 Correct 26 ms 5476 KB Output is correct
17 Correct 30 ms 6084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 5320 KB Output is correct
2 Correct 29 ms 5808 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 93 ms 19796 KB Output is correct
6 Correct 94 ms 19792 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 50 ms 10384 KB Output is correct
9 Correct 64 ms 11204 KB Output is correct
10 Correct 23 ms 5320 KB Output is correct
11 Correct 31 ms 5804 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 26 ms 5448 KB Output is correct
19 Correct 30 ms 6460 KB Output is correct
20 Correct 26 ms 5468 KB Output is correct
21 Correct 30 ms 6088 KB Output is correct
22 Correct 26 ms 5476 KB Output is correct
23 Correct 30 ms 6084 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
26 Halted 0 ms 0 KB -