十天集训补题——第二天

今天只写了一题签到。。

我补!

H题

CodeForces - 750C(思维)_codeforces查看等级分-CSDN博客

这题不难的呀        就是一开始想错方向了就会一直困在那里,我经常这样        就是一个方法错了不太有勇气去想一个新方法, 只是固执的认为自己有点小错误,继续细化这个代码 后来代码就会

变得很长。。而且很有可能自己都看不懂了。。下次尝试开新路。

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int inf=0x3f3f3f3f;
int c,d;
int d1=-inf,d2=inf;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int t,n,sum=0,x=2e7+10;
	cin>>t;
	n=t;
for(int i=1;i<=n;i++)

{
			cin>>c>>d;
	
		if(d==1)
		{
			d1=max(d1,1900-sum);	
		}
		else if(d==2)
		{
			d2=min(d2,1899-sum);	
		}
		sum+=c;
}
	if(d1>d2)
	  cout<<"Impossible"<<endl;
    else if(d2==inf)
        cout<<"Infinity"<<endl;
    else
        cout<<d2+sum<<endl;
	return 0; 
 } 



  


D题

我这么一看才发现自己当时题目理解错掉了。。

Sum of Two Numbers (CodeForces - 1788B )-CSDN博客

把数字看成字符串。

#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	while(n--)
	{
		string a;
		cin>>a;
		int sum=0;
		for(auto i:a){
			sum+=i-'0';
		}
		int mid=sum/2;
		string minstr;
		for(int i=a.length()-1;i>=0;i--){
			if(mid>a[i]-'0'){
				mid-=a[i]-'0';
				minstr+=a[i];
				a[i]='0';
			}else{
				minstr+=mid+'0';
				a[i]-=mid;
				mid-=mid;
			}
			if(mid==0){
				break;
			}
		}	
		reverse(minstr.begin(),minstr.end());
		cout<<a<<" "<<minstr<<endl;
	}
	return 0;
} 

其他的打标签

A题

 dfs序 没听说过 有空看看 LCA

CodeForces 1328E

CodeForces - 1328 E. Tree Queries 最近公共祖先lca_1328e - tree queries-CSDN博客

codeforces 1328E Tree Queries 思维 dfs序 LCA_codeforces1328e-CSDN博客

dfs序(树形结构线性化)_dfs序列-CSDN博客

E题

线段树 区间异或+区间和

Codeforces 242E-XOR on Segment (线段树 + 区间异或修改、求和)_线段树区间异或-CSDN博客

怎么又是线段树!

【总结】线段树_线段树难度-CSDN博客

线段树 从入门到进阶(超清晰,简单易懂)_进阶线段树-CSDN博客

F题

DP        可以看看

Codeforces 1221D Make The Fence great again 动态规划DP题解_你有一个由 n 块竖板组成的篱笆。每块板的宽度为 1。第 i 块板的高度为 ai。如果-CSDN博客

Codeforces1221 D. Make The Fence Great Again(DP)_p - make the fence great again(dp)-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值