3
19
2016
1

Diary of March 19th&20th

UPD Mar.19th 7:22 今天模拟赛也一样求保佑。。(我的RP是不是要用光了)
UPD Mar.20th 心好累……还是爆蛋了 RP真用光了 省选要炸了
今天做点水题算了

先把最初的答案求出来,然后前缀和后缀和搞一搞就好了
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#define Rep(x,a,b) for (int x=a;x<=b;x++)
#define Drp(x,a,b) for (int x=a;x>=b;x--)
#define Cross(x,a) for (int x=head[a];~x;x=next[x])
#define ll long long
#define oo (1<<29)
#define mk(a,b) make_pair(a,b)
#define fr first
#define sc second
using namespace std;
inline ll IN(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void OUT(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) OUT(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
const int N=500005;
int n,a[N];
char s[N];
ll pre[N],suf[N],Sum;
int main(){
	n=IN();
	Rep(i,1,n) a[i]=IN();
	scanf("%s",s+1);
	pre[0]=0,Sum=0;
	Rep(i,1,n){
		if (s[i]=='A') pre[i]=pre[i-1]+a[i];
			else pre[i]=pre[i-1]-a[i],Sum+=a[i];
	}
	suf[n+1]=0;
	Drp(i,n,1){
		if (s[i]=='A') suf[i]=suf[i+1]+a[i];
			else suf[i]=suf[i+1]-a[i];
	}
	ll Ans=0;
	Rep(i,1,n) Ans=max(Ans,max(pre[i],suf[i]));
	OUT(Ans+Sum);
} 
先放照题目要求贪心从前往后放奇数,再把偶数都塞到空格里去
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#define Rep(x,a,b) for (int x=a;x<=b;x++)
#define Drp(x,a,b) for (int x=a;x>=b;x--)
#define Cross(x,a) for (int x=head[a];~x;x=next[x])
#define ll long long
#define oo (1<<29)
#define mk(a,b) make_pair(a,b)
#define fr first
#define sc second
using namespace std;
inline ll IN(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void OUT(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) OUT(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
int nx,ny,n,a,b;
int Ans[105][105];
int main(){
	n=IN(),a=IN(),b=IN();
	nx=1,ny=1;
	for (int i=1;i<=n;i+=2){
		while (nx<=a&&(Ans[nx][ny]||Ans[nx-1][ny]||Ans[nx][ny-1])){
			ny++;if (ny==b+1) ny=1,nx++;
		}
		if (nx<=a) Ans[nx][ny]=i;else return puts("-1"),0;
	}
	nx=1,ny=1;
	for (int i=2;i<=n;i+=2){
		while (Ans[nx][ny]){
			ny++;if (ny==b+1) ny=1,nx++;
		}
		if (nx<=a) Ans[nx][ny]=i;else return puts("-1"),0;
	}
	Rep(i,1,a){
		Rep(j,1,b) OUT(Ans[i][j]),putchar(' ');
		puts("");
	}
}
照题目说的模拟就可以了 注意开LL
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#define Rep(x,a,b) for (int x=a;x<=b;x++)
#define Drp(x,a,b) for (int x=a;x>=b;x--)
#define Cross(x,a) for (int x=head[a];~x;x=next[x])
#define ll long long
#define oo (1<<29)
#define mk(a,b) make_pair(a,b)
#define fr first
#define sc second
using namespace std;
inline ll IN(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void OUT(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) OUT(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
const int N=200005;
int H,T,n,b;
ll Lst,Ans[N];
int t[N],d[N],q[N];
int main(){
	n=IN(),b=IN();
	Lst=0,H=1,T=0;
	Rep(i,1,n){
		t[i]=IN(),d[i]=IN();
		while (H<=T){
			Lst=max(Lst,(ll)t[q[H]]);
			if (Lst+d[q[H]]<=t[i]){
				Lst+=d[q[H]],Ans[q[H++]]=Lst;
			}else break;
		}
		if (T-H<b) q[++T]=i;else Ans[i]=-1;
	}
	while (H<=T){
		Lst=max(Lst,(ll)t[q[H]]);
		Lst+=d[q[H]],Ans[q[H++]]=Lst;
	}
	Rep(i,1,n) OUT(Ans[i]),putchar(' ');
}
Category: Diary | Tags: 模拟 贪心 SB题 | Read Count: 515
Assam HSLC English M 说:
Sep 30, 2022 01:46:15 AM

Board of Secondary Education, Assam is known as SEBA is conducted the English subject examination tests along with all examination tests for all government and private schools General curriculum and vocational course students as Unit Tests, Term, three months (Quarterly), Assam HSLC English Model Paper six months (Half Yearly), Pre-Final and annual final public examination tests to the academic year of 2023.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com