Submission #709472

# Submission time Handle Problem Language Result Execution time Memory
709472 2023-03-13T16:15:02 Z TlenekWodoru Catfish Farm (IOI22_fish) C++17
0 / 100
141 ms 41096 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
struct RYBA
{
    int y,c;
    long long wynik=0;
    long long l=0,s=0,p=0;
    long long suma=0;
    RYBA(int yy=0, int cc=0)
    {
        y=yy;
        c=cc;
        wynik=0;
        l=0;s=0,p=0;
        suma=0;
    }
    bool operator <(const RYBA &B)const
    {
        return y<B.y;
    }
};
vector<RYBA>V[100009];
long long max_weights(int N, int M, vector<int>X, vector<int>Y, vector<int>W)
{
    for(int i=0;i<M;i++)
    {
        V[X[i]+1].push_back(RYBA(Y[i]+1,W[i]));
    }
    for(int i=1;i<=N;i++)
    {
        V[i].push_back({N+1,0});
        V[i].push_back({0,0});
        sort(V[i].begin(),V[i].end());
    }
    for(int i=2;i<=N;i++)
    {
        int Hl=0,Hp=0;
        long long l=0,p=0,s=0;
        for(int j=0;j<V[i].size();j++)
        {
            while(Hl<V[i-1].size()&&V[i-1][Hl].y<=V[i][j].y-1)
            {
                l+=V[i-1][Hl].c;
                Hl++;
            }
            while(Hp<V[i+1].size()&&V[i+1][Hp].y<=V[i][j].y-1)
            {
                p+=V[i+1][Hp].c;
                Hp++;
            }
            V[i][j].l=l;
            V[i][j].s=s;
            V[i][j].p=p;
            V[i][j].suma=l+s+p;
            s+=V[i][j].c;
        }
    }
    for(int i=0;i<V[1].size();i++)
    {
        V[1][i].wynik=V[1][i].suma;
    }
    long long WYNIK=0;
    for(int i=1;i<=N;i++)
    {
        int h;
        long long maxx;
        h=0;maxx=0;
        for(int j=0;j<V[i].size();j++)
        {
            if(h<V[i-1].size()&&V[i-1][h].y<=V[i][j].y-1)
            {
                maxx=max(maxx,V[i-1][h].wynik-V[i-1][h].s-V[i-1][h].p);
                h++;
            }
            V[i][j].wynik=max(V[i][j].wynik,maxx+V[i][j].suma);
        }
        h=V[i-1].size()-1;maxx=0;
        for(int j=V[i].size()-1;j>=0;j--)
        {
            if(h>=0&&V[i][j].y<V[i-1][h].y-1)
            {
                maxx=max(maxx,V[i-1][h].wynik);
                h--;
            }
            V[i][j].wynik=max(V[i][j].wynik,maxx+V[i][j].suma-V[i][j].s-V[i][j].l);
            WYNIK=max(WYNIK,V[i][j].wynik);
        }
    }
    return WYNIK;
}
/**int main()
{ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int X[4]={0, 1, 4, 3};
    int Y[4]={2, 1, 4, 3};
    int W[4]={5, 2, 1, 3};
    long long w=max_weights(5, 4, X, Y, Y);
    cout<<w<<endl;
    return 0;
}**/

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RYBA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j=0;j<V[i].size();j++)
      |                     ~^~~~~~~~~~~~
fish.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RYBA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             while(Hl<V[i-1].size()&&V[i-1][Hl].y<=V[i][j].y-1)
      |                   ~~^~~~~~~~~~~~~~
fish.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RYBA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             while(Hp<V[i+1].size()&&V[i+1][Hp].y<=V[i][j].y-1)
      |                   ~~^~~~~~~~~~~~~~
fish.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RYBA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0;i<V[1].size();i++)
      |                 ~^~~~~~~~~~~~
fish.cpp:69:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RYBA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         for(int j=0;j<V[i].size();j++)
      |                     ~^~~~~~~~~~~~
fish.cpp:71:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RYBA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             if(h<V[i-1].size()&&V[i-1][h].y<=V[i][j].y-1)
      |                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 50 ms 19512 KB Output is correct
2 Correct 69 ms 22336 KB Output is correct
3 Correct 17 ms 13524 KB Output is correct
4 Correct 16 ms 13524 KB Output is correct
5 Incorrect 141 ms 41096 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '299628921470958'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Incorrect 83 ms 26700 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 17 ms 13512 KB Output is correct
2 Correct 17 ms 13584 KB Output is correct
3 Incorrect 47 ms 20412 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '41472243198113'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 13512 KB Output is correct
2 Correct 17 ms 13584 KB Output is correct
3 Incorrect 47 ms 20412 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '41472243198113'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 19512 KB Output is correct
2 Correct 69 ms 22336 KB Output is correct
3 Correct 17 ms 13524 KB Output is correct
4 Correct 16 ms 13524 KB Output is correct
5 Incorrect 141 ms 41096 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '299628921470958'
6 Halted 0 ms 0 KB -