Submission #197591

# Submission time Handle Problem Language Result Execution time Memory
197591 2020-01-21T20:36:55 Z stefdasca Watering can (POI13_kon) C++14
30 / 100
4000 ms 77836 KB
#include<bits/stdc++.h>
#include "koninc.h"
using namespace std;

const int MAXN = 300001, rad = 1502;

int N, K, v[MAXN+5];

int buk[MAXN+5], L[1012], R[1012], ad[1012], nrbuk, aans[1012];

short ans[202][300012];

void proc(int bk)
{
    for(int j = L[bk]; j <= R[bk]; ++j)
    {
        if(v[j] >= K)
            ans[bk][0] = 0;
        else
            if(K - v[j] <= 300000)
                ans[bk][K - v[j]] = 0;
    }
    for(int j = L[bk]; j <= R[bk]; ++j)
    {
        v[j] += ad[bk];
        if(v[j] >= K)
            ans[bk][0]++;
        else
            if(K - v[j] <= 300000)
                ans[bk][K - v[j]]++;
    }
    ad[bk] = 0;
    aans[bk] = ans[bk][0];
}

void inicjuj(int n, int k, int *D)
{
    N = n, K = k;
    for(int i = 0; i < n; ++i)
        v[i] = D[i];
    for(int i = 0; i < n; ++i)
    {
        if(i % rad == 0)
            ++nrbuk, L[nrbuk] = i;
        R[nrbuk] = i;
        buk[i] = nrbuk;
    }
    for(int i = 0; i <= nrbuk; ++i)
        proc(i);
}

void podlej(int a, int b)
{
    int fini = R[buk[a]];
    int ax = buk[a];
    proc(ax);
    while(a <= b && a <= fini)
    {
        ++v[a];
        ++a;
    }
    proc(ax);
    while(a < N && R[buk[a]] <= b)
        ++ad[buk[a]], aans[buk[a]] = aans[buk[a]] + ans[buk[a]][ad[buk[a]]], a = R[buk[a]] + 1;
    if(a <= b)
    {
        fini = R[buk[a]];
        ax = buk[a];
        proc(ax);
        while(a <= b && a <= fini)
        {
            ++v[a];
            ++a;
        }
        proc(ax);
    }
}

int dojrzale(int a, int b)
{
    int fini = R[buk[a]];
    int qans = 0;
    proc(buk[a]);
    while(a <= b && a <= fini)
    {
        if(v[a] >= K)
            ++qans;
        ++a;
    }
    while(a < N && R[buk[a]] <= b)
        qans += aans[buk[a]], a = R[buk[a]] + 1;
    if(a <= b)
    {
        proc(buk[a]);
        fini = R[buk[a]];
        while(a <= b && a <= fini)
        {
            if(v[a] >= K)
                ++qans;
            ++a;
        }
    }
    return qans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1762 ms 1444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3129 ms 1676 KB Output is correct
2 Correct 1042 ms 2168 KB Output is correct
3 Correct 1310 ms 1240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4083 ms 35812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4069 ms 49316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4078 ms 41276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4098 ms 77836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4006 ms 9120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 9700 KB Time limit exceeded
2 Halted 0 ms 0 KB -