QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524529#1140. Distributing CandiesMousa_Aboubaker#0 200ms60300kbC++202.2kb2024-08-19 19:05:182024-08-19 19:05:19

Judging History

你现在查看的是最新测评结果

  • [2024-08-19 19:05:19]
  • 评测
  • 测评结果:0
  • 用时:200ms
  • 内存:60300kb
  • [2024-08-19 19:05:18]
  • 提交

answer

#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

const int maxN = 2e5;
vector<long long> seg(maxN << 4), lazy(maxN << 4);
long long cmp, n;

void push(int v)
{
    if(seg[v] == 0 and lazy[v] <= 0)
    {
        return;
    }
    seg[v * 2] += lazy[v];
    seg[v * 2] = min(cmp, max(0ll, seg[v * 2]));

    seg[v * 2 + 1] += lazy[v];
    seg[v * 2 + 1] = min(cmp, max(0ll, seg[v * 2 + 1]));
    
    lazy[v * 2] += lazy[v];
    lazy[v * 2] = min(cmp, max(-cmp, lazy[v * 2]));
    
    lazy[v * 2 + 1] += lazy[v];
    lazy[v * 2 + 1] = min(cmp, max(-cmp, lazy[v * 2 + 1]));
    lazy[v] = 0;
}

void update(int l, int r, int val, int tl = 0, int tr = n - 1, int v = 1)
{
    if (l > r)
    {
        return;
    }
    if (l == tl and r == tr)
    {
        seg[v] += val;
        seg[v] = min(cmp, max(0ll, seg[v]));
        if(seg[v] == 0 and val <= 0)
        {
            return;
        }
        lazy[v] += val;
        lazy[v] = min(cmp, max(-cmp, lazy[v]));
    }
    else
    {
        push(v);
        int mid = tl + (tr - tl) / 2;
        update(l, min(mid, r), val, tl, mid, v * 2);
        update(max(mid + 1, l), r, val, mid + 1, tr, v * 2 + 1);
        seg[v] = seg[v * 2] + seg[v * 2 + 1];
        seg[v] = min(cmp, max(0ll, seg[v]));
    }
}

long long query(int idx, int tl = 0, int tr = n - 1, int v = 1)
{
    if (tl == tr)
    {
        return seg[v];
    }
    else
    {
        push(v);
        int mid = tl + (tr - tl) / 2;
        if (idx <= mid)
        {
            return query(idx, tl, mid, v * 2);
        }
        else
        {
            return query(idx, mid + 1, tr, v * 2 + 1);
        }
    }
}

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v)
{
    n = c.size();
    cmp = c.front();
    vector<int> res(n);
    for (int i = 0; i < l.size(); i++)
    {
        update(l[i], r[i], v[i]);
        // for (int j = 0; j < n; j++)
        // {
        //     res[j] = query(j);
        //     cout << res[j] << ' ';
        // }
        // cout << '\n';
    }

    for(int i = 0; i < n; i++)
    {
        res[i] = query(i);
    }

    return res;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 0ms
memory: 53020kb

input:

lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg
8
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
8
0 7 1
0 7 1
0 7 300000000
0 7 994967293
0 7 1
0 7 1000000000
0 7 1000000000
0 7 1000000000

output:

4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq
OK
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

result:

ok 3 lines

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 53008kb

input:

lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg
10
283 43634 101056 10340 6009 5133 30 2 3677888 210
10
1 8 26416
2 7 -51219
2 4 17793
3 7 75426
3 7 22307
1 1 60258
3 7 -29824
0 8 24839
2 8 -60304
0 1 -26411

output:

4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq
OK
283 283 0 283 283 283 283 283 0 0

result:

wrong answer 3rd lines differ - expected: '0 17223 0 0 0 0 0 0 0 0', found: '283 283 0 283 283 283 283 283 0 0'

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 200ms
memory: 60300kb

input:

lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg
200000
11408901 370732653 37843 28 53693 15782410 103 297546 1112427 170319071 26 1 6172 11614171 431 884673599 1 3 50085 154 57 28200 145886 898969 74758 72 845768 6 69787 11 31012465 55362 253 2363145 47186217 1103 19622 594 7867 1 4299 28130 48 4689582 12 ...

output:

4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq
OK
87153 87153 243257 250497 325876 406667 525479 655951 766665 971468 1073487 1084603 1144515 1257294 1514842 1536484 1739854 1833903 1950484 1950484 2050477 2096517 2213442 2241808 2453123 2551636 2688712 2735237 2969818 2969818 3043755 3043755 3113712 3297...

result:

wrong answer 3rd lines differ - expected: '87153 87153 37843 28 53693 406...46468 9 1756 429030 247071 1629', found: '87153 87153 243257 250497 3258...1546 474919 429030 247071 16020'

Subtask #3:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 3ms
memory: 53028kb

input:

lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg
1000
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...

output:

4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq
OK
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

wrong answer 3rd lines differ - expected: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 4ms
memory: 52928kb

input:

lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg
10
11 440 51 41 11 1 3 108 148 14
10
0 9 60
0 9 -9
0 9 -30
0 9 41
0 9 82
0 9 69
0 9 -79
0 9 -39
0 9 72
0 9 41

output:

4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq
OK
11 11 11 11 11 11 11 11 11 11

result:

wrong answer 3rd lines differ - expected: '11 208 51 41 11 1 3 108 143 14', found: '11 11 11 11 11 11 11 11 11 11'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%