답안 #814628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
814628 2023-08-08T08:37:33 Z gesgha 사탕 분배 (IOI21_candies) C++17
3 / 100
78 ms 12124 KB
#include "candies.h"
#include <bits/stdc++.h>
 
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define fe(x, y) for (auto& x : y)
 
#define fi first
#define se second
#define pb push_back
 
#define all(x) x.begin(), x.end()
#define pw(x) (1LL << (x))
#define sz(x) (int)x.size()
 
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename T>
using ve = vector <T>;
 
template <typename T>
bool umx (T& a, T b) { return a < b ? a = b, 1 : 0; }
 
template <typename T>
bool umn (T& a, T b) { return a > b ? a = b, 1 : 0; }
 
using ll = long long;
using ld = long double;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
using ull = unsigned long long;
 
const int oo = 1e9;
const ll OO = 1e18;
const int N = 2e5 + 10;
const int M = 5e3 + 100;
const int mod = 1e9 + 7;
const bool TEST = 0;


int T[4 * N];


void push(int v) {
    if(!T[v]) return;
    T[v << 1] += T[v];
    T[v << 1 | 1] += T[v];
    T[v] = 0;
}

void add(int v, int tl, int tr, int l, int r, int x) {
    if (l > r) return;
    if (l == tl && r == tr) {
        T[v] += x;
        return;
    }
    push(v);
    int tm = (tl + tr) >> 1;
    add(v << 1, tl, tm, l, min(r, tm), x);
    add(v << 1 | 1, tm + 1, tr, max(l, tm + 1), r, x);
}

vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) {
    int n = c.size();
    int q = v.size();
    bool ok = 1;
    bool ok1 = 1;
    for (int i = 0; i < q; i++) ok &= (v[i] > 0);
    for (int i = 0; i < q; i++) ok1 &= (c[i] == c[0]);
    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];
                umx(s[j], 0);
                umn(s[j], c[j]);
            }
        }
        return s;
    }
    return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 12124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 48 ms 8020 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 41 ms 7596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Incorrect 78 ms 12124 KB Output isn't correct
7 Halted 0 ms 0 KB -