Submission #1035852

# Submission time Handle Problem Language Result Execution time Memory
1035852 2024-07-26T16:52:35 Z Andrey Catfish Farm (IOI22_fish) C++17
3 / 100
140 ms 56144 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;

vector<pair<long long,long long>> haha[150000];
vector<long long> dp[150000][3];

long long max_weights(int n, int m, vector<int> x, vector<int> y,  vector<int> w) {
    for(long long i = 0; i < m; i++) {
        haha[x[i]+1].push_back({y[i],w[i]});
    }
    haha[0].push_back({0,0});
    for(long long i = 0; i <= n; i++) {
        haha[i].push_back({n,0});
        sort(haha[i].begin(),haha[i].end());
        for(long long j = 1; j < haha[i].size(); j++) {
            haha[i][j] = {haha[i][j].first,haha[i][j].second+haha[i][j-1].second};
        }
        for(long long j = haha[i].size()-1; j >= 1; j--) {
            haha[i][j] = {haha[i][j].first,haha[i][j-1].second};
        }
        haha[i][0] = {haha[i][0].first,0};
    }
    long long ans = 0;
    dp[0][0].push_back(0);
    dp[0][1].push_back(-LLONG_MAX/2);
    dp[0][2].push_back(-LLONG_MAX/2);
    dp[0][0].push_back(-LLONG_MAX/2);
    dp[0][1].push_back(-LLONG_MAX/2);
    dp[0][2].push_back(-LLONG_MAX/2);
    for(long long i = 1; i <= n; i++) {
        for(long long j = 0; j < haha[i].size(); j++) {
            dp[i][0].push_back(-LLONG_MAX/2);
            dp[i][1].push_back(-LLONG_MAX/2);
            dp[i][2].push_back(-LLONG_MAX/2);
        }
        long long x = -LLONG_MAX/2,y = haha[i-1].size()-1;
        for(long long j = haha[i].size()-1; j >= 0; j--) {
            while(y >= 0 && (j == 0 || haha[i-1][y].first > haha[i][j-1].first)) {
                x = max(x,max(dp[i-1][2][y],dp[i-1][0][y])+haha[i][j].second);
                y--;
            }
            dp[i][2][j] = max(dp[i][2][j],x-haha[i][j].second);
        }
        y = 0;
        for(long long j = 0; j < haha[i].size(); j++) {
            while(y < haha[i-1].size() && (y == 0 || haha[i-1][y-1].first < haha[i][j].first)) {
                dp[i][1][j] = max(dp[i][1][j],max(dp[i-1][0][y],dp[i-1][2][y])+haha[i][j].second);
                y++;
            }
        }
        x = -LLONG_MAX/2;
        y = 0;
        for(long long j = 0; j < haha[i].size(); j++) {
            while(y < haha[i-1].size() && (y == 0 || haha[i-1][y-1].first < haha[i][j].first)) {
                x = max(x,dp[i-1][1][y]-haha[i-1][y].second);
                x = max(x,dp[i-1][0][y]-haha[i-1][y].second);
                y++;
            }
            dp[i][0][j] = max(dp[i][0][j],x+haha[i-1][y-1].second);
        }
        x = -LLONG_MAX/2;
        y = haha[i-1].size()-1;
        for(long long j = haha[i].size()-1; j >= 0; j--) {
            while(y >= 0 && (j == 0 || haha[i-1][y].first > haha[i][j-1].first)) {
                x = max(x,dp[i-1][1][y]);
                y--;
            }
            dp[i][0][j] = max(dp[i][0][j],x);
        }
    }
    for(long long i = 0; i < haha[n].size(); i++) {
        ans = max(ans,dp[n][i][0]);
        ans = max(ans,dp[n][i][1]);
        ans = max(ans,dp[n][i][2]);
    }
    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:16:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(long long j = 1; j < haha[i].size(); j++) {
      |                              ~~^~~~~~~~~~~~~~~~
fish.cpp:32:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(long long j = 0; j < haha[i].size(); j++) {
      |                              ~~^~~~~~~~~~~~~~~~
fish.cpp:46:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(long long j = 0; j < haha[i].size(); j++) {
      |                              ~~^~~~~~~~~~~~~~~~
fish.cpp:47:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             while(y < haha[i-1].size() && (y == 0 || haha[i-1][y-1].first < haha[i][j].first)) {
      |                   ~~^~~~~~~~~~~~~~~~~~
fish.cpp:54:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(long long j = 0; j < haha[i].size(); j++) {
      |                              ~~^~~~~~~~~~~~~~~~
fish.cpp:55:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             while(y < haha[i-1].size() && (y == 0 || haha[i-1][y-1].first < haha[i][j].first)) {
      |                   ~~^~~~~~~~~~~~~~~~~~
fish.cpp:72:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for(long long i = 0; i < haha[n].size(); i++) {
      |                          ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 45 ms 32448 KB Output is correct
2 Correct 52 ms 35300 KB Output is correct
3 Correct 23 ms 26836 KB Output is correct
4 Correct 22 ms 26872 KB Output is correct
5 Correct 112 ms 53768 KB Output is correct
6 Correct 140 ms 56144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14424 KB Output is correct
2 Correct 68 ms 39116 KB Output is correct
3 Correct 85 ms 43332 KB Output is correct
4 Correct 45 ms 32592 KB Output is correct
5 Correct 50 ms 35320 KB Output is correct
6 Incorrect 10 ms 14428 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 26968 KB Output is correct
2 Incorrect 22 ms 26968 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 6 ms 14424 KB Output is correct
2 Correct 6 ms 14428 KB Output is correct
3 Incorrect 6 ms 14428 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14424 KB Output is correct
2 Correct 6 ms 14428 KB Output is correct
3 Incorrect 6 ms 14428 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14424 KB Output is correct
2 Correct 6 ms 14428 KB Output is correct
3 Incorrect 6 ms 14428 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 26968 KB Output is correct
2 Incorrect 22 ms 26968 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 45 ms 32448 KB Output is correct
2 Correct 52 ms 35300 KB Output is correct
3 Correct 23 ms 26836 KB Output is correct
4 Correct 22 ms 26872 KB Output is correct
5 Correct 112 ms 53768 KB Output is correct
6 Correct 140 ms 56144 KB Output is correct
7 Correct 6 ms 14424 KB Output is correct
8 Correct 68 ms 39116 KB Output is correct
9 Correct 85 ms 43332 KB Output is correct
10 Correct 45 ms 32592 KB Output is correct
11 Correct 50 ms 35320 KB Output is correct
12 Incorrect 10 ms 14428 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
13 Halted 0 ms 0 KB -