• 2022/9/14(cf·div3)https://codeforces.com/contest/1729


    https://codeforces.com/contest/1729/problem/A
    //暴力算,稍微注意一下b和c的位置关系

    #include
    using namespace std;
    #define int long long
    //int b[200005];
    
    signed main()
    {
    	int tt;
    	cin>>tt;
    	while(tt--)
    	{
    		int a,b,c;
    		cin>>a>>b>>c;
    		int x=a-1;
    		int y;
    		if(c>b)y=abs(c-b)+c-1;
    		else y=b-1;
    		if(x>y)puts("2");
    		else if(x==y)puts("3");
    		else puts("1");
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    https://codeforces.com/contest/1729/problem/B
    //从最后一位开始,遇0则需要往前统计两位,否则直接记录,用栈储存。
    //输出可以处理得灵活些,输出st.top()+‘a’-1;

    #include
    using namespace std;
    #define int long long
    //int b[200005];
    
    signed main()
    {
    	int tt;
    	cin>>tt;
    	//char ch[27]={'0','a','b','c','d','e',};
    	while(tt--)
    	{
    		int n;
    		string s;
    		cin>>n>>s;
    		stack<int>st;
    		for(int i=s.size()-1;i>=0;i--)
    		{
    			if(s[i]=='0')
    			{
    				int j=1,res=0;
    				while(j<=10)
    				{
    					res+=(s[--i]-'0')*j;
    					j*=10;
    				}
    				st.push(res);
    			}
    			else st.push(s[i]-'0');
    		}
    		while(st.empty()==0)
    		{
    			char ch=st.top()+'a'-1;
    			st.pop();
    			cout<<ch;
    		}
    		puts("");
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39

    https://codeforces.com/contest/1729/problem/C
    //有两个需要注意的点:
    //第一,要满足第一个条件花费最少,那肯定是从第一个字母走到最后个字母,所以,会经过这两个之间得字母,且走过了就不能回头。
    //第二,注意第一个字母和最后一个字母得大小问题。要么排两次序,要么向我这样排一次序,输出的时候注意一下,1是第一个输出,最后一个输出的数字与长度大小等大。
    //还没学毛爷的做法,他的不用排序

    #include
    using namespace std;
    #define int long long
    struct node
    {
    	char ch;
    	int id;
    }t[200005];
    
    bool cmp(node z1,node z2)
    {
    	if(z1.ch==z2.ch)
    		return z1.id<z2.id;
    	return z1.ch<z2.ch;
    }
    signed main()
    {
    	int tt;
    	cin>>tt;
    	while(tt--)
    	{	
    		string s;
    		int p=0;
    		cin>>s;
    		char x=s[0],y=s[s.size()-1];
    		if(x>y)swap(x,y),p=1;
    		
    		int ans=0,j=0;
    		for(int i=0;i<s.size();i++)
    		{
    			if(s[i]>=x&&s[i]<=y)
    			{
    				ans++;
    				t[j].ch=s[i];
    				t[j++].id=i+1;
    			}
    		}
    		sort(t,t+j,cmp);
    		cout<<y-x<<" "<<ans<<'\n';
    		if(p==0)
    			for(int i=0;i<j;i++)
    				cout<<t[i].id<<" ";
    		else 
    		{
    			cout<<1<<" ";
    			for(int i=j-1;i>=0;i--)
    			{
    				if(t[i].id==1)cout<<"";
    				else if(t[i].id==s.size())cout<<"";
    				else cout<<t[i].id<<" ";
    			}
    			cout<<s.size();
    		}
    		puts("");
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56

    https://codeforces.com/contest/1729/problem/D
    //害,这个题没写出来,属实是自己多管闲事了
    //2个人是一组,3个人也是一组,找能凑出两个人的组就行,还管其他的人干啥

    #include
    using namespace std;
    #define int long long
    int b[200005];
    struct node
    {
    	int a,c;
    }t[200005];
    
    signed main()
    {
    	int tt;
    	cin>>tt;
    	while(tt--)
    	{
    		int n;
    		cin>>n;
    		for(int i=0;i<n;i++)
    			cin>>t[i].a;
    		for(int i=0;i<n;i++)
    		{
    			cin>>t[i].c;
    			b[i]=t[i].c-t[i].a;
    		}
    		sort(b,b+n,greater<int>());//注意大的在前,要不然,麻烦,最小的可能找不到可以和他一起填平的数(他不能去吃饭)
    		int cnt=0;
    		int j=n-1;
    		for(int i=0;i<n;i++)
    		{
    			while(i<j&&(b[i]+b[j])<0)j--;//找到预算够能一起吃饭的人
    			if(i<j)
    				cnt++,j--;
    			else break;
    		}
    		cout<<cnt<<'\n';
    	}
    }
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
  • 相关阅读:
    element ui修改select选择框背景色和边框色
    【蓝桥杯省赛真题14】python围圈报数 青少年组蓝桥杯python编程省赛真题解析
    代码随想录——图论一刷day05
    ICommand命令 mvvm模式事件
    成为一个优秀的测试工程师需要具备哪些知识和经验?
    盛唐诗人三杰,儒释道的代表
    Python中定义Mittag-Leffler函数
    SQL Server基础指令(创建与检索)
    Sylar_网络框架学习——日志系统(一)
    vue2中组件间通讯
  • 原文地址:https://blog.csdn.net/m0_66433418/article/details/126859004