Codeforces Round #381 (Div. 2) A. Alyona and flowers
来源:互联网 发布:单片机液晶数字钟论文 编辑:程序博客网 时间:2024/06/08 19:17
http://codeforces.com/problemset/problem/740/B
题意:
给出一组n个数和m条指令,每条指令给出了区间[L,R],对于每天指令,算出第L个数到第R个数的和,最后将所有大于0的和相加得出结果。
代码:
#include <iostream>using namespace std;int arr[20000];int n,m;int main(){ cin>>n>>m; for(int i=0;i<n;i++) { cin>>arr[i]; } int a,b; int sum=0; while(m--) { int ans=0; cin>>a>>b; for(int i=a-1;i<=b-1;i++) { ans+=arr[i]; } if(ans>=0) sum+=ans; } cout<<sum<<endl; return 0;}
0 0
- Codeforces Round #381 (Div. 2) A. Alyona and flowers
- Codeforces Round #381 (Div. 2) B. Alyona and flowers
- Codeforces Round #209 (Div. 2) B. Alyona and flowers
- Codeforces Round #381 (Div. 2) A Alyona and copybooks
- Codeforces Round #381 (Div. 2)D. Alyona and a tree
- Codeforces Round #381 (Div. 2) A.Alyona and copybooks
- Codeforces Round #381 (Div. 2) A. Alyona and copybooks
- Codeforces Round #381 (Div. 2) A. Alyona and copybooks
- Codeforces Round #381 (Div. 2) D. Alyona and a tree
- Codeforces Round #381 (Div. 2) D. Alyona and a tree
- Codeforces Round #381 (Div. 2) B. Alyona and flowers(思维题目)
- Codeforces Round #381 (Div. 2) B. Alyona and flowers(贪心 模拟)
- Codeforces#381(Div. 2) B.Alyona and flowers【思维+暴力】
- Codeforces Round #381 (Div. 1) A. Alyona and mex
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- H264中提取sps和pps
- 网易面试题之小易去附近的商店买苹果,奸诈的商贩使用了捆绑交易,只提供6个每袋和8个每袋的包装(包装不可拆分)。 可是小易现在只想购买恰好n个苹果,小易想购买尽量少的袋数方便携带。如果不能购买恰好n个苹
- 第11篇 防火墙穿越及信令及php表单必需字段
- Xutils3.0框架的初始体验二
- android---- 引入本地aar 包 failed to resolve:xxx
- Codeforces Round #381 (Div. 2) A. Alyona and flowers
- 《Python简易教程》读书笔记
- printk打印级别输出
- 《Linux内核的设计与实现》读书笔记(二)---从内核出发
- java的基本数据类型
- 图片拉伸的处理的三种方式
- Mac RobotFramework 环境安装
- DevExpress.XtraGrid常用设置
- 中国大学MOOC-陈越、何钦铭-数据结构-2016秋期末考试