Submission #991860

# Submission time Handle Problem Language Result Execution time Memory
991860 2024-06-03T09:32:46 Z n3rm1n Food Court (JOI21_foodcourt) C++17
7 / 100
537 ms 524288 KB
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const long long MAXN = 7e4+10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
long long n, m, q;

vector < pair < long long/**number*/, long long/**colour*/> > g[MAXN];
vector < pair < long long, long long > > pref[MAXN];
long long cutted[MAXN];
vector < pair < long long, long long > >  lazy[MAXN * 4];

long long ql, qr, val;
long long find_pref(long long ttime, long long shop)
{
    long long l = 0, r = pref[shop].size()-1, mid, ans = 0;
    while(l <= r)
    {
        mid = (l + r)/2;
        if(pref[shop][mid].second <= ttime)
        {
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    return pref[shop][ans].first;
}
void push_lazy(long long i, long long l, long long r)
{
    if(lazy[i].size() != 0 && l == r)
    {
        long long vall, timerr;
        for (long long j = 0; j < lazy[i].size(); ++ j)
        {
            vall = lazy[i][j].first;
            timerr = lazy[i][j].second;
            cutted[l] += min(find_pref(timerr, l) - cutted[l], vall);
        }
    }
    if(l != r)
    {
        for (long long j = 0; j < lazy[i].size(); ++ j)
        {
            lazy[2*i].push_back(lazy[i][j]);
            lazy[2*i+1].push_back(lazy[i][j]);
        }
    }
    lazy[i].clear();
}
long long tt;
void update(long long i, long long l, long long r)
{
    push_lazy(i, l, r);
    if(ql <= l && r <= qr)
    {
        lazy[i].push_back({val, tt});
        push_lazy(i, l, r);
        return;
    }
    if(qr < l || ql > r)return;
    long long mid = (l + r)/2;
    update(2*i, l, mid);
    update(2*i+1, mid+1, r);
}
long long x;
long long query(long long i, long long l, long long r)
{
    push_lazy(i, l, r);
    if(l == r)
    {
        push_lazy(i, l, r);
        return cutted[l];
    }
    long long mid = (l + r)/2;
    if(x <= mid)return query(2*i, l, mid);
    else return query(2*i+1, mid+1, r);
}
void solve()
{
    cin >> n >> m >> q;
    long long type, l, r, k, c;
    for (long long i = 1; i <= n; ++ i)
    {
        pref[i].push_back({0, 0});
        g[i].push_back({0, 0});
    }
    long long aa, bb;

    for (long long i = 1; i <= q; ++ i)
    {
        cin >> type;
        if(type == 1)
        {
            cin >> l >> r >> c >> k;
            for (long long j = l; j <= r; ++ j)
            {
                g[j].push_back(make_pair(k, c));
                pref[j].push_back(make_pair(pref[j].back().first+k, i));
            }
        }
        else if(type == 2)
        {
            cin >> l >> r >> k;
            ql = l;
            qr = r;
            val = k;
            tt = i;
            update(1, 1, n);
        }
        else
        {

            cin >> aa >> bb;
            x = aa;
            long long loose = query(1, 1, n);

          //  cout << loose << endl;
           /// cout << "* " << cutted[aa] << " " << endl;
            long long l = 0, r = pref[aa].size()-1, mid, ans = 0;
            while(l <= r)
            {
                mid = (l + r)/2;
                if(pref[aa][mid].first < bb + loose)
                {
                    l = mid + 1;
                }
                else
                {
                    ans = mid;
                    r = mid - 1;
                }
            }

            cout << g[aa][ans].second << endl;
        }
    }
}
int main()
{
    speed();


    solve();
    return 0;
}

Compilation message

foodcourt.cpp: In function 'void push_lazy(long long int, long long int, long long int)':
foodcourt.cpp:40:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (long long j = 0; j < lazy[i].size(); ++ j)
      |                               ~~^~~~~~~~~~~~~~~~
foodcourt.cpp:49:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (long long j = 0; j < lazy[i].size(); ++ j)
      |                               ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 27484 KB Output is correct
2 Correct 35 ms 42580 KB Output is correct
3 Correct 31 ms 40836 KB Output is correct
4 Correct 52 ms 64220 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10844 KB Output is correct
7 Correct 48 ms 60208 KB Output is correct
8 Correct 48 ms 59476 KB Output is correct
9 Correct 49 ms 60960 KB Output is correct
10 Correct 48 ms 59732 KB Output is correct
11 Correct 54 ms 61776 KB Output is correct
12 Correct 49 ms 60752 KB Output is correct
13 Correct 56 ms 76372 KB Output is correct
14 Correct 78 ms 92500 KB Output is correct
15 Correct 44 ms 53076 KB Output is correct
16 Correct 74 ms 93120 KB Output is correct
17 Correct 27 ms 36692 KB Output is correct
18 Correct 44 ms 52264 KB Output is correct
19 Correct 5 ms 11612 KB Output is correct
20 Correct 4 ms 11776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 27484 KB Output is correct
2 Correct 35 ms 42580 KB Output is correct
3 Correct 31 ms 40836 KB Output is correct
4 Correct 52 ms 64220 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10844 KB Output is correct
7 Correct 48 ms 60208 KB Output is correct
8 Correct 48 ms 59476 KB Output is correct
9 Correct 49 ms 60960 KB Output is correct
10 Correct 48 ms 59732 KB Output is correct
11 Correct 54 ms 61776 KB Output is correct
12 Correct 49 ms 60752 KB Output is correct
13 Correct 56 ms 76372 KB Output is correct
14 Correct 78 ms 92500 KB Output is correct
15 Correct 44 ms 53076 KB Output is correct
16 Correct 74 ms 93120 KB Output is correct
17 Correct 27 ms 36692 KB Output is correct
18 Correct 44 ms 52264 KB Output is correct
19 Correct 5 ms 11612 KB Output is correct
20 Correct 4 ms 11776 KB Output is correct
21 Correct 29 ms 39508 KB Output is correct
22 Correct 32 ms 42580 KB Output is correct
23 Correct 43 ms 45140 KB Output is correct
24 Correct 51 ms 63824 KB Output is correct
25 Correct 3 ms 10844 KB Output is correct
26 Correct 4 ms 10844 KB Output is correct
27 Correct 40 ms 54168 KB Output is correct
28 Correct 48 ms 61268 KB Output is correct
29 Correct 58 ms 60396 KB Output is correct
30 Correct 45 ms 58708 KB Output is correct
31 Correct 49 ms 55632 KB Output is correct
32 Correct 52 ms 55172 KB Output is correct
33 Correct 65 ms 75344 KB Output is correct
34 Correct 83 ms 91220 KB Output is correct
35 Correct 57 ms 72032 KB Output is correct
36 Correct 83 ms 92496 KB Output is correct
37 Correct 4 ms 11356 KB Output is correct
38 Correct 4 ms 11612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 351 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 30556 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 27484 KB Output is correct
2 Correct 35 ms 42580 KB Output is correct
3 Correct 31 ms 40836 KB Output is correct
4 Correct 52 ms 64220 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10844 KB Output is correct
7 Correct 48 ms 60208 KB Output is correct
8 Correct 48 ms 59476 KB Output is correct
9 Correct 49 ms 60960 KB Output is correct
10 Correct 48 ms 59732 KB Output is correct
11 Correct 54 ms 61776 KB Output is correct
12 Correct 49 ms 60752 KB Output is correct
13 Correct 56 ms 76372 KB Output is correct
14 Correct 78 ms 92500 KB Output is correct
15 Correct 44 ms 53076 KB Output is correct
16 Correct 74 ms 93120 KB Output is correct
17 Correct 27 ms 36692 KB Output is correct
18 Correct 44 ms 52264 KB Output is correct
19 Correct 5 ms 11612 KB Output is correct
20 Correct 4 ms 11776 KB Output is correct
21 Runtime error 351 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 537 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 27484 KB Output is correct
2 Correct 35 ms 42580 KB Output is correct
3 Correct 31 ms 40836 KB Output is correct
4 Correct 52 ms 64220 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10844 KB Output is correct
7 Correct 48 ms 60208 KB Output is correct
8 Correct 48 ms 59476 KB Output is correct
9 Correct 49 ms 60960 KB Output is correct
10 Correct 48 ms 59732 KB Output is correct
11 Correct 54 ms 61776 KB Output is correct
12 Correct 49 ms 60752 KB Output is correct
13 Correct 56 ms 76372 KB Output is correct
14 Correct 78 ms 92500 KB Output is correct
15 Correct 44 ms 53076 KB Output is correct
16 Correct 74 ms 93120 KB Output is correct
17 Correct 27 ms 36692 KB Output is correct
18 Correct 44 ms 52264 KB Output is correct
19 Correct 5 ms 11612 KB Output is correct
20 Correct 4 ms 11776 KB Output is correct
21 Correct 29 ms 39508 KB Output is correct
22 Correct 32 ms 42580 KB Output is correct
23 Correct 43 ms 45140 KB Output is correct
24 Correct 51 ms 63824 KB Output is correct
25 Correct 3 ms 10844 KB Output is correct
26 Correct 4 ms 10844 KB Output is correct
27 Correct 40 ms 54168 KB Output is correct
28 Correct 48 ms 61268 KB Output is correct
29 Correct 58 ms 60396 KB Output is correct
30 Correct 45 ms 58708 KB Output is correct
31 Correct 49 ms 55632 KB Output is correct
32 Correct 52 ms 55172 KB Output is correct
33 Correct 65 ms 75344 KB Output is correct
34 Correct 83 ms 91220 KB Output is correct
35 Correct 57 ms 72032 KB Output is correct
36 Correct 83 ms 92496 KB Output is correct
37 Correct 4 ms 11356 KB Output is correct
38 Correct 4 ms 11612 KB Output is correct
39 Runtime error 351 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 27484 KB Output is correct
2 Correct 35 ms 42580 KB Output is correct
3 Correct 31 ms 40836 KB Output is correct
4 Correct 52 ms 64220 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10844 KB Output is correct
7 Correct 48 ms 60208 KB Output is correct
8 Correct 48 ms 59476 KB Output is correct
9 Correct 49 ms 60960 KB Output is correct
10 Correct 48 ms 59732 KB Output is correct
11 Correct 54 ms 61776 KB Output is correct
12 Correct 49 ms 60752 KB Output is correct
13 Correct 56 ms 76372 KB Output is correct
14 Correct 78 ms 92500 KB Output is correct
15 Correct 44 ms 53076 KB Output is correct
16 Correct 74 ms 93120 KB Output is correct
17 Correct 27 ms 36692 KB Output is correct
18 Correct 44 ms 52264 KB Output is correct
19 Correct 5 ms 11612 KB Output is correct
20 Correct 4 ms 11776 KB Output is correct
21 Correct 29 ms 39508 KB Output is correct
22 Correct 32 ms 42580 KB Output is correct
23 Correct 43 ms 45140 KB Output is correct
24 Correct 51 ms 63824 KB Output is correct
25 Correct 3 ms 10844 KB Output is correct
26 Correct 4 ms 10844 KB Output is correct
27 Correct 40 ms 54168 KB Output is correct
28 Correct 48 ms 61268 KB Output is correct
29 Correct 58 ms 60396 KB Output is correct
30 Correct 45 ms 58708 KB Output is correct
31 Correct 49 ms 55632 KB Output is correct
32 Correct 52 ms 55172 KB Output is correct
33 Correct 65 ms 75344 KB Output is correct
34 Correct 83 ms 91220 KB Output is correct
35 Correct 57 ms 72032 KB Output is correct
36 Correct 83 ms 92496 KB Output is correct
37 Correct 4 ms 11356 KB Output is correct
38 Correct 4 ms 11612 KB Output is correct
39 Runtime error 351 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -