답안 #502431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502431 2022-01-06T01:31:41 Z cig32 푸드 코트 (JOI21_foodcourt) C++17
7 / 100
1000 ms 524292 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
    int u = uniform_int_distribution<int>(x, y)(rng);
    return u;
}
int bm(int b, int p) { // bigmod
    if(p==0) return 1;
    int r = bm(b, p/2);
    if(p&1) return (((r*r) % MOD) * b) % MOD;
    return (r*r) % MOD;
}
int N, M, Q;
deque<pair<int, int> > ok[MAXN];
void join(int l, int r, int c, int k) {
    for(int i=l; i<=r; i++) ok[i].push_back({c, k});
}
void leave(int l, int r, int k) {
    for(int i=l; i<=r; i++) {
        int m = k;
        while(ok[i].size() && m > 0) {
            pair<int, int> f = ok[i].front();
            if(m >= f.second) {
                m -= f.second;
                ok[i].pop_front();
            }
            else {
                f.second -= m;
                ok[i].pop_front();
                ok[i].push_front(f);
                break;
            }
        }
    }
}
int service(int a, int b) {
    stack<pair<int, int> > st;
    int ans = 0;
    while(ok[a].size()) {
        pair<int, int> f = ok[a].front();
        if(b <= f.second) {
            ans = f.first;
            break;
        }
        else b -= f.second;
        st.push(f);
        ok[a].pop_front();
    }
    while(st.size()) {
        ok[a].push_front(st.top());
        st.pop();
    }
    return ans;
}
void solve(int tc) {
    cin >> N >> M >> Q;
    while(Q--) {
        int t;
        cin >> t;
        if(t == 1) {
            int l, r, c, k;
            cin >> l >> r >> c >> k;
            join(l, r, c, k);
        }
        else if(t == 2) {
            int l, r, k;
            cin >> l >> r >> k;
            leave(l, r, k);
        }
        else {
            int a, b;
            cin >> a >> b;
            cout << service(a, b) << "\n";
        }
    }
}
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1; //cin >> t;
    for(int i=1; i<=t; i++) {
        solve(i);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 202688 KB Output is correct
2 Correct 134 ms 203072 KB Output is correct
3 Correct 141 ms 209664 KB Output is correct
4 Correct 146 ms 213260 KB Output is correct
5 Correct 121 ms 202220 KB Output is correct
6 Correct 116 ms 202240 KB Output is correct
7 Correct 156 ms 214720 KB Output is correct
8 Correct 144 ms 210396 KB Output is correct
9 Correct 141 ms 203132 KB Output is correct
10 Correct 152 ms 209860 KB Output is correct
11 Correct 143 ms 206924 KB Output is correct
12 Correct 140 ms 203180 KB Output is correct
13 Correct 136 ms 203196 KB Output is correct
14 Correct 141 ms 204284 KB Output is correct
15 Correct 136 ms 205112 KB Output is correct
16 Correct 140 ms 204308 KB Output is correct
17 Correct 132 ms 202584 KB Output is correct
18 Correct 138 ms 202820 KB Output is correct
19 Correct 125 ms 202236 KB Output is correct
20 Correct 114 ms 202140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 202688 KB Output is correct
2 Correct 134 ms 203072 KB Output is correct
3 Correct 141 ms 209664 KB Output is correct
4 Correct 146 ms 213260 KB Output is correct
5 Correct 121 ms 202220 KB Output is correct
6 Correct 116 ms 202240 KB Output is correct
7 Correct 156 ms 214720 KB Output is correct
8 Correct 144 ms 210396 KB Output is correct
9 Correct 141 ms 203132 KB Output is correct
10 Correct 152 ms 209860 KB Output is correct
11 Correct 143 ms 206924 KB Output is correct
12 Correct 140 ms 203180 KB Output is correct
13 Correct 136 ms 203196 KB Output is correct
14 Correct 141 ms 204284 KB Output is correct
15 Correct 136 ms 205112 KB Output is correct
16 Correct 140 ms 204308 KB Output is correct
17 Correct 132 ms 202584 KB Output is correct
18 Correct 138 ms 202820 KB Output is correct
19 Correct 125 ms 202236 KB Output is correct
20 Correct 114 ms 202140 KB Output is correct
21 Correct 140 ms 202916 KB Output is correct
22 Correct 142 ms 203212 KB Output is correct
23 Correct 145 ms 209604 KB Output is correct
24 Correct 145 ms 213280 KB Output is correct
25 Correct 125 ms 202268 KB Output is correct
26 Correct 115 ms 202276 KB Output is correct
27 Correct 146 ms 214172 KB Output is correct
28 Correct 154 ms 211176 KB Output is correct
29 Correct 157 ms 204832 KB Output is correct
30 Correct 147 ms 209460 KB Output is correct
31 Correct 151 ms 207032 KB Output is correct
32 Correct 141 ms 202988 KB Output is correct
33 Correct 145 ms 203052 KB Output is correct
34 Correct 149 ms 205336 KB Output is correct
35 Correct 150 ms 203988 KB Output is correct
36 Correct 150 ms 204328 KB Output is correct
37 Correct 116 ms 202228 KB Output is correct
38 Correct 115 ms 202292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 202284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1102 ms 299404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 202688 KB Output is correct
2 Correct 134 ms 203072 KB Output is correct
3 Correct 141 ms 209664 KB Output is correct
4 Correct 146 ms 213260 KB Output is correct
5 Correct 121 ms 202220 KB Output is correct
6 Correct 116 ms 202240 KB Output is correct
7 Correct 156 ms 214720 KB Output is correct
8 Correct 144 ms 210396 KB Output is correct
9 Correct 141 ms 203132 KB Output is correct
10 Correct 152 ms 209860 KB Output is correct
11 Correct 143 ms 206924 KB Output is correct
12 Correct 140 ms 203180 KB Output is correct
13 Correct 136 ms 203196 KB Output is correct
14 Correct 141 ms 204284 KB Output is correct
15 Correct 136 ms 205112 KB Output is correct
16 Correct 140 ms 204308 KB Output is correct
17 Correct 132 ms 202584 KB Output is correct
18 Correct 138 ms 202820 KB Output is correct
19 Correct 125 ms 202236 KB Output is correct
20 Correct 114 ms 202140 KB Output is correct
21 Execution timed out 1098 ms 202284 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 444 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 202688 KB Output is correct
2 Correct 134 ms 203072 KB Output is correct
3 Correct 141 ms 209664 KB Output is correct
4 Correct 146 ms 213260 KB Output is correct
5 Correct 121 ms 202220 KB Output is correct
6 Correct 116 ms 202240 KB Output is correct
7 Correct 156 ms 214720 KB Output is correct
8 Correct 144 ms 210396 KB Output is correct
9 Correct 141 ms 203132 KB Output is correct
10 Correct 152 ms 209860 KB Output is correct
11 Correct 143 ms 206924 KB Output is correct
12 Correct 140 ms 203180 KB Output is correct
13 Correct 136 ms 203196 KB Output is correct
14 Correct 141 ms 204284 KB Output is correct
15 Correct 136 ms 205112 KB Output is correct
16 Correct 140 ms 204308 KB Output is correct
17 Correct 132 ms 202584 KB Output is correct
18 Correct 138 ms 202820 KB Output is correct
19 Correct 125 ms 202236 KB Output is correct
20 Correct 114 ms 202140 KB Output is correct
21 Correct 140 ms 202916 KB Output is correct
22 Correct 142 ms 203212 KB Output is correct
23 Correct 145 ms 209604 KB Output is correct
24 Correct 145 ms 213280 KB Output is correct
25 Correct 125 ms 202268 KB Output is correct
26 Correct 115 ms 202276 KB Output is correct
27 Correct 146 ms 214172 KB Output is correct
28 Correct 154 ms 211176 KB Output is correct
29 Correct 157 ms 204832 KB Output is correct
30 Correct 147 ms 209460 KB Output is correct
31 Correct 151 ms 207032 KB Output is correct
32 Correct 141 ms 202988 KB Output is correct
33 Correct 145 ms 203052 KB Output is correct
34 Correct 149 ms 205336 KB Output is correct
35 Correct 150 ms 203988 KB Output is correct
36 Correct 150 ms 204328 KB Output is correct
37 Correct 116 ms 202228 KB Output is correct
38 Correct 115 ms 202292 KB Output is correct
39 Execution timed out 1098 ms 202284 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 202688 KB Output is correct
2 Correct 134 ms 203072 KB Output is correct
3 Correct 141 ms 209664 KB Output is correct
4 Correct 146 ms 213260 KB Output is correct
5 Correct 121 ms 202220 KB Output is correct
6 Correct 116 ms 202240 KB Output is correct
7 Correct 156 ms 214720 KB Output is correct
8 Correct 144 ms 210396 KB Output is correct
9 Correct 141 ms 203132 KB Output is correct
10 Correct 152 ms 209860 KB Output is correct
11 Correct 143 ms 206924 KB Output is correct
12 Correct 140 ms 203180 KB Output is correct
13 Correct 136 ms 203196 KB Output is correct
14 Correct 141 ms 204284 KB Output is correct
15 Correct 136 ms 205112 KB Output is correct
16 Correct 140 ms 204308 KB Output is correct
17 Correct 132 ms 202584 KB Output is correct
18 Correct 138 ms 202820 KB Output is correct
19 Correct 125 ms 202236 KB Output is correct
20 Correct 114 ms 202140 KB Output is correct
21 Correct 140 ms 202916 KB Output is correct
22 Correct 142 ms 203212 KB Output is correct
23 Correct 145 ms 209604 KB Output is correct
24 Correct 145 ms 213280 KB Output is correct
25 Correct 125 ms 202268 KB Output is correct
26 Correct 115 ms 202276 KB Output is correct
27 Correct 146 ms 214172 KB Output is correct
28 Correct 154 ms 211176 KB Output is correct
29 Correct 157 ms 204832 KB Output is correct
30 Correct 147 ms 209460 KB Output is correct
31 Correct 151 ms 207032 KB Output is correct
32 Correct 141 ms 202988 KB Output is correct
33 Correct 145 ms 203052 KB Output is correct
34 Correct 149 ms 205336 KB Output is correct
35 Correct 150 ms 203988 KB Output is correct
36 Correct 150 ms 204328 KB Output is correct
37 Correct 116 ms 202228 KB Output is correct
38 Correct 115 ms 202292 KB Output is correct
39 Execution timed out 1098 ms 202284 KB Time limit exceeded
40 Halted 0 ms 0 KB -