G
暴力判断或者组合数学求解
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; } /* */
2022牛客寒假算法基础集训营5(3/11)
于 2022-02-15 14:53:02 首次发布