#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
int n, q, k;
int a[maxn];
void brute(int type, int t, int u, ll& res) {
if (type==1) {
int idx = t;
int val = u;
a[idx] = val;
}
if (type==2) {
int l = t;
int r = u;
for (int i=l; i<=r; i++) {
a[i] /= k;
}
}
if (type==3) {
res = 0;
int l = t;
int r = u;
for (int i=l; i<=r; i++) {
res += a[i];
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>q>>k;
for (int i=1; i<=n; i++) {
cin>>a[i];
}
for (int i=0; i<q; i++) {
int s,t,u;
cin>>s>>t>>u;
ll bans=-1; brute(s,t,u,bans);
if (s==3) cout<<bans<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
416 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
436 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
544 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
7 ms |
384 KB |
Output is correct |
10 |
Correct |
8 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4467 ms |
1184 KB |
Output is correct |
2 |
Correct |
2740 ms |
968 KB |
Output is correct |
3 |
Correct |
4396 ms |
1272 KB |
Output is correct |
4 |
Execution timed out |
5082 ms |
1452 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
142 ms |
512 KB |
Output is correct |
2 |
Correct |
346 ms |
760 KB |
Output is correct |
3 |
Correct |
548 ms |
824 KB |
Output is correct |
4 |
Correct |
1213 ms |
760 KB |
Output is correct |
5 |
Correct |
4994 ms |
1144 KB |
Output is correct |
6 |
Correct |
4952 ms |
1052 KB |
Output is correct |
7 |
Correct |
4990 ms |
1536 KB |
Output is correct |
8 |
Correct |
4991 ms |
2452 KB |
Output is correct |
9 |
Execution timed out |
5056 ms |
1784 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1792 ms |
1272 KB |
Output is correct |
2 |
Correct |
2071 ms |
1288 KB |
Output is correct |
3 |
Correct |
1097 ms |
1020 KB |
Output is correct |
4 |
Correct |
1529 ms |
888 KB |
Output is correct |
5 |
Execution timed out |
5038 ms |
1184 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |