Submission #1068239

# Submission time Handle Problem Language Result Execution time Memory
1068239 2024-08-21T08:48:01 Z Unforgettablepl Catfish Farm (IOI22_fish) C++17
9 / 100
96 ms 13016 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);
        sum-=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 24 ms 3272 KB Output is correct
2 Correct 24 ms 3780 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 96 ms 13016 KB Output is correct
6 Correct 82 ms 12740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 43 ms 5836 KB Output is correct
3 Correct 50 ms 10180 KB Output is correct
4 Correct 20 ms 4696 KB Output is correct
5 Correct 29 ms 5576 KB Output is correct
6 Correct 0 ms 344 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 348 KB Output is correct
12 Correct 21 ms 4820 KB Output is correct
13 Correct 28 ms 5692 KB Output is correct
14 Correct 23 ms 4476 KB Output is correct
15 Correct 25 ms 5072 KB Output is correct
16 Correct 22 ms 4716 KB Output is correct
17 Correct 26 ms 5108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 13 ms 2244 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '13412238152019'
4 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: '2'
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: '2'
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: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 13 ms 2244 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '13412238152019'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3272 KB Output is correct
2 Correct 24 ms 3780 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 96 ms 13016 KB Output is correct
6 Correct 82 ms 12740 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 43 ms 5836 KB Output is correct
9 Correct 50 ms 10180 KB Output is correct
10 Correct 20 ms 4696 KB Output is correct
11 Correct 29 ms 5576 KB Output is correct
12 Correct 0 ms 344 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 348 KB Output is correct
18 Correct 21 ms 4820 KB Output is correct
19 Correct 28 ms 5692 KB Output is correct
20 Correct 23 ms 4476 KB Output is correct
21 Correct 25 ms 5072 KB Output is correct
22 Correct 22 ms 4716 KB Output is correct
23 Correct 26 ms 5108 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Incorrect 13 ms 2244 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '13412238152019'
27 Halted 0 ms 0 KB -