Submission #436421

# Submission time Handle Problem Language Result Execution time Memory
436421 2021-06-24T13:30:09 Z PiejanVDC Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

vector<int64_t> distribute_candies(vector<int64_t> c, vector<int64_t> l, vector<int64_t> r, vector<int64_t> v) {
    vector<int64_t>sum(c.size()+1,0);
    for(int32_t i = 0 ; i < v.size() ; i++) {
        sum[l[i]]+=v[i],sum[r[i]+1]-=v[i];
    }
    vector<int64_t>ans(c.size());
    int64_t current_sum=0;
    for(int32_t i = 0 ; i < c.size() ; i++) {
            current_sum+=sum[i];
            ans[i] = min(c[i],current_sum);
    }
    return ans;
}

Compilation message

candies.cpp: In function 'std::vector<long int> distribute_candies(std::vector<long int>, std::vector<long int>, std::vector<long int>, std::vector<long int>)':
candies.cpp:7:27: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int32_t i = 0 ; i < v.size() ; i++) {
      |                         ~~^~~~~~~~~~
candies.cpp:12:27: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int32_t i = 0 ; i < c.size() ; i++) {
      |                         ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccrXTbUN.o: in function `main':
grader.cpp:(.text.startup+0x30e): undefined reference to `distribute_candies(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status