Submission #1053327

#TimeUsernameProblemLanguageResultExecution timeMemory
1053327tolbiDistributing Candies (IOI21_candies)C++17
0 / 100
5095 ms13744 KiB
#include "candies.h" #include <bits/stdc++.h> using namespace std; #define int long long #define tol(bi) ((1LL)<<((int)(bi))) template<typename T> vector<int32_t> normalize(vector<T> v){ vector<int32_t> ret(v.size()); for (int i = 0; i < v.size(); ++i) { ret[i]=v[i]; } return ret; } vector<int32_t> distribute_candies(vector<int32_t> c, vector<int32_t> l, vector<int32_t> r, vector<int32_t> v) { int n = c.size(); pair<int,int> pn[n]; for (int i = 0; i < n; i++){ pn[i]={c[i],i}; } sort(pn,pn+n); int ind = 0; int mav = 0; int miv = 0; vector<int> ans(n,-1); for (int i = l.size()-1; i >= 0; i--){ int val = v[i]; if (val<0){ miv-=val; } else { mav+=val; } while (ind<n){ if (mav+miv>=pn[ind].first){ if (val<0) ans[pn[ind].second]=mav; else ans[pn[ind].second]=pn[ind].first-miv; ind++; } else break; } } while (ind<n){ ans[pn[ind].second]=mav; } return normalize(ans); }

Compilation message (stderr)

candies.cpp: In instantiation of 'std::vector<int> normalize(std::vector<_Tp>) [with T = long long int]':
candies.cpp:45:22:   required from here
candies.cpp:8:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < v.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...