답안 #342253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342253 2021-01-01T16:52:23 Z Nursik Sterilizing Spray (JOI15_sterilizing) C++14
15 / 100
5000 ms 4956 KB
#include <bits/stdc++.h>
          
#define fi first
#define se second
#define pp pop_back
#define ll long long
#define pb push_back
#define ld long double
#define debug cout << "OK\n";
#define all(x) x.begin(), x.end() 
#define mp make_pair 
using namespace std;        
 
const ll N = 1e6 + 200;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ll pe = mod2; 
const ll pe2 = 570210983;
const ld eps = 1e-6; 
 
 
/*
Rucode: jaqVYNrpMj
JUDGE_ID: 295965SY
dl:160532
*/
void data() {
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif	
}
void speed_force() {
	ios_base::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
} 
                     
int n, q, k;
ll a[N];
ll f[N];
int type;
void upd(int pos, ll val)
{
	for (int i = pos; i <= n; i |= (i + 1))
	{
		f[i] += val;
	}
}
ll get(int pos)
{
	ll res = 0;
	for (int i = pos; i >= 1; i = (i & (i + 1)) - 1)
	{
		res += f[i];
	}
	return res;
}
int main()
{
	data();     
	cin >> n >> q >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		upd(i, a[i]);
	}   
	//subtask 3
	if (k == 1)
	{
		for (int i = 1; i <= q; i++)
		{
			cin >> type;
			if (type == 1)
			{
				int pos, x;
				cin >> pos >> x;
				upd(pos, -a[pos]);
				a[pos] = x;
				upd(pos, x);
			}
			else if (type == 2)
			{
				int l, r;
				cin >> l >> r;
			}
			else
			{
				int l, r;
				cin >> l >> r;
				cout << get(r) - get(l - 1) << '\n';
			}
		}
		return 0;
	}
	//subtask 1
	for (int i = 1; i <= q; i++)
	{
		cin >> type;
		if (type == 1)
		{
			int pos, x;
			cin >> pos >> x;
			upd(pos, -a[pos]);
			a[pos] = x;
			upd(pos, x);
		}
		else if (type == 2)
		{
			int l, r;
			cin >> l >> r;
			for (int j = l; j <= r; j++)
			{
				upd(j, -a[j]);
				upd(j, a[j] / k);
				a[j] /= k;
			}
		}
		else
		{
			int l, r;
			cin >> l >> r;
			cout << get(r) - get(l - 1) << '\n';
		}	
	}  
}
/*           
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 12 ms 364 KB Output is correct
5 Correct 16 ms 364 KB Output is correct
6 Correct 20 ms 364 KB Output is correct
7 Correct 16 ms 364 KB Output is correct
8 Correct 18 ms 364 KB Output is correct
9 Correct 17 ms 364 KB Output is correct
10 Correct 17 ms 364 KB Output is correct
11 Correct 16 ms 364 KB Output is correct
12 Correct 17 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 182 ms 1516 KB Output is correct
2 Correct 157 ms 2924 KB Output is correct
3 Correct 135 ms 3564 KB Output is correct
4 Correct 171 ms 4332 KB Output is correct
5 Correct 207 ms 4844 KB Output is correct
6 Correct 208 ms 4844 KB Output is correct
7 Correct 205 ms 4956 KB Output is correct
8 Correct 209 ms 4844 KB Output is correct
9 Correct 199 ms 4844 KB Output is correct
10 Correct 200 ms 4716 KB Output is correct
11 Correct 200 ms 4716 KB Output is correct
12 Correct 202 ms 4716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 748 KB Output is correct
2 Correct 1298 ms 1132 KB Output is correct
3 Correct 2054 ms 1260 KB Output is correct
4 Correct 4046 ms 1064 KB Output is correct
5 Execution timed out 5064 ms 2100 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5062 ms 1336 KB Time limit exceeded
2 Halted 0 ms 0 KB -