首页 > 代码库 > codeforces 85D. Sum of Medians
codeforces 85D. Sum of Medians
二次联通门 : codeforces 85D. Sum of Medians
/* codeforces 85D. Sum of Medians 正解线段树或是平衡树 结果用vector暴力卡过去了 */ #include <algorithm> #include <iostream> #include <cstdio> #include <vector> using namespace std; void read (int &now) { register char word = getchar (); int temp = 0; for (; !isdigit (word); word = getchar ()) if (word == ‘-‘) temp = 1; for (now = 0; isdigit (word); now = now * 10 + word - ‘0‘, word = getchar ()); if (temp == 1) now = -now; } int N; std :: vector <int> Flandre; int main (int argc, char *argv[]) { read (N); static char type[10]; register long long Answer; int x, L; for (register int i; N; -- N) { scanf ("%s", type); if (type[0] == ‘a‘) { read (x); Flandre.insert (lower_bound (Flandre.begin (), Flandre.end (), x), x); } else if (type[0] == ‘d‘) { read (x); Flandre.erase (lower_bound (Flandre.begin (), Flandre.end (), x)); } else { L = Flandre.size (); for (i = 2, Answer = 0; i < L; i += 5) Answer += Flandre[i]; printf ("%lld\n", Answer); } } return 0; }
codeforces 85D. Sum of Medians
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。