답안 #481474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481474 2021-10-21T02:42:56 Z 8e7 사탕 분배 (IOI21_candies) C++17
8 / 100
100 ms 8808 KB
//Challenge: Accepted
#include "candies.h"
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ...b) {
	cout << a << " ", debug(b ...);
};
template<class T> void pary (T l, T r) {
	while (l!= r) cout << *l << " ", l++;
	cout << endl;
};
#define ll long long
#define maxn 200005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size(), q = v.size();
	vector<int> ret(n, 0);
	vector<ll> pref(n, 0);	
	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 = 0;i < n;i++) {
		if (i) pref[i] += pref[i-1];
		ret[i] = min(pref[i], (ll)c[i]);
	}
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 8808 KB Output is correct
2 Correct 89 ms 8796 KB Output is correct
3 Correct 89 ms 8804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -