제출 #795454

#제출 시각아이디문제언어결과실행 시간메모리
795454ln_e메기 농장 (IOI22_fish)C++17
9 / 100
72 ms10352 KiB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho #include "fish.h" using ll=long long; using ld=long double; int const INF=1000000005; ll const LINF=1000000000000000005; ll const mod=1000000007; ld const PI=3.14159265359; ll const MAX_N=3e5+5; ld const EPS=0.00000001; #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define f first #define s second #define pb push_back #define mp make_pair #define endl '\n' #define sz(a) (int)a.size() #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; long long pref[100005][3],a[100005][3],sum[5005][5005],suf[100005][3]; bool check1(vector<int>x){ for(ll i=0;i<x.size();i++) { if(x[i]%2==1){ return 0; } } return 1; } bool check2(vector<int>x){ for(ll i=0;i<x.size();i++) { if(x[i]>1){ return 0; } } return 1; } bool check3(vector<int>y){ for(ll i=0;i<y.size();i++){ if(y[i]!=0){ return 0; } } return 1; } long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { if(check1(X)){ ll ans=0; for(ll i=0;i<M;i++) { ans+=W[i]; } return ans; }else if(check2(X)){ ll sum1=0,sum2=0,ans=0; for(ll i=0;i<M;i++) { if(X[i]==0){ sum1+=W[i]; }else sum2+=W[i]; } ans=max(sum1,sum2); if(N>2){ int x[3][100005]; for(int i=0;i<=1;i++) { for(ll j=0;j<N;j++) { x[i][j]=0; } } for(int i=0;i<M;i++) { x[X[i]][Y[i]]=W[i]; } ll sum2[100005]; memset(sum2,0,sizeof(sum2)); for(ll i=0;i<N;i++) { if(i-1>=0){ sum2[i]=sum2[i-1]; } sum2[i]+=x[0][i]; } ll idk=0; for(ll i=N-1;i>=1;i--) { idk+=x[1][i]; ans=max(ans,idk+sum2[i-1]); } } return ans; }else if(check3(Y)){ return 0; ll ans=0; pref[0][1]=-LINF; pref[0][2]=-LINF; for(ll i=1;i<=N;i++){ pref[i][0]=pref[i-1][0]; pref[i][1]=max(pref[i-1][0]+a[i-1][1],pref[i-1][2]); pref[i][2]=max(pref[i-1][1]+a[i][1],pref[i-1][2]+a[i][1]); } ans=max(pref[N][0],max(pref[N][1],pref[N][2])); return ans; }else { return 0; } }

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

fish.cpp: In function 'bool check1(std::vector<int>)':
fish.cpp:23:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(ll i=0;i<x.size();i++)
      |                    ~^~~~~~~~~
fish.cpp: In function 'bool check2(std::vector<int>)':
fish.cpp:32:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(ll i=0;i<x.size();i++)
      |                ~^~~~~~~~~
fish.cpp: In function 'bool check3(std::vector<int>)':
fish.cpp:41:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 | for(ll i=0;i<y.size();i++){
      |            ~^~~~~~~~~
#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...