답안 #788510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
788510 2023-07-20T10:04:43 Z alexander707070 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define MAXN 1000007
using namespace std;
 
int n;
vector<int> curr;

vector<int> distribute_candies(int[] c, int[] l, int[] r, int[] v){
    n=int(c.size());
    curr.resize(n);

    for(int i=0;i<q;i++){
        for(int f=l[i];f<=r[i];f++){
            curr[f]+=v[i];
            if(curr[f]<0)curr[f]=0
            if(curr[f]>c[f])curr[f]=c[f];
        }
    }

    return curr;
}

Compilation message

candies.cpp:8:38: error: expected ',' or '...' before 'c'
    8 | vector<int> distribute_candies(int[] c, int[] l, int[] r, int[] v){
      |                                      ^
candies.cpp: In function 'std::vector<int> distribute_candies(int*)':
candies.cpp:9:11: error: 'c' was not declared in this scope
    9 |     n=int(c.size());
      |           ^
candies.cpp:12:19: error: 'q' was not declared in this scope
   12 |     for(int i=0;i<q;i++){
      |                   ^
candies.cpp:13:19: error: 'l' was not declared in this scope
   13 |         for(int f=l[i];f<=r[i];f++){
      |                   ^
candies.cpp:13:27: error: 'r' was not declared in this scope
   13 |         for(int f=l[i];f<=r[i];f++){
      |                           ^
candies.cpp:14:22: error: 'v' was not declared in this scope
   14 |             curr[f]+=v[i];
      |                      ^
candies.cpp:15:35: error: expected ';' before 'if'
   15 |             if(curr[f]<0)curr[f]=0
      |                                   ^
      |                                   ;
   16 |             if(curr[f]>c[f])curr[f]=c[f];
      |             ~~