Submission #544056

#TimeUsernameProblemLanguageResultExecution timeMemory
544056brunnorezendesDistributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#include "candies.h" #include <bits/stdc++.h> #define s second #define f first #define max 10e9 + 1 using namespace std; typedef vector <int> vi; typedef pair<pair<int,int> , int> iii; typedef vector<iii> viii; vi distribute_candies(vi c, vi l, vi r, vi v){ int q = l.size(), n = c.size(), i, flag=0, type, ind, sum=0, aux; vi val(n, 0); viii sweep; for(i=0;i<q;i++){ if(v[i]<0) flag=1; sweep.push_back({{l[i], 0}, i}); sweep.push_back({{r[i], 2}, i}); } for(i=0;i<n;i++){ sweep.push_back({{i, 1}, i}); } sort(sweep.begin(), sweep.end()); for(i=0;i<sweep.size();i++){ ind = sweep[i].s; type = sweep[i].f.s; if(type == 1){ val[ind] = min(c[ind], sum); } else if(flag){ if(type == 2) sum-=v[ind]; else sum+=v[ind]; aux = sum; sum = max(0, sum); sum = min(c[0], sum); v[ind] += sum-aux; } else{ if(type == 2) sum-=v[ind]; else sum+=v[ind]; } sum %= max; } return val; }

Compilation message (stderr)

candies.cpp: In function 'vi distribute_candies(vi, vi, vi, vi)':
candies.cpp:27:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(i=0;i<sweep.size();i++){
      |          ~^~~~~~~~~~~~~
candies.cpp:37:20: error: expression cannot be used as a function
   37 |    sum = max(0, sum);
      |                    ^
candies.cpp:45:7: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   45 |   sum %= max;
      |       ^
candies.cpp:45:7: note:   in evaluation of 'operator%=(int, double)'