Submission #500206

# Submission time Handle Problem Language Result Execution time Memory
500206 2021-12-30T13:10:35 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;
using 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:7: error: expected nested-name-specifier before 'int'
    5 | using 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++){
      |                    ~~^~~~~~~~~~