Submission #850350

#TimeUsernameProblemLanguageResultExecution timeMemory
850350AliHasanliCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { if(N==1) return 0; bool check=true; int maxX=0; for(int i:X) maxX=max(maxX,X[i]); for(int i:X) if(i%2) { check=false; break; } long long ans=0; if(check) { for(int i=0;i<W.size();i++) ans+=W[i]; return ans; } else if(maxX==0) { for(int i=0;i<W.size();i++) ans+=W[i]; return ans; } else if(maxX==1) { long long ansX0=0,ansX1=0; for(int i=0;i<X.size();i++) if(X[i]==0) ansX0+=W[i]; else ansX1+=W[i]; return max(ansX0,ansX1); } return 0; }

Compilation message (stderr)

fish.cpp:1:37: error: 'vector' has not been declared
    1 | long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
      |                                     ^~~~~~
fish.cpp:1:43: error: expected ',' or '...' before '<' token
    1 | long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
      |                                           ^
fish.cpp: In function 'long long int max_weights(int, int, int)':
fish.cpp:7:15: error: 'X' was not declared in this scope
    7 |     for(int i:X)
      |               ^
fish.cpp:8:14: error: 'max' was not declared in this scope; did you mean 'maxX'?
    8 |         maxX=max(maxX,X[i]);
      |              ^~~
      |              maxX
fish.cpp:9:15: error: 'X' was not declared in this scope
    9 |     for(int i:X)
      |               ^
fish.cpp:18:23: error: 'W' was not declared in this scope
   18 |         for(int i=0;i<W.size();i++)
      |                       ^
fish.cpp:24:23: error: 'W' was not declared in this scope
   24 |         for(int i=0;i<W.size();i++)
      |                       ^
fish.cpp:31:23: error: 'X' was not declared in this scope
   31 |         for(int i=0;i<X.size();i++)
      |                       ^
fish.cpp:33:24: error: 'W' was not declared in this scope
   33 |                 ansX0+=W[i];
      |                        ^
fish.cpp:35:24: error: 'W' was not declared in this scope
   35 |                 ansX1+=W[i];
      |                        ^
fish.cpp:36:16: error: 'max' was not declared in this scope; did you mean 'maxX'?
   36 |         return max(ansX0,ansX1);
      |                ^~~
      |                maxX