| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 883420 | nguyentunglam | 사탕 분배 (IOI21_candies) | C++17 | 69 ms | 29084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 1e5 + 10;
vector<int> event[N];
vector<long long> distribute_candies (vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
vector<long long> p;
int n = c.size();
for(int i = 0; i < n; i++) event[i].push_back(0);
for(int i = 0; i < v.size(); i++)
{
for(int j = l[i]; j <= r[i]; j++)
{
event[j].push_back(v[i]);
}
}
for(int i = 0; i < n; i++)
{
long long sum = 0, border = 0;
vector<long long> pref;
for(int &j : event[i]) {
sum += j;
pref.push_back(sum);
}
long long mx = -1e18, mn = 1e18;
for(int j = pref.size() - 1; j >= 0; j--)
{
mn = min(mn, pref[j]);
mx = max(mx, pref[j]);
if (mx - mn <= c[i])
{
if (event[i][j] > 0 && mx <= pref[j]) border = pref[j] - c[i];
if (event[i][j] <= 0 && mn >= pref[j]) border = pref[j];
}
}
p.push_back(sum - border);
}
return p;
}
#ifdef ngu
int main() {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
int n, q; cin >> n >> q;
vector<int> c(n), l(q), r(q), v(q);
for(int i = 0; i < n; i++) cin >> c[i];
for(int i = 0; i < q; i++) cin >> l[i] >> r[i] >> v[i];
vector<long long> ans = distribute_candies(c, l, r, v);
for(long long &j : ans) cout << j << " ";
}
#endif // ngu
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
