Submission #724352

#TimeUsernameProblemLanguageResultExecution timeMemory
724352raul2008487Catfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include "fish.h" #include <vector> long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { long long i,ans=0; if(N==2){ ll ans1=0,ans2=0; for(i=0;i<W.size();i++){ if(X[i]==1){ ans1+=W[i]; } else{ ans2+=W[i]; } } if(ans1>ans2){ return ans1; } else{ return ans2; } } else{ ll cur1=0,cur2=0,w1=0; for(i=0;i<W.size();i++){ if(X[i]==1){ w1+=W[i]; } } ll cx=0; for(i=0;i<W.size();i++){ if(X[i]==0){ cur1+=W[i]; } else{ cur2+=W[i]; } if((cur1-cur2)>cx){ cx=cur1-cur2; } } return w1+cx; } }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:8:9: error: 'll' was not declared in this scope
    8 |         ll ans1=0,ans2=0;
      |         ^~
fish.cpp:9:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |         for(i=0;i<W.size();i++){
      |                 ~^~~~~~~~~
fish.cpp:11:17: error: 'ans1' was not declared in this scope; did you mean 'ans'?
   11 |                 ans1+=W[i];
      |                 ^~~~
      |                 ans
fish.cpp:14:17: error: 'ans2' was not declared in this scope; did you mean 'ans'?
   14 |                 ans2+=W[i];
      |                 ^~~~
      |                 ans
fish.cpp:17:12: error: 'ans1' was not declared in this scope; did you mean 'ans'?
   17 |         if(ans1>ans2){
      |            ^~~~
      |            ans
fish.cpp:17:17: error: 'ans2' was not declared in this scope; did you mean 'ans'?
   17 |         if(ans1>ans2){
      |                 ^~~~
      |                 ans
fish.cpp:25:9: error: 'll' was not declared in this scope
   25 |         ll cur1=0,cur2=0,w1=0;
      |         ^~
fish.cpp:26:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(i=0;i<W.size();i++){
      |                 ~^~~~~~~~~
fish.cpp:28:17: error: 'w1' was not declared in this scope
   28 |                 w1+=W[i];
      |                 ^~
fish.cpp:31:11: error: expected ';' before 'cx'
   31 |         ll cx=0;
      |           ^~~
      |           ;
fish.cpp:32:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(i=0;i<W.size();i++){
      |                 ~^~~~~~~~~
fish.cpp:34:17: error: 'cur1' was not declared in this scope
   34 |                 cur1+=W[i];
      |                 ^~~~
fish.cpp:37:17: error: 'cur2' was not declared in this scope
   37 |                 cur2+=W[i];
      |                 ^~~~
fish.cpp:39:17: error: 'cur1' was not declared in this scope
   39 |             if((cur1-cur2)>cx){
      |                 ^~~~
fish.cpp:39:22: error: 'cur2' was not declared in this scope
   39 |             if((cur1-cur2)>cx){
      |                      ^~~~
fish.cpp:39:28: error: 'cx' was not declared in this scope
   39 |             if((cur1-cur2)>cx){
      |                            ^~
fish.cpp:43:16: error: 'w1' was not declared in this scope
   43 |         return w1+cx;
      |                ^~
fish.cpp:43:19: error: 'cx' was not declared in this scope
   43 |         return w1+cx;
      |                   ^~
fish.cpp:6:17: warning: unused variable 'ans' [-Wunused-variable]
    6 |     long long i,ans=0;
      |                 ^~~