8VC Venture Cup 2016 - Final Round (Div. 2 Edition) D635 - Factory Repairs 线段树
来源:互联网 发布:网络与手机失泄密 编辑:程序博客网 时间:2024/04/20 17:47
再一次比赛结束写完…sad
感觉这个题目描述很尴尬啊,一开始说机器每天能生产a个东西,但是有些零件坏了每天只能生产b个东西。
但是我并没有看到说只有1个机器,而且一开始是坏的,Pi是修理的日期,看了20~30分钟的题也是无语了….
猜了一下题意,感觉是线段树,等终测结束再交吧SAD
好吧 果然A了 sad
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<math.h>#include<queue>#include<stack>#include<string>#include<vector>#include<map>#include<set>using namespace std;typedef long long LL;#define maxn 200005#define f(x) (x*1.0)#define inf 0x3f3f3f3f#define maxm maxn*maxn#define lowbit(x) (x&(-x))#define cheak(i) printf("%d ",i)#define lson(x) (splay[x].son[0])#define rson(x) (splay[x].son[1])#define rfor(i,a,b) for(i=a;i<=b;++i)#define lfor(i,a,b) for(i=a;i>=b;--i)#define mem(a,b) memset(a,b,sizeof(a))#define mec(a,b) memcpy(a,b,sizeof(b))const double PAI=acos(-1.0);int A[maxn];int tree1[maxn*4];int tree2[maxn*4];int a,b,n;void build(int l,int r,int index){ tree1[index]=0; tree2[index]=0; int mid=(l+r)/2; if(l==r) return ; build(l,mid,index*2); build(mid+1,r,index*2+1);}void Push_up1(int index){ tree1[index]=tree1[index*2]+tree1[index*2+1];}void Push_up2(int index){ tree2[index]=tree2[index*2]+tree2[index*2+1];}void insert(int l,int r,int x,int val,int index){ if(l==r&&l==x) { tree1[index]+=val; tree1[index]=min(tree1[index],a); tree2[index]+=val; tree2[index]=min(tree2[index],b); return ; } int mid=(l+r)/2; if(x>mid) insert(mid+1,r,x,val,index*2+1); else insert(l,mid,x,val,index*2); Push_up1(index); Push_up2(index);}int query(int l,int r,int left,int right,int t,int index){ //printf("**%d %d %d %d %d %d\n",l,r,left,right,t,index); if(left>n||right==0) return 0; if(left<=l&&r<=right) { if(t==1) return tree1[index]; else return tree2[index]; } int mid=(l+r)/2; int ans=0; if(left<=mid) ans+=query(l,mid,left,right,t,index*2); if(right>mid) ans+=query(mid+1,r,left,right,t,index*2+1); return ans;}int main(){ int k,q,i,x,y; scanf("%d%d%d%d%d",&n,&k,&a,&b,&q); build(1,n,1); rfor(i,1,q) { scanf("%d",&x); if(x==1) { scanf("%d%d",&x,&y); insert(1,n,x,y,1); } else { scanf("%d",&x); printf("%d\n",query(1,n,1,x-1,2,1)+query(1,n,x+k,n,1,1)); } } return 0;}
0 0
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) D635 - Factory Repairs 线段树
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)
- cf#8VC Venture Cup 2016 - Final Round (Div. 2 Edition) -A. Orchestra暴力水题
- cf#8VC Venture Cup 2016 - Final Round (Div. 2 Edition)-B. sland Puzzle 水题/hash
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) A. Orchestra
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) B. Island Puzzle
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) C. XOR Equation
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) E. Package Delivery
- Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)
- Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)
- cf#8VC Venture Cup 2016 - Final Round (Div. 2 Edition)-C - XOR Equation-数学/位运算
- 8VC Venture Cup 2016 - Elimination Round题解
- 8VC Venture Cup 2016 - Elimination Round A. Robot Sequence
- Codeforces 8VC Venture Cup 2016 - Elimination Round解题报告
- 8VC Venture Cup 2016 - Elimination Round 总结
- 8VC Venture Cup 2016 - Elimination Round C - Block Towers
- Codeforces 8VC Venture Cup 2016 - Elimination Round
- 8VC Venture Cup 2016 - Elimination Round总结
- Cocoapods系列教程(三)——私有库管理和模块化管理
- mysql
- Zenefits 第一轮编程题
- [leetcode] 253. Meeting Rooms II 解题报告
- 周赛题解报告-2013 亚洲南京区域赛
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) D635 - Factory Repairs 线段树
- transformation action
- hive 结构
- 学习Javascript闭包(Closure)讲的很深入透彻
- DE 27 Sketching Solutions of 2x2 Homogeneous Linear System with Constant Coefficients
- DE28 Matrix Methods for Inhomogeneous Systems
- [leetcode] 49. Group Anagrams 解题报告
- Hive QL
- vector的详细用法---线程安全