Submission #543994

#TimeUsernameProblemLanguageResultExecution timeMemory
543994brunnorezendesDistributing Candies (IOI21_candies)C++17
0 / 100
177 ms19796 KiB
#include "candies.h" #include <bits/stdc++.h> #define s second #define f first 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; 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]; sum = max(0, sum); sum = min(c[0], sum); } else{ if(type == 2) sum-=v[ind]; else sum+=v[ind]; } } return val; }

Compilation message (stderr)

candies.cpp: In function 'vi distribute_candies(vi, vi, vi, vi)':
candies.cpp:26: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]
   26 |  for(i=0;i<sweep.size();i++){
      |          ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...