比赛 |
EYOI与SBOI开学欢乐赛13th |
评测结果 |
WWWWEEEEEE |
题目名称 |
WHZ 的序列 |
最终得分 |
0 |
用户昵称 |
李星昊 |
运行时间 |
2.353 s |
代码语言 |
C++ |
内存使用 |
5.92 MiB |
提交时间 |
2022-10-21 19:41:09 |
显示代码纯文本
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
ll a[110000],q,opt,l,r,d;
int main () {
freopen("whz_sequence.in","r",stdin);
freopen("whz_sequence.out","w",stdout);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
cin >> q;
for (int i = 1; i <= q; i++) {
cin >> opt;
ll c;
if (opt == 2) {
cin >> l >> r;
c = a[l] - (a[l + 1] + 1);
ll c1 = 2;
char ch = '+';
for (int j = l + 1; j <= r; j++) {
if (ch == '+') {
ch = '-';
c += (a[j] + c1) + (a[j] + (c1 + 1));
c1 += 1;
}
else if (ch == '-') {
ch = '+';
c += (a[j] + c1) - (a[j] + (c1 + 1));
c1 += 1;
}
}
cout << c << endl;
} else if (opt == 1) {
cin >> l >> r >> d;
for (int j = l; j <= r; j++) {
a[j] += d;
}
}
}
return 0;
}