답안 #773398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773398 2023-07-05T04:10:13 Z SanguineChameleon 사탕 분배 (IOI21_candies) C++17
11 / 100
99 ms 12888 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

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);
	if (n <= 2000 && q <= 2000) {
		for (int i = 0; i < q; i++) {
			for (int j = l[i]; j <= r[i]; j++) {
				s[j] += v[i];
				s[j] = max(s[j], 0);
				s[j] = min(s[j], c[j]);
			}
		}
	}
	else {
		vector<long long> pref(n);
		for (int i = 0; i < q; i++) {
			pref[l[i]] += v[i];
			if (r[i] + 1 < n) {
				pref[r[i] + 1] -= v[i];
			}
		}
		for (int i = 1; i < n; i++) {
			pref[i] += pref[i - 1];
		}
		for (int i = 0; i < n; i++) {
			s[i] = min(max(pref[i], 0LL), (long long)c[i]);
		}
	}
	return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 8812 KB Output is correct
2 Correct 88 ms 12888 KB Output is correct
3 Correct 77 ms 12776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 47 ms 4964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 40 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 99 ms 8812 KB Output is correct
7 Correct 88 ms 12888 KB Output is correct
8 Correct 77 ms 12776 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Incorrect 47 ms 4964 KB Output isn't correct
11 Halted 0 ms 0 KB -