이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) {
for(ll i=0;i<M;i++)
{
a[X[i]+1][Y[i]+1]+=W[i];
}
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);
return ans;
}else if(check3(Y)){
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][1],max(pref[i-1][0]+a[i-1][1],pref[i-1][2]));
pref[i][2]=max(pref[i-1][0],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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |