A不想补了 以后再说吧
C - Cryptographer's Conundrum
纯纯签到题,我手误 写成i % 3 == 3; 了,wa了一发,对不起我的队友
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
int v[N], n, m, k, x, t, T;
void ClearFloat()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
signed main()
{
ClearFloat();
int a = 0, b = 0, c = 0;
string s;
cin >> s;
for (int i = 0; i < s.size(); i++)
{
if (i % 3 == 0 && s[i] == 'P')
a++;
if (i % 3 == 1 && s[i] == 'E')
b++;
if (i % 3 == 2 && s[i] == 'R')
c++;
}
cout << s.size() - a - b - c << endl;
return 0;
}
D - Disastrous Downtime
这道题也特别恶心,本来在想常规算法,队友灵光一现直接a掉,搜题解发现都是二分,但其实是个思维题,只需要求出来同时在运行的最大个数除以k然后向上去整就行
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
int v[N], n, m, k, x, t, T;
void ClearFloat()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
queue<int> q;
signed main()
{
ClearFloat();
int ans = 1;
cin >> n >> k;
for (int i = 1; i <= n; i++)
{
cin >> x;
if (q.empty())
{
q.push(x);
continue;
}
while (q.size() && x >= q.front() + 1000)
q.pop();
q.push(x);
int a = q.size();
ans = max(ans, a);
}
if (ans % k == 0)
cout << ans / k;
else
cout << ans / k + 1;
return 0;
}
E - Entertainment Box
不得不说这道题题解确实巧妙,这道题和acwing上的有道模板题挺像的,但是有点区别,挂上链接,感兴趣的可以对比一下。题解不得不说真的🐮
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
int v[N], n, m, k, x, t, T;
void ClearFloat()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
struct node
{
int l, r;
} f[N];
bool cmp(node a, node b)
{
return a.r < b.r;
}
signed main()
{
ClearFloat();
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> f[i].l >> f[i].r;
sort(f + 1, f + 1 + n, cmp);
int ans = 0;
multiset<int> s;
multiset<int>::iterator it;
for (int i = 1; i <= m; i++)
s.insert(0);
for (int i = 1; i <= n; i++)
{
it = s.upper_bound(f[i].l);
if (it == s.begin())
continue;
else
{
it--;
s.erase(it);
s.insert(f[i].r);
ans++;
}
}
cout << ans;
return 0;
}
G - Goblin Garden Guards
恶心至极的题!!!!!不说了直接看代码吧
#include <bits/stdc++.h>
using namespace std;
struct code
{
int x,y,r;
}a[100002],b[20002];
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
int n,m,ans;
cin>>n;
ans=n;
for(int i=0;i<n;i++)
{
cin>>a[i].x>>a[i].y;
}
cin>>m;
for(int i=0;i<m;i++)
{
cin>>b[i].x>>b[i].y>>b[i].r;
}
for(int i=0;i<n;i++)
{
for(int k=0;k<m;k++)
{
int x = a[i].x, y = a[i].y, xi = b[k].x, yi = b[k].y;
if(((x-xi)*(x-xi)+(y-yi)*(y-yi))<=b[k].r*b[k].r)
{
ans--;
break;
}
}
}
cout<<ans;
return 0;
}