Submission #1068235

# Submission time Handle Problem Language Result Execution time Memory
1068235 2024-08-21T08:46:53 Z Unforgettablepl Catfish Farm (IOI22_fish) C++17
3 / 100
85 ms 18244 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){
    if(N==2){
        long long a = 0;
        long long b = 0;
        for(int i=0;i<X.size();i++) {
            if(X[i]&1)b+=W[i];
            else a+=W[i];
        }
        return max(a,b);
    }
    vector<pair<int,int>> pointsa,pointsb;
    long long sum = 0;
    for(int i=0;i<X.size();i++) {
        if(X[i]&1) {
            pointsb.emplace_back(Y[i],W[i]);
            sum+=W[i];
        } else pointsa.emplace_back(Y[i],W[i]);
    }
    sort(pointsa.begin(), pointsa.end());
    sort(pointsb.begin(), pointsb.end());
    pointsb.emplace_back(N+1,0);
    long long ans = 0;
    auto iter = pointsa.begin();
    for(auto&[ht,wt]:pointsb) {
        while(iter!=pointsa.end() and iter->first<ht)sum+=(iter++)->second;
        ans = max(ans,sum);
        ans-=wt;
    }
    return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         for(int i=0;i<X.size();i++) {
      |                     ~^~~~~~~~~
fish.cpp:18:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0;i<X.size();i++) {
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 4816 KB Output is correct
2 Correct 28 ms 5320 KB Output is correct
3 Correct 0 ms 428 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 85 ms 17676 KB Output is correct
6 Correct 83 ms 18244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 41 ms 8392 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 19 ms 3188 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 19 ms 3188 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 4816 KB Output is correct
2 Correct 28 ms 5320 KB Output is correct
3 Correct 0 ms 428 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 85 ms 17676 KB Output is correct
6 Correct 83 ms 18244 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 41 ms 8392 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
9 Halted 0 ms 0 KB -