I_AK_Ynoi @ 2022-07-15 21:55:02
语言:C ||
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int SIZE = 1e6;
const int INF = 0x3f3f3f3f3f3f;
int n, a[SIZE+1], m;
inline int read(){
register int x = 0, f = 1;
register char ch = getchar();
while(!isdigit(ch)){
if(ch == '-'){
f = -1;
}
ch = getchar();
}
while(isdigit(ch)){
x = x * 10 + ch - '0';
ch = getchar();
}
return x*f;
}
signed main(){
n = read(), m = read();
for(register int i = 1; i <= n; i++){
a[i] = read();
}
while(m--){
int op = read(), l = read(), r = read();
if(op == 1){
int x = read();
for(register int i = l; i <= r; i++){
a[i] = x;
}
}else if(op == 2){
int x = read();
for(register int i = l; i <= r; i++){
a[i] += x;
}
}else{
int ans = -INF;
for(register int i = l; i <= r; i++){
ans = max(ans, a[i]);
}
printf("%lld\n", ans);
}
}
return 0;
}
by Ynoi @ 2022-07-15 21:58:38
@I_AK_Ynoi 你还真想
by I_AK_Ynoi @ 2022-07-15 22:09:56
@Ynoi 我这个确实是暴力做法,线段树明天再说
by 喵仔牛奶 @ 2022-07-16 08:57:17
用自己写的min、max