当前位置:网站首页>Codeforces Round #807 (Div. 2) A~D
Codeforces Round #807 (Div. 2) A~D
2022-07-19 04:19:00 【zyh_ fighting】
A - Mark the Photographer
#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int g[N];
int t;
int n, x;
int main()
{
cin >> t;
while (t--)
{
cin >> n >> x;
for (int i = 1; i <= n + n; i++) cin >> g[i];
sort(g + 1, g + n + n + 1);
int flag = 0;
for (int i = 1; i <= n; i++)
{
if (g[i + n] - g[i] < x)
{
flag = 1;
break;
}
}
if (flag == 1) cout << "NO" << endl;
else cout << "YES" << endl;
}
return 0;
}B - Mark the Dust Sweeper
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200010;
LL g[N];
int t;
int n;
int main()
{
cin >> t;
while (t--)
{
LL res = 0;
cin >> n;
for (int i = 0; i < n; i++) cin >> g[i];
int i = 0;
while (g[i] == 0) i++;
for (int j = i; j < n - 1; j++)
{
if (g[j] == 0) res++;
else res += g[j];
}
cout << res << endl;
}
return 0;
}C - Mark and His Unfinished Essay
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 45;
int t;
int n, c, q;
string s;
LL l[N], r[N], k;
LL len[N];
int main()
{
cin >> t;
while(t--)
{
cin >> n >> c >> q;
cin >> s;
len[0] = n;
for(int i = 0; i < c; i++)
{
cin >> l[i] >> r[i];
l[i]--;
len[i + 1] = len[i] + r[i] - l[i];
if(len[i + 1] > (LL) 1e18) len[i + 1] = (LL) 1e18;
}
while(q--)
{
cin >> k;
k--;
for(int i = c - 1; i >= 0; i--)
{
if(len[i] > k) continue;
k = l[i] + (k - len[i]);
}
cout << s[k] << endl;
}
}
return 0;
}D - Mark and Lightbulbs
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int q, n;
string s, t;
int main()
{
cin >> q;
while(q--)
{
cin >> n >> s >> t;
if(s[0] != t[0] || s[n - 1] != t[n - 1])
{
cout << -1 << endl;
continue;
}
vector<int> a;
for(int i = 0; i < n - 1; i++)
if(s[i] != s[i + 1]) a.push_back(i);
vector<int> b;
for(int i = 0; i < n - 1; i++)
if(t[i] != t[i + 1]) b.push_back(i);
if(a.size() != b.size())
{
cout << -1 << endl;
continue;
}
LL res = 0;
for(int i = 0; i < a.size(); i++)
res += abs(a[i] - b[i]);
cout << res << endl;
}
return 0;
}边栏推荐
- string扩展方法使用
- [database] must know and be able at the end of the term ----- Chapter 1 database overview
- 06 Maui, WPF uses MVVM toolkit framework to build MVVM program
- Dapr series (I)
- Xdc 2022 Intel technology special session: Intel Software and hardware technology builds the cornerstone of cloud computing architecture
- AttributeError: ‘NoneType‘ object has no attribute ‘sort‘
- 小程序毕设作品之微信在线教育视频点播学习小程序毕业设计(2)小程序功能
- Chapter 0 performance platform godeye source code analysis - Course Introduction
- 【数据库】期末必知必会-----第十二章 数据库恢复
- Graphic verification code verification
猜你喜欢

小程序毕设作品之微信在线教育视频点播学习小程序毕业设计(4)开题报告

图形验证码验证

How to filter viruses / spam more effectively!

MAUI 框架入门学习05 MVVM数据模型理解

WPF cannot find resource file problem

小程序毕设作品之微信电子书阅读小程序毕业设计(1)开发概要

Unity - 如何修改一个 Package 或是如何将 Package Local化

无心剑汉英双语诗005.《抒怀》

Insert the laptop into the headset and still play it out (the personal test is valid)

可省近90%服务器,反欺诈效率却大增,PayPal打破「AI内存墙」的方案为何如此划算?
随机推荐
priority_queue的介绍及其使用
[database] must know and be able at the end of the term ----- Chapter VIII database security
06 Maui, WPF uses MVVM toolkit framework to build MVVM program
如何更有效的过滤病毒/垃圾邮件!
机器学习10:集成学习
[wechat applet] super easy to understand conditional rendering and list rendering
Laravel's file upload
Chapter 4 performance platform godeye source code analysis - monitoring module
可省近90%服务器,反欺诈效率却大增,PayPal打破「AI内存墙」的方案为何如此划算?
priority_ Introduction and use of queue
英特尔专家分享:如何在XPU架构上高效编程?丨至强研究所
Insert the laptop into the headset and still play it out (the personal test is valid)
小程序毕设作品之微信电子书阅读小程序毕业设计(2)小程序功能
FTXUI基础笔记(botton按钮组件基础)
leetcode209. 长度最小的子数组
Deconstruction of typescript array / object / string / function parameters
Nearly 90% of servers can be saved, but the anti fraud efficiency has increased significantly. Why is PayPal's plan to break the "Ai memory wall" so cost-effective?
XDC 2022 Intel 技术专场:英特尔软硬件技术构筑云计算架构基石
PAC十年:见证HPC从CPU时代走向XPU纪元
Wechat e-book reading applet graduation project (6) opening defense ppt