Submission #615656

# Submission time Handle Problem Language Result Execution time Memory
615656 2022-07-31T11:42:28 Z HamletPetrosyan Distributing Candies (IOI21_candies) C++17
11 / 100
100 ms 13252 KB
#include "candies.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define ll long long
#define add push_back
#define pii pair<int, int>
#define len(a) ((int)(a).size())
#define all(a) a.begin(), a.end()

#define fr first
#define sc second

const int N = 3e5 + 5;

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
	vector<int> ret;
	if(len(c) <= 2000 && len(l) <= 2000){
		int now = 0;
		for(int i = 0; i < len(c); i++){
			now = 0;
			for(int j = 0; j < len(l); j++){
				if(l[j] <= i && i <= r[j]) {
					if(v[j] < 0) now = max(0, now + v[j]);
					else now = min(c[i], now + v[j]);
				}
			}
			ret.add(now);
		}
		return ret;
	}
	vector<ll> dif;
	dif.resize(len(c) + 5, 0);
	for(int i = 0; i < len(l); i++){
		dif[l[i]] += (ll)v[i];
		dif[r[i] + 1] -= (ll)v[i];
	}
	ll now = 0;
	for(int i = 0; i < len(c); i++){
		now += dif[i];
		ret.add(min(now, (ll)c[i]));
	}
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 14 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 9284 KB Output is correct
2 Correct 93 ms 13252 KB Output is correct
3 Correct 100 ms 13208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 55 ms 4968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 48 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 14 ms 380 KB Output is correct
6 Correct 98 ms 9284 KB Output is correct
7 Correct 93 ms 13252 KB Output is correct
8 Correct 100 ms 13208 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 55 ms 4968 KB Output isn't correct
11 Halted 0 ms 0 KB -