답안 #813905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
813905 2023-08-08T04:30:02 Z alvingogo 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"
#include <bits/stdc++.h>
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n = c.size();
    vector<int> s(n);
    int q=l.size();
    for(int i=0;i<q;i++){
        if(v[i]<0){
            for(int j=l[i];j<=r[i];j++){
                s[j]=max(0,s[j]+v[i]);
            }
        }
        else{
            for(int j=l[i];j<=r[i];j++)[
                s[j]=min(c[j],s[j]+v[i]);
            ]
        }
    }
    return s;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:21:18: error: expected ',' before '[' token
   21 |                 s[j]=min(c[j],s[j]+v[i]);
      |                  ^
      |                  ,
candies.cpp:21:18: error: expected identifier before '[' token
candies.cpp:21:41: error: expected ']' before ';' token
   21 |                 s[j]=min(c[j],s[j]+v[i]);
      |                                         ^
      |                                         ]
candies.cpp: In lambda function:
candies.cpp:21:41: error: expected '{' before ';' token
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:22:13: error: expected primary-expression before ']' token
   22 |             ]
      |             ^