Sereja and Array-数组操作或者线段树或树状数组
CodeForces - 315B
Description Sereja has got an array, consisting of n integers, a1, a2, ..., an.
Help Sereja, complete all his operations. Input The first line contains integers n, m(1 ≤ n, m ≤ 105). Next m lines describe operations, the i-th line describes the i-th operation. Output For each third type operation print value aqi. Print the values in the order, in which the corresponding queries Sample Input
Input
10 11
Output
2 这道题目大家须要思考,不要一看到题目就用线段树,要想想有没有更好的方法,这里的题目给出的三种操作 能够知道没有一个是对区间进行操作的,唯一一个都是对整个数组操作。对全部的数的影响一样。 所以代码便能够变为例如以下: /* |
Sereja and Array-数组操作或者线段树或树状数组的更多相关文章
- HDU 1394 线段树or 树状数组~
Minimum Inversion Number Description The inversion number of a given number sequence a1, a2, ..., an ...
- 2019牛客暑期多校训练营(第七场)F-Energy stones(思维+树状数组)
>传送门< 题意:有n块能量石,每秒钟会增加Li的能量,但是一旦增长到了Ci它就不会增长了,它初始的能量为Ei. 现在有若干个时刻ti,会选择下标在[Si,Ti]的能量石吸取它们的能量,这 ...
- 【BZOJ-3790】神奇项链 Manacher + 树状数组(奇葩) + DP
3790: 神奇项链 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 304 Solved: 150[Submit][Status][Discuss] ...
- php 数组操作类(整合 给意见)
数组操作函数整理: /* 将一个二维数组按照指定字段的值分组 * * @param array $arr * @param string $keyField * * @return array */ ...
- js之数组操作
js之数组操作 前言 本文主要从应用来讲数组api的一些操作,如一行代码扁平化n维数组.数组去重.求数组最大值.数组求和.排序.对象和数组的转化等.(文章摘自:https://segmentfault ...
- 牛客小白月赛12 F 华华开始学信息学 (分块+树状数组)
链接:https://ac.nowcoder.com/acm/contest/392/F来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 32768K,其他语言65536K ...
- BZOJ2120:数颜色(数状数组套主席树)(带修改的莫对)
墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会像你发布如下指令: 1. Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画笔. 2. R P ...
- HDU3333 Turing Tree 树状数组+离线处理
Turing Tree Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- PHP数组操作汇总
php 操作数组 (合并,拆分,追加,查找,删除等) - Just Code - ITeye技术网站 PHP操作数组的一些函数介绍 -- 简明现代魔法 PHP数组元素操作实例 -- 简明现代魔法 儿童 ...
随机推荐
- 指定某个git的版本代码拉取新的分支
在本地找到一个目录,执行 git clone http://gitlab.xxxxx.com/xxxxx/xxxxx.git cd xxxxx/ git log //找到对应版本的SHA值 例如2b1 ...
- CentOS7重新生成 /boot/grub2/grub.cfg
CentOS7重新生成 /boot/grub2/grub.cfg CentOS7 is using grub2 and the generated /boot/grub2/grub.cfg rathe ...
- Gym 100989F 水&愚&vector
standard input/output You must have heard about Agent Mahone! Dr. Ibrahim hired him to catch the che ...
- html5拖动文件上传
使用html5的fileReader api <!DOCTYPE html><html lang="en"><head> <meta ch ...
- JavaScript 的新特性:类的 #private 字段
这是什么,如何使用,为什么需要? 一边听“Noise Pollution” —— Portugal. The Man,一边阅读本文简直就是享受 JavaScript 标准的第二阶段(Stage 2)加 ...
- ext4向后兼容代码
ext.h: #define EXT4_GOOD_OLD_INODE_SIZE 128 ... #define EXT4_GOOD_OLD_REV 0 /* The good old (origina ...
- spring整合jedis时所遇问题
@Test public void testSpringJedisPool(){ ApplicationContext ac = new ClassPathXmlApplicationContext( ...
- 解决IE6的PNG透明
http://www.jb51.net/article/35669.htm http://blog.csdn.net/mosliang/article/details/6760028
- LeetCode OJ-- Reverse Words in a String
https://oj.leetcode.com/problems/reverse-words-in-a-string/ 给一个字符串 abc dd m,返回 m dd abc. 注意:输入中可能有 ...
- webview reload 错误 Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted"
在某个特定的场合先需要对WKWebView进行一次reload,但是直接回走到失败的代理方法中并报如下的错误 Error Domain=WebKitErrorDomain Code=102 " ...