蓝桥算法训练营—普及组—2023年2.5日

Kingcarry6 Kingcarry6 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

标题 蓝桥算法训练营—普及组—2023年2.5日

目录

标题 蓝桥算法训练营—普及组—2023年2.5日

P1372 又是毕业季I

P1106 删数问题

谈判


https://www.luogu.com.cn/problem/P2694

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <string>
#include <cstring>

#define x first
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef long long LL;
typedef unsigned long long ULL;

const int N= 1e4 + 10 , INF = 1e9 ;

int n;

PII q[N];

bool cmp(PII a,PII b)
{
    return a.y < b.y;    
}

void solve()
{
    cin>>n;
    for(int i=0;i<n;i ++ )
    {
        cin>>q[i].x>>q[i].y;
    }
    sort(q,q+n,cmp);
    LL t =0,cnt=0;bool flag=0;
    for(int i=0;i <n ;i ++ )
    {
        if(abs(t-q[i].x) > q[i].y - cnt) 
        {
            flag =1 ;break;
        }
        cnt=q[i].y;
        t = q[i].x;
    }
    
    if(flag ) puts("Notabletocatch");
    else puts("Abletocatch");
    
}


int main()
{
    ios 
    int T;cin>>T;
    while(T -- )
    {
        solve();
    }    
    
    
    
    
    return 0;
}

P1372 又是毕业季I

https://www.luogu.com.cn/problem/P1372

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <string>
#include <cstring>

#define x first
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef long long LL;
typedef unsigned long long ULL;

const int N= 1e4 + 10 , INF = 1e9 ;


int n,m;
PII q[N];



void solve()
{
	cin>>n>>m;
	cout<<n  /m <<endl;	
	
		
}


int main()
{
	ios 
	int T=1;
//	cin>>T;
	while(T -- )
	{
		solve();
	}	
	
	
	
	
	return 0;
}


P1106 删数问题

https://www.luogu.com.cn/problem/P1106

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <string>
#include <cstring>

#define x first
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef long long LL;
typedef unsigned long long ULL;

const int N= 1e4 + 10 , INF = 1e9 ;


int n,m;
PII q[N];



void solve()
{
	string s;cin>>s>>n;
	while(n -- )
	{
		bool flag =0;
		for(int i=0;i < s.size() -1 ;i ++ )
		{
			if(s[i] > s[i + 1]) 
			{
				flag =1;
				s = s.substr(0,i) + s.substr(i+1);
				// 删掉 第 i 个数  
				break;
			}
		}
		if(!flag) // 没有找到 要删的 数 说明 这个从前往后 是 递增的  
		s = s.substr(0,s.size()-1) ; // 否则删掉 最后一个 数 
	}	
	
	int i=0;
	while(i < s.size()  && s[i] == '0') i ++ ;
	if(i == s.size()) cout<<0 << endl;
	else 
	{
		for(int j =i;j <s.size() ; j++)cout<<s[j];		
	}
}


int main()
{
	ios 
	int T=1;
//	cin>>T;
	while(T -- )
	{
		solve();
	}	
	
	
	
	
	return 0;
}


谈判

https://www.lanqiao.cn/problems/545/learning/

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <string>
#include <cstring>

#define x first
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef long long LL;
typedef unsigned long long ULL;

const int N= 1e4 + 10 , INF = 1e9 ;


int n,m;

priority_queue<int,vector<int>,greater<int>> q;

void solve()
{
    cin>>n;
    for(int i=0; i< n ;i ++ )
    {
        int t;cin>>t;
        q.push(t);
    }
    LL res=0;
    while(q.size() > 1)
    {
        auto x = q.top(); q.pop();
        auto y = q.top();q.pop();
        res += (LL)x+y;
        q.push(x +y);
    }
    cout << res << endl;
}


int main()
{
    ios 
    int T=1;
//    cin>>T;
    while(T -- )
    {
        solve();
    }    
    
    
    
    
    return 0;
}

 

...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部