답안 #790066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790066 2023-07-22T10:09:58 Z mousebeaver 사탕 분배 (IOI21_candies) C++17
11 / 100
89 ms 14560 KB
#define ll long long
#define pll pair<ll, ll>
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) 
{
    ll n = c.size();
    ll q = l.size();

    if(n <= 2000 && q <= 2000)
    {
        //Subtask 1
        vector<ll> a(n, 0);
        for(ll i = 0; i < q; i++)
        {
            for(ll j = l[i]; j <= r[i]; j++)
            {
                if(v[i] > 0)
                {
                    a[j] = min(a[j]+(ll) v[i], (ll) c[j]);
                }
                if(v[i] < 0)
                {
                    a[j] = max(a[j]+(ll) v[i], 0LL);
                }
            }
        }
        vector<int> output(n, 0);
        for(ll i = 0; i < n; i++)
        {
            output[i] = a[i];
        }
        return output;
    }
    if(*min_element(v.begin(), v.end()) > 0)
    {
        vector<ll> plus(n, 0);
        vector<ll> minus(n, 0);
        for(ll i = 0; i < q; i++)
        {
            plus[l[i]] += v[i];
            minus[r[i]] += v[i];
        }

        ll add = 0;
        vector<int> output(n);
        for(ll i = 0; i < n; i++)
        {
            add += plus[i];
            output[i] = (int) min(add, (ll) c[i]);
            add -= minus[i];
        }
        return output;
    }

    return {};
}
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 10484 KB Output is correct
2 Correct 81 ms 14560 KB Output is correct
3 Correct 88 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 46 ms 4952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 41 ms 4952 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 89 ms 10484 KB Output is correct
7 Correct 81 ms 14560 KB Output is correct
8 Correct 88 ms 14288 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 46 ms 4952 KB Output isn't correct
11 Halted 0 ms 0 KB -