2022牛客寒假算法基础集训营5(3/11)

G

163小孩

暴力判断或者组合数学求解

AC代码:

18395

I

兔崽小孩

模拟

AC代码:

/*
Tips:
   1.int? long long?
   2.don't submit wrong answer
   3.figure out logic first, then start writing please
   4.know about the range
   5.check if you have to input t or not
   6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define endl '\n'
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long long ll;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
	T res = 1;
	for (; b; b >>= 1, a = a * a) {
		if (b & 1) {
			res = res * a;
		}
	}
	return res;
}
template <typename T>
inline void read(T& x)
{
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - '0', ch = getchar(); }
	x *= f;
}
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}

void solve() {
	int n, q;
	cin >> n >> q;
	vector<int> t(n + 5);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	vector<int> a(n + 5);
	for (int i = 0; i < n - 1; i++) {
		a[i] = t[i + 1] - t[i];
	}
	sort(a.begin(), a.begin() + n - 1);
	vector<long long> s(n);
	s[n - 1] = 0;
	for (int i = n - 2; i >= 0; i--) {
		s[i] = s[i + 1] + a[i];
	}
	for (int i = 0; i < q; i++) {
		int k, p;
		cin >> k >> p;
		int j = lower_bound(a.begin(), a.begin() + n - 1, k) - a.begin();
		long long v = s[j] - 1LL * (n - 1 - j) * k;
		if (v >= p) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return;
}
int main() {
	IOS1;
	//IOS2;
	int __t = 1;
	// cin >> __t;
	for (int _t = 1; _t <= __t; _t++) {
		solve();
	}
	return 0;
}
/*

*/

J

三国小孩

博弈,贪心

AC代码:

/*
Tips:
   1.int? long long?
   2.don't submit wrong answer
   3.figure out logic first, then start writing please
   4.know about the range
   5.check if you have to input t or not
   6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <numeric>
#include <iomanip>
#include <functional>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long long ll;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
	T res = 1;
	for (; b; b >>= 1, a = a * a) {
		if (b & 1) {
			res = res * a;
		}
	}
	return res;
}
template <typename T>
inline void read(T& x)
{
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - '0', ch = getchar(); }
	x *= f;
}
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}
//计算几何
//向量
//struct Point {
//	double x, y;
//	Point operator - (Point a) {//向量加法
//		return { x - a.x,y - a.y };
//	}
//	Point operator + (Point a) {//向量减法
//		return { x + a.x,y + a.y };
//	}
//	double operator * (Point a) {//点乘
//		return x * a.x + y * a.y;
//	}
//	double operator % (Point a) {//叉乘
//		return x * a.y - y * a.x;
//	}
//	bool operator == (Point a) {//两点是否重合
//		return !sgn(x - a.x) && !sgn(y - a.y);
//	}
//	long double len() {//返回向量的模
//		return hypot(x, y);
//	}
//	Point rot(long double arg) {//向量旋转
//		long double Cos = cos(arg), Sin = sin(arg);
//		return { x * Cos - y * Sin,x * Sin + y * Cos };
//	}
//};
//直线 or 射线
//struct Line {
//	Line() {}
//	Line (Point s,Point e): s(s),e(s){}
//	Point s, e;
//};

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	if (n + m > k) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}
int main() {
	IOS1;
	//IOS2;
	int __t = 1;
	//cin >> __t;
	for (int _t = 1; _t <= __t; _t++) {
		solve();
	}
	return 0;
}
/*

*/
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值