Submission #1308583

#TimeUsernameProblemLanguageResultExecution timeMemory
1308583SmuggingSpunDistributing Candies (IOI21_candies)C++20
11 / 100
60 ms9248 KiB
#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>distribute_candies(vector<int>c, vector<int>l, vector<int>r, vector<int>v){
	int n = c.size(), q = l.size();
	if(max(n, q) <= 2000){
		vector<int>ans(n, 0);
		for(int i = 0; i < q; i++){
			for(int j = l[i]; j <= r[i]; j++){
				if(v[i] > 0){
					ans[j] = min(c[j], ans[j] + v[i]);
				}
				else{
					ans[j] = max(0, ans[j] + v[i]);
				}
			}
		}
		return ans;
	}
	else if(*min_element(v.begin(), v.end()) > 0){
		vector<ll>f(n + 1, 0);
		for(int i = 0; i < q; i++){
			f[l[i]] += v[i];
			f[r[i] + 1] -= v[i];
		}
		vector<int>ans;
		ans.push_back(min(ll(c[0]), f[0]));
		for(int i = 1; i < n; i++){
			ans.push_back(min(ll(c[i]), f[i] += f[i - 1]));
		}
		return ans;
	}
}

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:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
#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...