답안 #1081218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081218 2024-08-29T19:48:43 Z Trent 푸드 코트 (JOI21_foodcourt) C++17
7 / 100
1000 ms 20316 KB
#include <iostream>
#include "bits/stdc++.h"
#define forR(i, x) for(int i=0; i < (x); ++i)
#define REP(i, a, b) for(int i=(a); i<(b); ++i)
#define all(x) x.begin(), x.end()
#define boost() cin.sync_with_stdio(0); cin.tie(0)
#define asst(x) if(!(x)) exit(1)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MN = 2e5 + 10;
int len[MN];
struct ev{
	int ti;
	ll to;
};
ll ch[MN];
int c[MN];
bool us[MN];
vector<ev> evs[MN];
struct query{
	int ai, i; ll b;
};
vector<query> qus[MN];
int ans[MN];

int main(){
	boost();
	int n, m, q; cin >> n >> m >> q;
	int ai=0;
	forR(i, q){
		int ty; cin >> ty;
		if(ty == 1){
			int l, r, k; cin >> l >> r >> c[i] >> k;
			evs[l].push_back({i, k});
			evs[r+1].push_back({i, 0});
		} else if(ty == 2){
			int l, r, k; cin >> l >> r >> k;
			evs[l].push_back({i, -k});
			evs[r+1].push_back({i, 0});
		} else {
			int a; ll b; cin >> a >> b;
			qus[a].push_back({ai++, i, b});
		}
	}
	REP(i, 1, n+1){
		for(auto [ti, to] : evs[i]) {
			ch[ti] = to;
		}
		for(auto [ai, ti, b] : qus[i]) {
			int j = 0;
			bool found = false;
			ll cur = 0;
			ll nSum = 0;
			REP(k, 0, ti + 1) if(ch[k] < 0) nSum += ch[k];
			for(; j <= ti && !found;) {
				cur = max(0LL, cur + ch[j]);
				if(ch[j] < 0) nSum -= ch[j];
				if(cur + nSum >= b) {
					found = true;
				} else {
					++j;
				}
			}
			if(found) {
				ans[ai] = c[j];
			} else ans[ai] = 0;
		}
	}
	forR(i, ai) cout << ans[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9820 KB Output is correct
2 Correct 7 ms 9808 KB Output is correct
3 Correct 6 ms 9816 KB Output is correct
4 Correct 6 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 6 ms 10076 KB Output is correct
7 Correct 6 ms 9816 KB Output is correct
8 Correct 6 ms 9820 KB Output is correct
9 Correct 5 ms 9816 KB Output is correct
10 Correct 5 ms 9836 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 6 ms 10028 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 5 ms 9880 KB Output is correct
15 Correct 5 ms 9820 KB Output is correct
16 Correct 5 ms 9820 KB Output is correct
17 Correct 5 ms 9820 KB Output is correct
18 Correct 5 ms 9876 KB Output is correct
19 Correct 5 ms 9820 KB Output is correct
20 Correct 5 ms 9948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9820 KB Output is correct
2 Correct 7 ms 9808 KB Output is correct
3 Correct 6 ms 9816 KB Output is correct
4 Correct 6 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 6 ms 10076 KB Output is correct
7 Correct 6 ms 9816 KB Output is correct
8 Correct 6 ms 9820 KB Output is correct
9 Correct 5 ms 9816 KB Output is correct
10 Correct 5 ms 9836 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 6 ms 10028 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 5 ms 9880 KB Output is correct
15 Correct 5 ms 9820 KB Output is correct
16 Correct 5 ms 9820 KB Output is correct
17 Correct 5 ms 9820 KB Output is correct
18 Correct 5 ms 9876 KB Output is correct
19 Correct 5 ms 9820 KB Output is correct
20 Correct 5 ms 9948 KB Output is correct
21 Correct 6 ms 9820 KB Output is correct
22 Correct 6 ms 9820 KB Output is correct
23 Correct 5 ms 9820 KB Output is correct
24 Correct 6 ms 10044 KB Output is correct
25 Correct 5 ms 9964 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 5 ms 9820 KB Output is correct
28 Correct 6 ms 10044 KB Output is correct
29 Correct 6 ms 9876 KB Output is correct
30 Correct 5 ms 9820 KB Output is correct
31 Correct 5 ms 9992 KB Output is correct
32 Correct 6 ms 9996 KB Output is correct
33 Correct 5 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 7 ms 9820 KB Output is correct
36 Correct 6 ms 9820 KB Output is correct
37 Correct 5 ms 9820 KB Output is correct
38 Correct 5 ms 9916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 13392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 20316 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9820 KB Output is correct
2 Correct 7 ms 9808 KB Output is correct
3 Correct 6 ms 9816 KB Output is correct
4 Correct 6 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 6 ms 10076 KB Output is correct
7 Correct 6 ms 9816 KB Output is correct
8 Correct 6 ms 9820 KB Output is correct
9 Correct 5 ms 9816 KB Output is correct
10 Correct 5 ms 9836 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 6 ms 10028 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 5 ms 9880 KB Output is correct
15 Correct 5 ms 9820 KB Output is correct
16 Correct 5 ms 9820 KB Output is correct
17 Correct 5 ms 9820 KB Output is correct
18 Correct 5 ms 9876 KB Output is correct
19 Correct 5 ms 9820 KB Output is correct
20 Correct 5 ms 9948 KB Output is correct
21 Execution timed out 1062 ms 13392 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 12888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9820 KB Output is correct
2 Correct 7 ms 9808 KB Output is correct
3 Correct 6 ms 9816 KB Output is correct
4 Correct 6 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 6 ms 10076 KB Output is correct
7 Correct 6 ms 9816 KB Output is correct
8 Correct 6 ms 9820 KB Output is correct
9 Correct 5 ms 9816 KB Output is correct
10 Correct 5 ms 9836 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 6 ms 10028 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 5 ms 9880 KB Output is correct
15 Correct 5 ms 9820 KB Output is correct
16 Correct 5 ms 9820 KB Output is correct
17 Correct 5 ms 9820 KB Output is correct
18 Correct 5 ms 9876 KB Output is correct
19 Correct 5 ms 9820 KB Output is correct
20 Correct 5 ms 9948 KB Output is correct
21 Correct 6 ms 9820 KB Output is correct
22 Correct 6 ms 9820 KB Output is correct
23 Correct 5 ms 9820 KB Output is correct
24 Correct 6 ms 10044 KB Output is correct
25 Correct 5 ms 9964 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 5 ms 9820 KB Output is correct
28 Correct 6 ms 10044 KB Output is correct
29 Correct 6 ms 9876 KB Output is correct
30 Correct 5 ms 9820 KB Output is correct
31 Correct 5 ms 9992 KB Output is correct
32 Correct 6 ms 9996 KB Output is correct
33 Correct 5 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 7 ms 9820 KB Output is correct
36 Correct 6 ms 9820 KB Output is correct
37 Correct 5 ms 9820 KB Output is correct
38 Correct 5 ms 9916 KB Output is correct
39 Execution timed out 1062 ms 13392 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9820 KB Output is correct
2 Correct 7 ms 9808 KB Output is correct
3 Correct 6 ms 9816 KB Output is correct
4 Correct 6 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 6 ms 10076 KB Output is correct
7 Correct 6 ms 9816 KB Output is correct
8 Correct 6 ms 9820 KB Output is correct
9 Correct 5 ms 9816 KB Output is correct
10 Correct 5 ms 9836 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 6 ms 10028 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 5 ms 9880 KB Output is correct
15 Correct 5 ms 9820 KB Output is correct
16 Correct 5 ms 9820 KB Output is correct
17 Correct 5 ms 9820 KB Output is correct
18 Correct 5 ms 9876 KB Output is correct
19 Correct 5 ms 9820 KB Output is correct
20 Correct 5 ms 9948 KB Output is correct
21 Correct 6 ms 9820 KB Output is correct
22 Correct 6 ms 9820 KB Output is correct
23 Correct 5 ms 9820 KB Output is correct
24 Correct 6 ms 10044 KB Output is correct
25 Correct 5 ms 9964 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 5 ms 9820 KB Output is correct
28 Correct 6 ms 10044 KB Output is correct
29 Correct 6 ms 9876 KB Output is correct
30 Correct 5 ms 9820 KB Output is correct
31 Correct 5 ms 9992 KB Output is correct
32 Correct 6 ms 9996 KB Output is correct
33 Correct 5 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 7 ms 9820 KB Output is correct
36 Correct 6 ms 9820 KB Output is correct
37 Correct 5 ms 9820 KB Output is correct
38 Correct 5 ms 9916 KB Output is correct
39 Execution timed out 1062 ms 13392 KB Time limit exceeded
40 Halted 0 ms 0 KB -