Codeforces 311C
来源:互联网 发布:外网代理软件 编辑:程序博客网 时间:2024/05/17 04:39
给定n个数字b_j,r个数字a_i
1.判断下面方程是否有整数解
2.r++,增加a_r,r最多为20
#include <cstdio>#include <queue>using namespace std;typedef long long ll;const int N=1e5+5,K=1e4+5;ll h;int n,m,k;ll a[N];int c[N];int len;ll d[K];bool inq[K];int head,tail,q[K];typedef pair<int,int> pr;priority_queue<pr> s;int main(){ #ifdef DouBi freopen("in.cpp","r",stdin); #endif // Dou scanf("%I64d%d%d%d",&h,&n,&m,&k); d[0]=0; for(int u=1;u<k;u++) d[u]=h; for(int i=1;i<=n;i++){ scanf("%I64d%d",&a[i],&c[i]); if((--a[i])%k==0) s.push(pr(c[i],-i)); } while(m--){ int type; scanf("%d",&type); if(type==1){ ll w; scanf("%I64d",&w); head=tail=0; for(int u=0;u<k;u++) if(d[u]!=h) q[tail++]=u,inq[u]=1; while(head!=tail){ int u=q[head]; ++head==K?head=0:0; inq[u]=0; ll t=d[u]+w; int v=t%k; if(t<d[v]){ d[v]=t; if(!inq[v]) q[tail]=v,++tail==K?tail=0:0,inq[v]=1; } } while(!s.empty()) s.pop(); for(int i=1;i<=n;i++) if(a[i]>=d[a[i]%k]&&c[i]) s.push(pr(c[i],-i)); } else if(type==2){ int x,y; scanf("%d%d",&x,&y); c[x]-=y; if(a[x]>=d[a[x]%k]) s.push(pr(c[x],-x)); } else{ while(!s.empty()&&c[-s.top().second]!=s.top().first) s.pop(); if(s.empty()){ puts("0"); continue; } printf("%d\n",s.top().first); c[-s.top().second]=0; s.pop(); } }}
0 0
- Codeforces 311C
- 【Codeforces#311】 div.2 C--E
- CodeForces#311 C. Arthur and Table
- Codeforces Round #311 (Div. 2) C 贪心
- Codeforces-340-C(c++)
- Codeforces-507-C(c++)
- CodeForces 731C C
- CodeForces-612C C
- codeforces #311 C 557C. Arthur and Table(枚举+贪心)
- CODEFORCES 265C CODEFORCES, 265C
- codeforces #78 div2 C
- Codeforces 117C Cycle
- CodeForces 209C
- CodeForces 156C Cipher
- codeforces 148 div2 C
- codeforces 242C
- Codeforces-234C Weather
- codeforces 106C Buns
- TensorFlow实验环境搭建
- win7 mysql的安装和常见问题解决
- SpringMVC笔记系列(1)——用一个例子帮你入门
- jeecg——代码生成器配置
- PHP文件中变量之间的传递
- Codeforces 311C
- 第十四周项目6—二叉排序树中查找的路径
- android 6.0以上系统apk自动安装失败问题
- [2016/12/2]求一个32位二进制数中1的数量
- psi-probe监控apache-tomcat-7.0.73 window版
- Dojo1.11官方教程文档翻译(4.2)数组
- EL表达式
- npm离线安装全局包,内网安装npm中的包
- vCenter Server证书