专栏文章
C. 【二月份 -- 基础语法组】-- T3 --统计
个人记录参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mipbdv36
- 此快照首次捕获于
- 2025/12/03 09:14 3 个月前
- 此快照最后确认于
- 2025/12/03 09:14 3 个月前
https://cspjs.online/contest/649/problem/3
CPP#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2e5 + 5;//=2*10^5+5
int a[SIZE], sum[SIZE];
int main() {
freopen("statistics.in", "r", stdin);
freopen("statistics.out", "w", stdout);
int n, p;
cin >> n >> p;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum[i] = sum[i - 1] + (a[i] != a[i - 1]);
}
while (n--) {
int l;
int r;
cin >> l >> r;
cout << sum[r] - sum[l - 1] + (a[l] == a[l - 1]) << endl;
}
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...