我是靠谱客的博主 大胆酸奶,这篇文章主要介绍HDOJ 4288 Coder 线段树 vector偷懒做法,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//4288 Coder 线段树 vector偷懒做法 /* 题意:给一个序列,每次有3种操作: 1、往有序集合中增加一个原素x 2、把集合中的元素x 3、查询集合中下标%5=3的元素的总和 思路:vector */ #include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> using namespace std; char op[5]; int n,x; __int64 ans; vector<int>V; int main(){ int i; while(scanf("%d",&n)!=EOF){ V.clear(); while(n--){ scanf("%s",op); if(op[0] == 's'){ ans = 0; for(i = 2; i < V.size(); i+=5) ans += V[i]; printf("%I64dn",ans); } else{ scanf("%d",&x); if(op[0] == 'a') V.insert(lower_bound(V.begin(),V.end(),x),x); else V.erase(lower_bound(V.begin(),V.end(),x)); } } } return 0; }

最后

以上就是大胆酸奶最近收集整理的关于HDOJ 4288 Coder 线段树 vector偷懒做法的全部内容,更多相关HDOJ内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(85)

评论列表共有 0 条评论

立即
投稿
返回
顶部