Submission #500212

# Submission time Handle Problem Language Result Execution time Memory
500212 2021-12-30T13:13:10 Z sazid_alam Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"

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

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:19: error: multiple types in one declaration
    5 | typedef long long int int;
      |                   ^~~
candies.cpp:5:23: error: declaration does not declare anything [-fpermissive]
    5 | typedef long long int int;
      |                       ^~~
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++){
      |                    ~~^~~~~~~~~~