답안 #799103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799103 2023-07-31T09:42:38 Z TheSahib 사탕 분배 (IOI21_candies) C++17
8 / 100
153 ms 16300 KB
#include "candies.h"
#include <bits/stdc++.h>

#define ll long long
#define pii pair<ll, ll>

using namespace std;

const int MAX = 2e5 + 5;

ll tree[MAX * 4];
ll lazy[MAX * 4];

void update(int node, int l, int r, int ql, int qr, int val){
    if(ql > r || qr < l) return;
    if(ql <= l && r <= qr){
        tree[node] += val;
        return;
    }
    int mid = (l + r) / 2;
    update(node * 2, l, mid, ql, qr, val);
    update(node * 2 + 1, mid + 1, r, ql, qr, val);
}
ll get(int node, int l, int r, int pos){
    if(l == r){
        return tree[node];
    }
    tree[node * 2] += tree[node];
    tree[node * 2 + 1] += tree[node];
    tree[node] = 0;
    int mid = (l + r) / 2;
    if(pos <= mid){
        return get(node * 2, l, mid, pos);
    }
    else{
        return get(node * 2 + 1, mid + 1, r, pos);
    }
}


std::vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    for (int i = 0; i < l.size(); i++)
    {
        update(1, 0, MAX, l[i], r[i], v[i]);
    }
    vector<int> ans(c.size());
    for (int i = 0; i < c.size(); i++)
    {
        ans[i] = min(c[i] * 1ll, get(1, 0, MAX, i));
    }
    return ans;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i < l.size(); i++)
      |                     ~~^~~~~~~~~~
candies.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i = 0; i < c.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 16300 KB Output is correct
2 Correct 152 ms 15660 KB Output is correct
3 Correct 145 ms 15372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -