Submission #436605

# Submission time Handle Problem Language Result Execution time Memory
436605 2021-06-24T16:48:06 Z Stickfish Distributing Candies (IOI21_candies) C++17
3 / 100
625 ms 8104 KB
#include "candies.h"
#include <vector>
using namespace std;
using ll = long long;

const int MAXN = 2e5 + 123;
const int INF = 1e9 + 177013;

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size();
	int q = l.size();
    vector<int> s(n, 0);
	for(int i = 0; i < q; ++i)
		++r[i];

	if(n <= 2000){
		for(int qi = 0; qi < q; ++qi){
			for(int i = l[qi]; i < r[qi]; ++i){
				s[i] += v[qi];
				s[i] = max(s[i], 0);
				s[i] = min(s[i], c[i]);
			}
		}
		return s;
	}

	bool isv_positive = true;
	for(int i = 0; i < q; ++i)
		isv_positive &= v[i] > 0;
	if(isv_positive){
		vector<int> pf(n + 1, 0);
		for(int qi = 0; qi < q; ++qi){
			pf[l[qi]] += v[qi];
			pf[r[qi]] -= v[qi];
		}
		int sm = 0;
		for(int i = 0; i < n; ++i){
			sm += pf[i];
			sm = max(sm, 0);
			sm = min(sm, INF);
			s[i] = min(sm, c[i]);
		}
		return s;
	}
    return s;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 8104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 244 ms 5004 KB Output is correct
3 Incorrect 58 ms 2600 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 625 ms 5008 KB Output is correct
4 Incorrect 55 ms 2608 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Incorrect 127 ms 8104 KB Output isn't correct
7 Halted 0 ms 0 KB -