Language: C++

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

vector<int> Input(const int n)
{
????????vector<int> W;
????????for(int i = 0; i < n; i++){
????????????????int w;
????????????????cin >> w;
????????????????W.push_back(w);
????????}
????????return W;
}
??
bool IsAllLoaded(int P, vector<int> W, int k)
{
????????int TrackIndex = 0;
????????int CurrentSum = 0;
????????int i = 0;
????????for(i = 0; i < W.size(); i++){
????????????????if(W[i] > P){
????????????????????????return false;
????????????????}
????????????????if(CurrentSum + W[i] > P){
????????????????????????TrackIndex++;
????????????????????????if(TrackIndex == k){
????????????????????????????????return false;
????????????????????????}
????????????????????????CurrentSum = 0;
????????????????}
????????????????CurrentSum += W[i];
????????}
????????return true;
}
??
int Calc(vector<int> W, int k)
{
????????int Sum = accumulate(W.begin(), W.end(), 0 );
????????int P = (Sum + k - 1) / k;
????????while(!IsAllLoaded(P, W, k)){
????????????????P++;
????????}
????????return P;
}
??
int main()
{
????????int n, k;
????????cin >> n >> k;
????????vector<int> W = Input(n);
????????int P = Calc(W, k);
????????cout << P << endl;
????????return 0;
}

Compiler output:
a.cc: In function 'std::vector<int> Input(int)':
a.cc:8:1: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      | ^
a.cc:8:2: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |  ^
a.cc:8:3: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |   ^
a.cc:8:4: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |    ^
a.cc:8:5: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |     ^
a.cc:8:6: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |      ^
a.cc:8:7: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |       ^
a.cc:8:8: error: expected primary-expression before '?' token
    8 | ????????vector<int> W;
      |        ^
a.cc:8:21: error: expected primary-expression before 'W'
    8 | ????????vector<int> W;
      |                     ^
a.cc:8:20: error: expected ':' before 'W'
    8 | ????????vector<int> W;
      |                    ^~
      |                    :
a.cc:8:21: error: 'W' was not declared in this scope
    8 | ????????vector<int> W;
      |                     ^
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:8:22: error: expected ':' before ';' token
    8 | ????????vector<int> W;
      |                      ^
      |                      :
a.cc:8:22: error: expected primary-expression before ';' token
a.cc:9:1: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      | ^
a.cc:9:2: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |  ^
a.cc:9:3: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |   ^
a.cc:9:4: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |    ^
a.cc:9:5: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |     ^
a.cc:9:6: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |      ^
a.cc:9:7: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |       ^
a.cc:9:8: error: expected primary-expression before '?' token
    9 | ????????for(int i = 0; i < n; i++){
      |        ^
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:9: error: expected ':' before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
      |         :
a.cc:9:9: error: expected primary-expression before 'for'
    9 | ????????for(int i = 0; i < n; i++){
      |         ^~~
a.cc:9:24: error: 'i' was not declared in this scope
    9 | ????????for(int i = 0; i < n; i++){
      |                        ^
a.cc:14:1: error: expected primary-expression before '?' token
   14 | ????????return W;
      | ^
a.cc:14:2: error: expected primary-expression before '?' token
   14 | ????????return W;
      |  ^
a.cc:14:3: error: expected primary-expression before '?' token
   14 | ????????return W;
      |   ^
a.cc:14:4: error: expected primary-expression before '?' token
   14 | ????????return W;
      |    ^
a.cc:14:5: error: expected primary-expression before '?' token
   14 | ????????return W;
      |     ^
a.cc:14:6: error: expected primary-expression before '?' token
   14 | ????????return W;
      |      ^
a.cc:14:7: error: expected primary-expression before '?' token
   14 | ????????return W;
      |       ^
a.cc:14:8: error: expected primary-expression before '?' token
   14 | ????????return W;
      |        ^
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:14:9: error: expected ':' before 'return'
   14 | ????????return W;
      |         ^~~~~~
      |         :
a.cc:14:9: error: expected primary-expression before 'return'
   14 | ????????return W;
      |         ^~~~~~
a.cc:15:1: warning: no return statement in function returning non-void [-Wreturn-type]
   15 | }
      | ^
a.cc: At global scope:
a.cc:16:1: error: expected unqualified-id before '?' token
   16 | ??
      | ^
a.cc:37:1: error: expected unqualified-id before '?' token
   37 | ??
      | ^
a.cc:47:1: error: expected unqualified-id before '?' token
   47 | ??
      | ^