답안 #436609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436609 2021-06-24T16:50:32 Z Stickfish 사탕 분배 (IOI21_candies) C++17
3 / 100
702 ms 8856 KB
#include "candies.h"
#include <vector>
using namespace std;
using ll = long long;

const int MAXN = 2e5 + 123;
const ll INF = 1e18 + 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<ll> pf(n + 1, 0);
		for(int qi = 0; qi < q; ++qi){
			pf[l[qi]] += v[qi];
			pf[r[qi]] -= v[qi];
		}
		ll sm = 0;
		for(int i = 0; i < n; ++i){
			sm += pf[i];
			sm = max(sm, 0ll);
			sm = min(sm, INF);
			s[i] = min(int(sm), c[i]);
		}
		return s;
	}
    return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 138 ms 8856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 248 ms 5004 KB Output is correct
3 Incorrect 57 ms 2588 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 702 ms 5000 KB Output is correct
4 Incorrect 70 ms 2600 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Incorrect 138 ms 8856 KB Output isn't correct
7 Halted 0 ms 0 KB -