Submission #939552

# Submission time Handle Problem Language Result Execution time Memory
939552 2024-03-06T13:50:12 Z n3rm1n Food Court (JOI21_foodcourt) C++17
7 / 100
1000 ms 524288 KB
#include<bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5+10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, m, que;
deque < pair < long long/**type*/, long long/**number*/ > > q[MAXN];
long long total[MAXN];
long long t;
long long l, r, c, k, a, b;
void read()
{
    cin >> n >> m >> que;
    for (long long i = 1; i <= que; ++ i)
    {
        cin >> t;
        if(t == 1)
        {
            cin >> l >> r >> c >> k;
            for (long long j = l; j <= r; ++ j)
            {
                q[j].push_back(make_pair(c, k));
                total[j] += k;
            }
        }
        else if(t == 2)
        {
            cin >> l >> r >> k;
            for (long long j = l; j <= r; ++ j)
            {
                if(total[j] <= k)
                {
                    q[j].clear();
                    total[j] = 0;
                }
                else
                {
                    int kk = k;
                    total[j] -= kk;
                    while(kk)
                    {
                        if(kk >= q[j].front().second)
                        {
                            kk -= q[j].front().second;
                           // cout << "cut " << q[j].front().first << endl;
                            q[j].pop_front();
                        }
                        else
                        {
                            q[j].front().second -= kk;
                            kk = 0;
                        }
                    }
                }
            }
        }
        else
        {
            cin >> a >> b;
           // cout << "start " << endl;
            if(total[a] < b)cout << 0 << endl;
            else
            {
                deque < pair <long long, long long > >cut;
                long long sum = b, last_colour = 0;
                while(sum > 0)
                {
                    sum -= q[a].front().second;
                    last_colour = q[a].front().first;
                   // cout << "** " << last_colour << endl;
                    cut.push_back(q[a].front());
                    q[a].pop_front();
                }
                while(!cut.empty())
                {
                    q[a].push_front(cut.back());
                    cut.pop_back();
                }
                cout << last_colour << endl;
            }

        }
    }
}
int main()
{
    speed();

    read();
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 113 ms 203020 KB Output is correct
2 Correct 116 ms 203432 KB Output is correct
3 Correct 123 ms 209972 KB Output is correct
4 Correct 146 ms 213332 KB Output is correct
5 Correct 106 ms 202532 KB Output is correct
6 Correct 109 ms 202372 KB Output is correct
7 Correct 142 ms 215124 KB Output is correct
8 Correct 151 ms 210648 KB Output is correct
9 Correct 123 ms 203344 KB Output is correct
10 Correct 147 ms 210000 KB Output is correct
11 Correct 122 ms 207324 KB Output is correct
12 Correct 129 ms 203452 KB Output is correct
13 Correct 122 ms 203284 KB Output is correct
14 Correct 145 ms 204760 KB Output is correct
15 Correct 122 ms 205524 KB Output is correct
16 Correct 136 ms 204592 KB Output is correct
17 Correct 128 ms 202784 KB Output is correct
18 Correct 120 ms 202908 KB Output is correct
19 Correct 109 ms 202564 KB Output is correct
20 Correct 98 ms 202504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 203020 KB Output is correct
2 Correct 116 ms 203432 KB Output is correct
3 Correct 123 ms 209972 KB Output is correct
4 Correct 146 ms 213332 KB Output is correct
5 Correct 106 ms 202532 KB Output is correct
6 Correct 109 ms 202372 KB Output is correct
7 Correct 142 ms 215124 KB Output is correct
8 Correct 151 ms 210648 KB Output is correct
9 Correct 123 ms 203344 KB Output is correct
10 Correct 147 ms 210000 KB Output is correct
11 Correct 122 ms 207324 KB Output is correct
12 Correct 129 ms 203452 KB Output is correct
13 Correct 122 ms 203284 KB Output is correct
14 Correct 145 ms 204760 KB Output is correct
15 Correct 122 ms 205524 KB Output is correct
16 Correct 136 ms 204592 KB Output is correct
17 Correct 128 ms 202784 KB Output is correct
18 Correct 120 ms 202908 KB Output is correct
19 Correct 109 ms 202564 KB Output is correct
20 Correct 98 ms 202504 KB Output is correct
21 Correct 123 ms 203160 KB Output is correct
22 Correct 143 ms 203348 KB Output is correct
23 Correct 130 ms 209916 KB Output is correct
24 Correct 135 ms 213540 KB Output is correct
25 Correct 97 ms 202408 KB Output is correct
26 Correct 106 ms 202500 KB Output is correct
27 Correct 133 ms 214520 KB Output is correct
28 Correct 133 ms 211284 KB Output is correct
29 Correct 121 ms 205000 KB Output is correct
30 Correct 135 ms 209768 KB Output is correct
31 Correct 122 ms 207024 KB Output is correct
32 Correct 123 ms 203276 KB Output is correct
33 Correct 119 ms 203352 KB Output is correct
34 Correct 122 ms 205628 KB Output is correct
35 Correct 115 ms 204148 KB Output is correct
36 Correct 138 ms 204836 KB Output is correct
37 Correct 115 ms 202480 KB Output is correct
38 Correct 106 ms 202392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 203700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 299360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 203020 KB Output is correct
2 Correct 116 ms 203432 KB Output is correct
3 Correct 123 ms 209972 KB Output is correct
4 Correct 146 ms 213332 KB Output is correct
5 Correct 106 ms 202532 KB Output is correct
6 Correct 109 ms 202372 KB Output is correct
7 Correct 142 ms 215124 KB Output is correct
8 Correct 151 ms 210648 KB Output is correct
9 Correct 123 ms 203344 KB Output is correct
10 Correct 147 ms 210000 KB Output is correct
11 Correct 122 ms 207324 KB Output is correct
12 Correct 129 ms 203452 KB Output is correct
13 Correct 122 ms 203284 KB Output is correct
14 Correct 145 ms 204760 KB Output is correct
15 Correct 122 ms 205524 KB Output is correct
16 Correct 136 ms 204592 KB Output is correct
17 Correct 128 ms 202784 KB Output is correct
18 Correct 120 ms 202908 KB Output is correct
19 Correct 109 ms 202564 KB Output is correct
20 Correct 98 ms 202504 KB Output is correct
21 Execution timed out 1051 ms 203700 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 501 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 203020 KB Output is correct
2 Correct 116 ms 203432 KB Output is correct
3 Correct 123 ms 209972 KB Output is correct
4 Correct 146 ms 213332 KB Output is correct
5 Correct 106 ms 202532 KB Output is correct
6 Correct 109 ms 202372 KB Output is correct
7 Correct 142 ms 215124 KB Output is correct
8 Correct 151 ms 210648 KB Output is correct
9 Correct 123 ms 203344 KB Output is correct
10 Correct 147 ms 210000 KB Output is correct
11 Correct 122 ms 207324 KB Output is correct
12 Correct 129 ms 203452 KB Output is correct
13 Correct 122 ms 203284 KB Output is correct
14 Correct 145 ms 204760 KB Output is correct
15 Correct 122 ms 205524 KB Output is correct
16 Correct 136 ms 204592 KB Output is correct
17 Correct 128 ms 202784 KB Output is correct
18 Correct 120 ms 202908 KB Output is correct
19 Correct 109 ms 202564 KB Output is correct
20 Correct 98 ms 202504 KB Output is correct
21 Correct 123 ms 203160 KB Output is correct
22 Correct 143 ms 203348 KB Output is correct
23 Correct 130 ms 209916 KB Output is correct
24 Correct 135 ms 213540 KB Output is correct
25 Correct 97 ms 202408 KB Output is correct
26 Correct 106 ms 202500 KB Output is correct
27 Correct 133 ms 214520 KB Output is correct
28 Correct 133 ms 211284 KB Output is correct
29 Correct 121 ms 205000 KB Output is correct
30 Correct 135 ms 209768 KB Output is correct
31 Correct 122 ms 207024 KB Output is correct
32 Correct 123 ms 203276 KB Output is correct
33 Correct 119 ms 203352 KB Output is correct
34 Correct 122 ms 205628 KB Output is correct
35 Correct 115 ms 204148 KB Output is correct
36 Correct 138 ms 204836 KB Output is correct
37 Correct 115 ms 202480 KB Output is correct
38 Correct 106 ms 202392 KB Output is correct
39 Execution timed out 1051 ms 203700 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 203020 KB Output is correct
2 Correct 116 ms 203432 KB Output is correct
3 Correct 123 ms 209972 KB Output is correct
4 Correct 146 ms 213332 KB Output is correct
5 Correct 106 ms 202532 KB Output is correct
6 Correct 109 ms 202372 KB Output is correct
7 Correct 142 ms 215124 KB Output is correct
8 Correct 151 ms 210648 KB Output is correct
9 Correct 123 ms 203344 KB Output is correct
10 Correct 147 ms 210000 KB Output is correct
11 Correct 122 ms 207324 KB Output is correct
12 Correct 129 ms 203452 KB Output is correct
13 Correct 122 ms 203284 KB Output is correct
14 Correct 145 ms 204760 KB Output is correct
15 Correct 122 ms 205524 KB Output is correct
16 Correct 136 ms 204592 KB Output is correct
17 Correct 128 ms 202784 KB Output is correct
18 Correct 120 ms 202908 KB Output is correct
19 Correct 109 ms 202564 KB Output is correct
20 Correct 98 ms 202504 KB Output is correct
21 Correct 123 ms 203160 KB Output is correct
22 Correct 143 ms 203348 KB Output is correct
23 Correct 130 ms 209916 KB Output is correct
24 Correct 135 ms 213540 KB Output is correct
25 Correct 97 ms 202408 KB Output is correct
26 Correct 106 ms 202500 KB Output is correct
27 Correct 133 ms 214520 KB Output is correct
28 Correct 133 ms 211284 KB Output is correct
29 Correct 121 ms 205000 KB Output is correct
30 Correct 135 ms 209768 KB Output is correct
31 Correct 122 ms 207024 KB Output is correct
32 Correct 123 ms 203276 KB Output is correct
33 Correct 119 ms 203352 KB Output is correct
34 Correct 122 ms 205628 KB Output is correct
35 Correct 115 ms 204148 KB Output is correct
36 Correct 138 ms 204836 KB Output is correct
37 Correct 115 ms 202480 KB Output is correct
38 Correct 106 ms 202392 KB Output is correct
39 Execution timed out 1051 ms 203700 KB Time limit exceeded
40 Halted 0 ms 0 KB -