Submission #858218

# Submission time Handle Problem Language Result Execution time Memory
858218 2023-10-07T16:02:18 Z vjudge1 Catfish Farm (IOI22_fish) C++17
9 / 100
68 ms 7284 KB
#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Fish = array<int, 3>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

void setIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int64_t max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
    bool even = true;
    bool sub2 = true;

    for(int i=0; i<m; i++) {
        if(x[i] % 2 == 1) even = false;
        if(x[i] > 1) sub2 = false;
    }

    if(even) {
        ll ans = 0;
        for(int &x : w) ans += x;
        return ans;
    }

    if(sub2) {
        ll ans = 0;

        ll prefix[n][2];
        memset(prefix, 0, sizeof(prefix));
        for(int i=0; i<m; i++)
            prefix[y[i]][x[i]] += w[i];

        for(int i=1; i<n; i++) {
            prefix[i][0] += prefix[i-1][0];
            prefix[i][1] += prefix[i-1][1];
        }

        if(n == 2) return max(prefix[n-1][0], prefix[n-1][1]);

        for(int i=0; i<n; i++) {
            ll res = 0;
            res += prefix[i][0];
            res += prefix[n-1][1];
            res -= prefix[i][1];
            ans = max(ans, res);

            ll res2 = 0;
            ans = max(ans, res2);
        }

        return max({ ans, prefix[n-1][0], prefix[n-1][1] });
    }

    return 0;
}

// int32_t main() {
//     setIO();

//     int n, m;
//     cin >> n >> m;

//     vector<int> x(m), y(m), w(m);
//     for(int i=0; i<m; i++)
//         cin >> x[i] >> y[i] >> w[i];
    
//     cout << max_weights(n, m, x, y, w) << '\n';
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2140 KB Output is correct
2 Correct 21 ms 2636 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 68 ms 7284 KB Output is correct
6 Correct 68 ms 7248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 37 ms 5468 KB Output is correct
3 Correct 45 ms 6484 KB Output is correct
4 Correct 18 ms 2164 KB Output is correct
5 Correct 23 ms 2908 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 19 ms 3676 KB Output is correct
13 Correct 23 ms 4180 KB Output is correct
14 Correct 20 ms 4964 KB Output is correct
15 Correct 22 ms 5720 KB Output is correct
16 Correct 20 ms 4952 KB Output is correct
17 Correct 21 ms 5468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 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 348 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 348 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 348 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 344 KB Output is correct
2 Incorrect 0 ms 348 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 17 ms 2140 KB Output is correct
2 Correct 21 ms 2636 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 68 ms 7284 KB Output is correct
6 Correct 68 ms 7248 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 37 ms 5468 KB Output is correct
9 Correct 45 ms 6484 KB Output is correct
10 Correct 18 ms 2164 KB Output is correct
11 Correct 23 ms 2908 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 19 ms 3676 KB Output is correct
19 Correct 23 ms 4180 KB Output is correct
20 Correct 20 ms 4964 KB Output is correct
21 Correct 22 ms 5720 KB Output is correct
22 Correct 20 ms 4952 KB Output is correct
23 Correct 21 ms 5468 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
26 Halted 0 ms 0 KB -