博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2019东北四省B,G,H,J 2018宁夏 A,F
阅读量:6280 次
发布时间:2019-06-22

本文共 5901 字,大约阅读时间需要 19 分钟。

B. Balanced Diet

#include
#define il inline#define pb push_back#define fi first#define se second#define ms(_data,v) memset(_data,v,sizeof(_data))#define sc(n) scanf("%d",&n)#define SC(n,m) scanf("%d %d",&n,&m)#define SZ(a) int((a).size())#define rep(i,a,b) for(int i=a;i<=b;++i)#define drep(i,a,b) for(int i=a;i>=b;--i)using namespace std;typedef long long ll;const ll inf=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-9;const int maxn=1e5+5;int T,n,m,l[maxn];vector
v[maxn],f[maxn];bool cmp(int x,int y) {return x>y;}int main(){ std::ios::sync_with_stdio(0); cin>>T; while(T--){ cin>>n>>m; rep(i,1,m) cin>>l[i]; int val,op; rep(i,1,n){ cin>>val>>op; v[op].pb(val); } rep(i,1,m){ sort(v[i].begin(),v[i].end(),cmp); rep(j,0,SZ(v[i])-1) f[max((j+1),l[i])].pb(v[i][j]); v[i].clear(); } ll as=0,ac=1,ns=0,nc; rep(i,1,n){ nc=i; rep(j,0,SZ(f[i])-1) ns+=f[i][j]; if(ns*ac > nc*as) as=ns,ac=nc; f[i].clear(); } ll tp=__gcd(ac,as); cout<

G. Radar Scanner

#include
#define il inline#define pb push_back#define fi first#define se second#define ms(_data,v) memset(_data,v,sizeof(_data))#define sc(n) scanf("%d",&n)#define SC(n,m) scanf("%d %d",&n,&m)#define SZ(a) int((a).size())#define rep(i,a,b) for(int i=a;i<=b;++i)#define drep(i,a,b) for(int i=a;i>=b;--i)using namespace std;typedef long long ll;const ll inf=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-9;const int maxn=1e6+5;struct node{ int x1,y1,x2,y2;}a[maxn];int T,n;vector
tx,ty;int main(){ std::ios::sync_with_stdio(0); cin>>T; while(T--){ tx.clear(),ty.clear(); cin>>n; rep(i,1,n){ cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2; tx.pb(a[i].x1),tx.pb(a[i].x2); ty.pb(a[i].y1),ty.pb(a[i].y2); } sort(tx.begin(),tx.end()); sort(ty.begin(),ty.end()); int sx=SZ(tx),sy=SZ(ty); int midx=(tx[sx/2]+tx[sx/2-1])/2; int midy=(ty[sy/2]+ty[sy/2-1])/2; ll ans=0; rep(i,1,n){ ans+=(abs(midx-a[i].x1)+abs(midx-a[i].x2)-(a[i].x2-a[i].x1))/2; ans+=(abs(midy-a[i].y1)+abs(midy-a[i].y2)-(a[i].y2-a[i].y1))/2; } cout<
<

H. Skyscraper

#include
#define il inline#define pb push_back#define fi first#define se second#define ms(_data,v) memset(_data,v,sizeof(_data))#define sc(n) scanf("%d",&n)#define SC(n,m) scanf("%d %d",&n,&m)#define SZ(a) int((a).size())#define rep(i,a,b) for(int i=a;i<=b;++i)#define drep(i,a,b) for(int i=a;i>=b;--i)using namespace std;typedef long long ll;const ll inf=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-9;const int maxn=1e6+6;ll T,n,m,a[maxn],b[maxn];struct tr { ll sum[maxn]; void add(int p,int x) { while(p<=n+2) sum[p]+=x,p+=p&-p; } ll ask(int p) { ll res=0; while(p) res+=sum[p],p-=p&-p; return res; } ll r_ask(int l,int r) { return ask(r)-ask(l-1); }} tb,tc;int main() { std::ios::sync_with_stdio(0); cin>>T; while(T--) { cin>>n>>m; rep(i,1,n) { cin>>a[i]; if(i>=2) { b[i]=a[i]-a[i-1]; tb.add(i,b[i]); if(b[i]>0) tc.add(i,b[i]); } else { b[i]=a[i]; tb.add(i,a[i]); tc.add(i,a[i]); } } int op,l,r,x; rep(i,1,m) { cin>>op; if(op==1) { cin>>l>>r>>x; tb.add(l,x),tb.add(r+1,-x); if(b[l]>0) tc.add(l,x); else if(b[l]+x>0) tc.add(l,b[l]+x); if(b[r+1]>0) { if(b[r+1]-x>0) tc.add(r+1,-x); else tc.add(r+1,-b[r+1]); } b[l]+=x,b[r+1]-=x; } else { cin>>l>>r; cout<
<

J. Time Limit

#include
#define il inline#define pb push_back#define fi first#define se second#define ms(_data,v) memset(_data,v,sizeof(_data))#define sc(n) scanf("%d",&n)#define SC(n,m) scanf("%d %d",&n,&m)#define SZ(a) int((a).size())#define rep(i,a,b) for(int i=a;i<=b;++i)#define drep(i,a,b) for(int i=a;i>=b;--i)using namespace std;typedef long long ll;const ll inf=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-9;int T,n;int main(){ std::ios::sync_with_stdio(0); cin>>T; while(T--){ cin>>n; int ans=0,x; rep(i,1,n){ cin>>x; if(i==1) ans=3*x; else ans=max(ans,x+1); } if(ans&1) cout<
<

  

 

A. Maximum Element In A Stack

#include
#define il inline#define pb push_back#define fi first#define se second#define ms(_data,v) memset(_data,v,sizeof(_data))#define sc(n) scanf("%d",&n)#define SC(n,m) scanf("%d %d",&n,&m)#define SZ(a) int((a).size())#define rep(i,a,b) for(int i=a;i<=b;++i)#define drep(i,a,b) for(int i=a;i>=b;--i)using namespace std;typedef long long ll;int n,p,q,m;unsigned int SA,SB,SC;stack
s;void PUSH(long long x){ if(s.empty())s.push(x); else s.push(max(x,s.top()));}void POP(){ if(!s.empty()) s.pop();}unsigned int rng61(){ SA ^= SA << 16; SA ^= SA >> 5; SA ^= SA << 1; unsigned int t = SA; SA = SB; SB = SC; SC ^= t ^ SA; return SC;}int main(){ int T; scanf("%d",&T); for(int t = 1;t <= T;t++){ while(!s.empty())s.pop(); long long ans = 0; scanf("%d%d%d%d%u%u%u",&n,&p,&q,&m,&SA,&SB,&SC); for(int i = 1;i <= n;i++){ if(rng61() % (p + q) < p) PUSH(rng61() % m + 1); else POP(); if(!s.empty()) ans^=(i*s.top()); } printf("Case #%d: %lld\n",t,ans); } return 0;}

F.Moving On

#include
#define il inline#define pb push_back#define fi first#define se second#define ms(_data,v) memset(_data,v,sizeof(_data))#define sc(n) scanf("%d",&n)#define SC(n,m) scanf("%d %d",&n,&m)#define SZ(a) int((a).size())#define rep(i,a,b) for(int i=a;i<=b;++i)#define drep(i,a,b) for(int i=a;i>=b;--i)using namespace std;typedef long long ll;const ll inf=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-9;const int maxn=205;int T,dis[maxn][maxn],ans[20005],n,q;struct node { int id,w;} a[maxn];struct Qu { int id,u,v,w;} qu[20005];bool Qcmp(Qu x,Qu y) { return x.w

 

转载于:https://www.cnblogs.com/hxn-tj-cy/p/10952207.html

你可能感兴趣的文章
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
查看>>
<转>云主机配置OpenStack使用spice的方法
查看>>
java jvm GC 各个区内存参数设置
查看>>
[使用帮助] PHPCMS V9内容模块PC标签调用说明
查看>>
关于FreeBSD的CVSROOT的配置
查看>>
基于RBAC权限管理
查看>>
基于Internet的软件工程策略
查看>>
数学公式的英语读法
查看>>
留德十年
查看>>
迷人的卡耐基说话术
查看>>
PHP导出table为xls出现乱码解决方法
查看>>
PHP问题 —— 丢失SESSION
查看>>
Java中Object类的equals()和hashCode()方法深入解析
查看>>
数据库
查看>>
Vue------第二天(计算属性、侦听器、绑定Class、绑定Style)
查看>>
dojo.mixin(混合进)、dojo.extend、dojo.declare
查看>>
Python 数据类型
查看>>
iOS--环信集成并修改头像和昵称(需要自己的服务器)
查看>>
PHP版微信权限验证配置,音频文件下载,FFmpeg转码,上传OSS和删除转存服务器本地文件...
查看>>
教程前言 - 回归宣言
查看>>