제출 #786844

#제출 시각아이디문제언어결과실행 시간메모리
786844andrei_boaca메기 농장 (IOI22_fish)C++17
35 / 100
1070 ms94464 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; vector<ll> suf; int lg=myy[i-1].size(); ll maxim=0; for(int j=lg-1;j>=0;j--) { int p1=myy[i-1][j].poz-1; maxim=max(maxim,max(dp[1][i-1][p1],dp[2][i-1][p1])); suf.push_back(maxim); } reverse(suf.begin(),suf.end()); for(ll j=0;j<myy[i].size();j++) { suma+=myy[i][j].val; ll p=myy[i][j].poz; ll st=0; ll dr=myy[i-1].size(); dr--; while(st<=dr) { ll mij=(st+dr)/2; if(myy[i-1][mij].poz-1>=p) { dp[0][i][p]=max(dp[0][i][p],suma+suf[mij]); dr=mij-1; } else st=mij+1; } 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][k].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:48: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]
   48 |         for(ll j=0;j<myy[i].size();j++)
      |                    ~^~~~~~~~~~~~~~
fish.cpp:70:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for(int j=0;j<myy[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
fish.cpp:76: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]
   76 |             for(ll k=0;k<myy[i-1].size();k++)
      |                        ~^~~~~~~~~~~~~~~~
fish.cpp:82: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]
   82 |             for(ll k=0;k<myy[i-1].size();k++)
      |                        ~^~~~~~~~~~~~~~~~
fish.cpp:99:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |         for(int j=0;j<myy[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
fish.cpp:109:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<date>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |             for(int k=0;k<myy[i-1].size();k++)
      |                         ~^~~~~~~~~~~~~~~~
fish.cpp:114: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]
  114 |                 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...