답안 #752710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
752710 2023-06-03T13:17:03 Z jmyszka2007 Sterilizing Spray (JOI15_sterilizing) C++17
80 / 100
5000 ms 9824 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int LIM = 1e5;
constexpr int base = (1 << 17);
ll tri[2 * base];
int tab[LIM + 10];
void upd(int v, int x) {
	v += base;
	tri[v] = x;
	v /= 2;
	while(v > 0) {
		tri[v] = tri[2 * v] + tri[2 * v + 1];
		v /= 2;
	}
}
ll que(int l, int r) {
	l += base;
	r += base;
	ll ans = 0;
	while(l <= r) {
		if(l & 1) {
			ans += tri[l];
		}
		if(!(r & 1)) {
			ans += tri[r];
		}
		l = (l + 1) / 2;
		r = (r - 1) / 2;
	}
	return ans;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k, t;
	cin >> n >> t >> k;
	set<int>s;
	for(int i = 1; i <= n; i++) {
		cin >> tab[i];
		if(tab[i]) {
			s.insert(i);
		}
		upd(i, tab[i]);
	}
	while(t--) {
		int tp;
		cin >> tp;
		if(tp == 1) {
			int a, b;
			cin >> a >> b;
			tab[a] = b;
			if(b) {
				s.insert(a);
			}
			upd(a, b);
		}
		else if(tp == 2) {
			int l, r;
			cin >> l >> r;
			vector<int>us;
			auto it = s.lower_bound(l);
			while(it != s.end() && *it <= r) {
				tab[*it] /= k;
				upd(*it, tab[*it]);
				if(!tab[*it]) {
					us.push_back(*it);
				}
				it++;
			}
			for(auto x : us) {
				s.erase(x);
			}
		}
		else {
			int l, r;
			cin >> l >> r;
			cout << que(l, r) << '\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Correct 5 ms 592 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 5 ms 596 KB Output is correct
9 Correct 6 ms 592 KB Output is correct
10 Correct 6 ms 596 KB Output is correct
11 Correct 5 ms 596 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5037 ms 3876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 652 KB Output is correct
2 Correct 17 ms 2260 KB Output is correct
3 Correct 19 ms 2356 KB Output is correct
4 Correct 39 ms 1508 KB Output is correct
5 Correct 57 ms 4764 KB Output is correct
6 Correct 57 ms 4692 KB Output is correct
7 Execution timed out 5042 ms 4676 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 3924 KB Output is correct
2 Correct 83 ms 5708 KB Output is correct
3 Correct 114 ms 4576 KB Output is correct
4 Correct 90 ms 4360 KB Output is correct
5 Correct 139 ms 9708 KB Output is correct
6 Correct 162 ms 9680 KB Output is correct
7 Correct 132 ms 9676 KB Output is correct
8 Correct 193 ms 9780 KB Output is correct
9 Correct 180 ms 9620 KB Output is correct
10 Correct 180 ms 9824 KB Output is correct
11 Correct 137 ms 9652 KB Output is correct
12 Correct 237 ms 9644 KB Output is correct