제출 #786767

#제출 시각아이디문제언어결과실행 시간메모리
786767andrei_boaca메기 농장 (IOI22_fish)C++17
0 / 100
1068 ms94300 KiB
#include "fish.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
typedef long long ll;
ll n,m;
struct date
{
    ll poz,val;
};
vector<date> myy[100005];
ll dp[3][3005][3005];
bool comp(date a, date b)
{
    return a.poz<b.poz;
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    n=N;
    m=M;
    for(int i=0;i<m;i++)
    {
        ll x=X[i];
        ll y=Y[i];
        ll w=W[i];
        myy[x+1].push_back({y+1,w});
    }
    for(int i=1;i<=n;i++)
    {
        myy[i].push_back({0,0});
        myy[i].push_back({n+1,0});
        sort(myy[i].begin(),myy[i].end(),comp);
    }
    ll ans=0;
    for(int i=2;i<=n;i++)
    {
        // neutru
        ll suma=0;
        for(ll j=0;j<myy[i].size();j++)
        {
            suma+=myy[i][j].val;
            ll p=myy[i][j].poz;
            for(ll k=0;k<myy[i-1].size();k++)
            {
                ll p1=myy[i-1][k].poz-1;
                if(p1>=p)
                    dp[0][i][p]=max(dp[0][i][p],suma+max(dp[1][i-1][p1],dp[2][i-1][p1]));
            }
            ans=max(ans,dp[0][i][p]);
        }

        // cresc
        for(int j=0;j<myy[i].size();j++)
        {
            ll p=myy[i][j].poz-1;
            if(p<0)
                continue;
            ll s1=0;
            for(ll k=0;k<myy[i-1].size();k++)
            {
                if(myy[i-1][k].poz<=p)
                    s1+=myy[i-1][k].val;
            }
            ll s2=0;
            for(ll k=0;k<myy[i-1].size();k++)
            {
                ll poz=myy[i-1][k].poz-1;
                if(poz>=0)
                {
                    ll val=dp[1][i-1][poz]+max(0LL,s1-s2);
                    dp[1][i][p]=max(dp[1][i][p],val);
                }
                s2+=myy[i-1][k].val;
                poz++;
                ll val=dp[0][i-1][poz]+max(0LL,s1-s2);
                dp[1][i][p]=max(dp[1][i][p],val);
            }
            ans=max(ans,dp[1][i][p]);
        }

        // desc
        for(int j=0;j<myy[i].size();j++)
        {
            ll p=myy[i][j].poz-1;
            if(p<0)
                continue;
            ll s2=0;
            for(int k=0;k<j;k++)
                s2+=myy[i][k].val;
            ll poz=0;
            ll s1=0;
            for(int k=0;k<myy[i-1].size();k++)
            {
                ll p1=myy[i-1][j].poz-1;
                if(p1<0)
                    continue;
                while(poz<myy[i].size()&&myy[i][poz].poz<=p1)
                {
                    s1+=myy[i][poz].val;
                    poz++;
                }
                ll val=max(dp[1][i-1][p1],dp[2][i-1][p1])+max(0LL,s1-s2);
                dp[2][i][p]=max(dp[2][i][p],val);
            }
            ans=max(ans,dp[2][i][p]);
        }
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:38:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(ll j=0;j<myy[i].size();j++)
      |                    ~^~~~~~~~~~~~~~
fish.cpp:42:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for(ll k=0;k<myy[i-1].size();k++)
      |                        ~^~~~~~~~~~~~~~~~
fish.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int j=0;j<myy[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
fish.cpp:58:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for(ll k=0;k<myy[i-1].size();k++)
      |                        ~^~~~~~~~~~~~~~~~
fish.cpp:64:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             for(ll k=0;k<myy[i-1].size();k++)
      |                        ~^~~~~~~~~~~~~~~~
fish.cpp:81:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |         for(int j=0;j<myy[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
fish.cpp:91:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |             for(int k=0;k<myy[i-1].size();k++)
      |                         ~^~~~~~~~~~~~~~~~
fish.cpp:96:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |                 while(poz<myy[i].size()&&myy[i][poz].poz<=p1)
      |                       ~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...