답안 #500210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500210 2021-12-30T13:12:17 Z sazid_alam 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"

#include <bits/stdc++.h>
using namespace std;
typedef int long long;

vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n = c.size();
    vector<int> sum(n + 1, 0);

    for(int i = 0; i < v.size(); i++){
        sum[l[i]] += v[i];
        sum[r[i] + 1] -= v[i];
    }

    for(int i = 1; i < n; i++) sum[i] += sum[i - 1];
    for(int i = 0; i < n; i++) c[i] = min(c[i], sum[i]);

    return c;
}

Compilation message

candies.cpp:5:18: error: declaration does not declare anything [-fpermissive]
    5 | typedef int long long;
      |                  ^~~~
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0; i < v.size(); i++){
      |                    ~~^~~~~~~~~~