买礼物
/*
* @Author: 晚乔最美
* @Date: 2022-11-05 15:03:46
* @Last Modified by: 晚乔最美
* @Last Modified time: 2022-11-05 15:03:46
*/
#include<bits/stdc++.h>
#include<bitset>
#include<unordered_map>
#define pb push_back
#define bp __builtin_popcount
#define TIME cout << "RuningTime: " << clock() << "ms\n", 0
#define ls x<<1
#define rs x<<1|1
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int MOD=9901;
const int mod = 1e9+7;
const double PI=3.14;
int lowbit(int x){return x&-x;}
ll gcd(ll x, ll y){ return y == 0 ? x : gcd(y, x%y); }
ll lcm(ll x, ll y){ return x / gcd(x, y)*y; }
inline ll dpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % MOD; b >>= 1; t = (t*t) % MOD; }return r; }
inline ll fpow(ll a, ll b,ll p){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % p; b >>= 1; t = (t*t) % p; }return r; }
const int maxN = 3e5 + 7;
int N;
ll a[maxN], M;
inline int read()
{
int x = 0,f = 1;
char ch = getchar();
while (ch < '0' || ch>'9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int main()
{
int n, k, p, q, x, y;
x = read();y = read();
n = read();k = read();
q = read();p = read();
int cvr = 21 * 60 - x * 60 - y;
cvr = max(cvr, 0);
double num1 = ceil(1.0 * n / (1.0 * p)) * q;
int ans = n + cvr * k;
double num2 = ceil(1.0 * ans / (1.0 * p)) * q * 0.75;
printf("%.4f", min(num1, num2));
//system("pause");
return 0;
}
/*
21 00
100 1 6 5
90.0000
*/
召唤神龙
/*
* @Author: 晚乔最美
* @Date: 2022-11-04 13:06:46
* @Last Modified by: 晚乔最美
* @Last Modified time: 2022-11-04 13:06:46
*/
#include<bits/stdc++.h>
#include<bitset>
#include<unordered_map>
#define pb push_back
#define bp __builtin_popcount
#define TIME cout << "RuningTime: " << clock() << "ms\n", 0
#define ls x<<1
#define rs x<<1|1
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int MOD=9901;
const int mod = 1e9+7;
const double PI=3.14;
int lowbit(int x){return x&-x;}
ll gcd(ll x, ll y){ return y == 0 ? x : gcd(y, x%y); }
ll lcm(ll x, ll y){ return x / gcd(x, y)*y; }
inline ll dpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % MOD; b >>= 1; t = (t*t) % MOD; }return r; }
inline ll fpow(ll a, ll b,ll p){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % p; b >>= 1; t = (t*t) % p; }return r; }
const int maxN = 3e5 + 7;
int N;
ll a[maxN], M;
inline bool check(ll lim)
{
ll sum = 0;
for(int i=1; i<=N; i++) {
if(a[i]<lim)
{
sum = sum + lim - a[i];
}
}
return sum <=min(lim,M) ;
}
int main()
{
scanf("%d%lld", &N, &M);
ll sum = 0;
for(int i=1; i<=N; i++) { scanf("%lld", &a[i]); sum += a[i]; }
ll L = 0, R = (sum+M)/N, mid, ans = 0;
// cout<<(check(4))<<" "<<endl;
while(L <= R)
{
mid = (L + R) >> 1LL;
if(check(mid))
{
L = mid + 1;
ans = max(ans, mid);
}
else R = mid - 1;
}
printf("%lld\n", ans);
// system("pause");
return 0;
}
大促销
/*
* @Author: 晚乔最美
* @Date: 2022-11-05 15:16:46
* @Last Modified by: 晚乔最美
* @Last Modified time: 2022-11-05 15:16:46
*/
#include<bits/stdc++.h>
#include<bitset>
#include<unordered_map>
#define pb push_back
#define bp __builtin_popcount
#define TIME cout << "RuningTime: " << clock() << "ms\n", 0
#define ls x<<1
#define rs x<<1|1
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int MOD=9901;
const int mod = 1e9+7;
const double PI=3.14;
int lowbit(int x){return x&-x;}
ll gcd(ll x, ll y){ return y == 0 ? x : gcd(y, x%y); }
ll lcm(ll x, ll y){ return x / gcd(x, y)*y; }
inline ll dpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % MOD; b >>= 1; t = (t*t) % MOD; }return r; }
inline ll fpow(ll a, ll b,ll p){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % p; b >>= 1; t = (t*t) % p; }return r; }
inline int read()
{
int x = 0,f = 1;
char ch = getchar();
while (ch < '0' || ch>'9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int main()
{
int n, a, x, y;
x = read();y = read();
a = read();n = read();
printf("%d\n", n % (x + y) >= x ? n / (x + y) * (a * x) + x * a : n / (x + y) * (a * x) + n % (x + y) * a);
//system("pause");
return 0;
}
/*
2 1 2 10
14
*/
轨道探测
/*
* @Author: 晚乔最美
* @Date: 2022-11-05 17:10:46
* @Last Modified by: 晚乔最美
* @Last Modified time: 2022-11-05 17:15:46
*/
#include<bits/stdc++.h>
#include<bitset>
#include<unordered_map>
#define pb push_back
#define bp __builtin_popcount
#define TIME cout << "RuningTime: " << clock() << "ms\n", 0
#define ls x<<1
#define rs x<<1|1
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=3e4+10;
const int MOD=9901;
const int mod = 1e9+7;
const double PI=3.14;
int lowbit(int x){return x&-x;}
ll gcd(ll x, ll y){ return y == 0 ? x : gcd(y, x%y); }
ll lcm(ll x, ll y){ return x / gcd(x, y)*y; }
inline ll dpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % MOD; b >>= 1; t = (t*t) % MOD; }return r; }
inline ll fpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t); b >>= 1; t = (t*t); }return r; }
struct node{
int x, y, r;
} a[4];
bool cmp(node p,node q)
{
return p.r < q.r;
}
int main()
{
for (int i = 1; i <= 3;i++)
cin >> a[i].x >> a[i].y >> a[i].r;
sort(a + 1, a + 1 + 3, cmp);
int flag = 0;
if(a[2].x-a[2].r==a[3].x-a[3].r&&a[1].x+a[1].r==a[3].x+a[3].r&&a[2].x+a[2].r==a[1].x-a[1].r)
flag = 1;
if(a[1].x-a[1].r==a[3].x-a[3].r&&a[2].x+a[2].r==a[3].x+a[3].r&&a[1].x+a[1].r==a[2].x-a[2].r)
flag = 1;
if(a[2].y-a[2].r==a[3].y-a[3].r&&a[1].y+a[1].r==a[3].y+a[3].r&&a[2].y+a[2].r==a[1].y-a[1].r)
flag = 1;
if(a[1].y-a[1].r==a[3].y-a[3].r&&a[2].y+a[2].r==a[3].y+a[3].r&&a[1].y+a[1].r==a[2].y-a[2].r)
flag = 1;
if(flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
//system("pause");
return 0;
}
/*
3 3 2 2 3 1 4 3 1
YES
2 2 3 3 2 2 4 2 1
NO
*/
本文分享了算法竞赛中实用的编程技巧,包括快速读入、二分查找等,并通过具体题目展示了如何运用这些技巧解决问题。
&spm=1001.2101.3001.5002&articleId=127706117&d=1&t=3&u=7cdf0829c95e43e6b56e8ce6e26a9f9c)
699

被折叠的 条评论
为什么被折叠?



