Submission #839273

#TimeUsernameProblemLanguageResultExecution timeMemory
839273nguyentunglamDistributing Candies (IOI21_candies)C++17
3 / 100
5089 ms9200 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; vector<int> distribute_candies (vector<int> c, vector<int> l, vector<int> r, vector<int> v) { vector<int> p; p.resize(c.size()); for(int query = 0; query < v.size(); query++) { for(int i = l[query]; i <= r[query]; i++) { p[i] += v[query]; p[i] = max(0, p[i]); p[i] = min(c[i], p[i]); } // for(int i = 0; i < p.size(); i++) cout << p[i] << " "; cout << endl; } return p; } #ifdef ngu int main() { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); int n, q; cin >> n >> q; vector<int> c(n), l(q), r(q), v(q); for(int i = 0; i < n; i++) cin >> c[i]; for(int i = 0; i < q; i++) cin >> l[i] >> r[i] >> v[i]; vector<int> ans = distribute_candies(c, l, r, v); // for(int &j : ans) cout << j << " "; } #endif // ngu

Compilation message (stderr)

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:11:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int query = 0; query < v.size(); query++) {
      |                        ~~~~~~^~~~~~~~~~
#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...