零点工作室暑假集训(Codeforces Round 886 (Div. 4))

A. To My Critics

题意:给定3个整数x, y和z,问他们的之中任意两个数的和可能大于等于10吗

思路:直接找最大和次大的数即可,若不大于等于10则输出No

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 200010, INF = 0x3f3f3f3f, Mod = 998244353;

int a, b, c;

void solved()
{
    cin >> a >> b >> c;
    if(a + b >= 10 || a + c >= 10 || b + c >= 10) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //int t = 1;
    int t;
    cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

B. Ten Words of Wisdom

题意: 在这里插入图片描述

思路:在所有的ai <= 10的人里面,找到bi最大的,输出编号i即可

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 200010, INF = 0x3f3f3f3f, Mod = 998244353;

struct res 
{
    int a;
    int b;
};

void solved()
{
    
        int n;
        cin >> n;
        
        vector<res> v(n);
        for (int i = 0; i < n; i ++) 
        {
            cin >> v[i].a >> v[i].b;
        }
        
        int flag = 0;
        int ans = -1;
        for (int i = 0; i < n; i ++) 
        {
            if (v[i].a <= 10 && v[i].b > flag) 
            {
                flag = v[i].b;
                ans = i + 1;
            }
        }
        
        cout << ans << endl;

    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //int t = 1;
    int t;
    cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

C. Word on the Paper

题意: 给定8行8列字符,某一列中存在连续一段字母,按顺序输出这一段字母。

思路: 直接模拟即可

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 1010, INF = 0x3f3f3f3f, Mod = 998244353;

char s[N][N];

void solved()
{
    for(int i = 1; i <= 8; i ++)
    {
        for(int j = 1; j <= 8; j ++)
        {
            cin >> s[i][j];
        }
    }
    
    for(int i = 1; i <= 8; i ++)
    {
        for(int j = 1; j <= 8; j ++)
        {
            if(s[i][j] != '.') cout << s[i][j];
        }
    }
    
    cout << endl;

    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //int t = 1;
    int t;
    cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

D. Balanced Round

题意:
在这里插入图片描述

思路:循环找到连续的子序列,当不满足条件时与前一个比较大小,大的留下,然后继续循环找最大子序列

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 200010, INF = 0x3f3f3f3f, Mod = 998244353;

int n, k;
int v[N];

void solved()
{
    cin >> n >> k;
    
    //vector<int> v(n);
    for(LL i = 1; i <= n; i ++)
    {
        cin >> v[i];
    }
    
    //sort(v.begin() + 1, v.end() + 1);
    sort(v + 1, v + 1 + n);
    
    
    int max1 = 1;
    int max2 = 0;
    for(int i = 2; i <= n; i ++)
    {
        if(v[i] - v [i - 1] <= k) max1 ++;
        else 
        {
            max2 = max(max2, max1);
            max1 = 1;
        }
    }
    
    int res = max(max1, max2);
    
    cout << n - res << endl;
    
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //int t = 1;
    int t;
    cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

E. Cardboard for Pictures

题意:
在这里插入图片描述

思路: 本体采用了二分法,因为w具有二分的性质,为了防止越界,在每次检查其合法性时,当sum > c 时,跳出循环即可

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 200010, INF = 0x3f3f3f3f, Mod = 998244353;

LL n , m;
LL a[N];

bool check(LL x)
{
	LL res = 0;
	for(int i = 0 ; i < n ; i ++ )
	{
		if((__int128)((a[i] + 2 * x) * (a[i] + 2 * x) + res) >= m) return true;//开__int128,此处数据太大LL都会爆
		else res += (a[i] + 2 * x) * (a[i] + 2 * x);
	}
	return res >= m;
}

void solved()
{
	cin >> n >> m;
	
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i];
	
	LL l = 0 , r = 1e9;
	while(l < r)
	{
		LL mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	
	cout << l << endl;
    
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //int T = 1;
    int T;
    cin >> T;
 
    while(T -- )
    {
        solved();
    }
 
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值