Submission #925192

# Submission time Handle Problem Language Result Execution time Memory
925192 2024-02-11T00:38:39 Z IS_Rushdi Catfish Farm (IOI22_fish) C++17
0 / 100
88 ms 8040 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;


long long max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
    // long long pre[n+1][n+1]{};
    // for(int i = 0; i < m; i++) x[i]++,y[i]++;
    // for(int i = 0; i < m; i++) pre[x[i]][y[i]] += w[i];
    // for(int i = 1; i <= n; i++){
    //     for(int j = 1; j <= n; j++){
    //         pre[i][j] += pre[i][j-1];
    //     }
    // }
    
    long long ans = 0;
    long long ans2 = 0;
    int cost[n][2]{};
    for(int i = 0; i < m; i++){
        if(x[i] == 1){cost[y[i]][1] = w[i]; ans += w[i];}
        if(x[i] == 0){ans2 += w[i];cost[y[i]][0]=w[i];}
    }
    if(n == 2) return max(ans,ans2);
    ans2 = max(ans,ans2);
    
    for(int i = 1; i < n; i++){
        ans -= cost[i-1][1];
        ans += cost[i][0];

        ans2 = max(ans2,ans);
    }
    return ans2;
}

// int main(){
//     cout << max_weights(5, 4, {0, 1, 4, 3}, {2, 1, 4, 3}, {5, 2, 1, 3}) << '\n';
// }
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2904 KB Output is correct
2 Correct 23 ms 3416 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Incorrect 88 ms 8040 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '0'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1116 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: '1'
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: '1'
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: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1116 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 19 ms 2904 KB Output is correct
2 Correct 23 ms 3416 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Incorrect 88 ms 8040 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '0'
6 Halted 0 ms 0 KB -