A.ACM中的A题
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull = unsigned long long
void solve() {
ll a,b,c;
cin>>a>>b>>c;
a*=2;
if(a+b>c&&a+c>b&&b+c>a)
{
cout<<"Yes";
return;
}
a/=2;
b*=2;
if(a+b>c&&a+c>b&&b+c>a)
{
cout<<"Yes";
return;
}
b/=2;
c*=2;
if(a+b>c&&a+c>b&&b+c>a)
{
cout<<"Yes";
return;
}
cout<<"No";
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll t = 1;
// std::cin >> t;
while (t--) {
solve();
}
}
B.ACM中的C题
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull = unsigned long long
void solve() {
ll a,b,c;
cin>>a;
if(a==1)
{
cout<<-1;
return;
}
else
{
cout<<(a/2+a%2);
return;
}
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll t = 1;
// std::cin >> t;
while (t--) {
solve();
}
}
C.ACM中的M题
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull = unsigned long long
void solve() {
ll a,b,c;
map<int,int> mp;
cin>>a;
if(a==1)
{
cout<<-1;
return;
}
else
{
int sum=0;
for(int i=1;i<=a;++i)
{
cin>>b;
}
for(int i=1;i<=a;++i)
{
cin>>b;
mp[b]++;
}
for(map<int,int>::iterator it = mp.begin();it!=mp.end();it++)
{
if(it->second==1)
{
cout<<-1;
return;
}
else
{
sum+=(it->second/2+it->second%2);
}
}
cout<<sum;
return;
}
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll t = 1;
// std::cin >> t;
while (t--) {
solve();
}
}
E.ACM中的CM题
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n; // 读入地雷的数量
vector<int> a(n); // 存储地雷的位置
for (int i = 0; i < n; ++i) {
cin >> a[i]; // 读入每个地雷的位置
}
// 对地雷的位置进行排序,方便后续处理
sort(a.begin(), a.end());
// 初始化最小时间,最坏情况下是 n(每个地雷都单独处理)
int minTime = n;
// 遍历所有可能的排雷能力 m
for (int m = 0; m < n; ++m) {
int ans = m; // 当前排雷能力 m 需要的时间
// 当前位置初始化为第一个地雷
int pos = a[0];
// 处理所有地雷
while (1) {
ans++; // 每次需要处理的时间增加
// 查找当前能力 m + 1 可以覆盖的最远位置
pos = upper_bound(a.begin(), a.end(), pos + m) - a.begin();
if (pos == n) break; // 如果所有地雷都被处理,退出循环
// 更新当前位置为新的地雷位置
pos = a[pos];
}
// 更新最小时间
minTime = min(minTime, ans);
}
cout << minTime << endl; // 输出最小时间
return 0;
}