当前位置:网站首页>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;
}边栏推荐
- 微信附近的人小程序怎么开(开通附近小程序的方法)
- WPF cannot find resource file problem
- Some problems after xcode11 new project
- [database] must know and be able at the end of the term ----- Chapter 11 concurrency control
- Wechat e-book reading of small program graduation design (5) task book
- Machine learning 10: Integrated Learning
- Build a portrait matting server based on openvino model server
- Data interaction between avframe\avpacket and itself in ffmpeg
- [database] must know and be able at the end of the term ----- Chapter VIII database security
- string扩展方法使用
猜你喜欢

Common methods of C string

【数据库】期末必知必会-----第九章 数据库设计

Chapter 5 performance platform godeye source code analysis - third party module

SQL interface switching cannot obtain focus

Unity - how to modify a package or localize it

To build agile teams, these methods are indispensable

IN Tech 2022|英特尔技术产品创新速览

Chapter 2 performance platform godeye source code analysis - data module

If by frame package name modifier

Wechat online education video on demand learning applet graduation design (3) background function
随机推荐
Wechat Online Education video on Demand Learning of applet Graduation Design (3) Background Function
Wechat e-book reading of applet completion works (7) Interim inspection report
Typescript数组/对象/字符串/函数参数的解构使用
Idea configures SFTP and SSH, which is very convenient to deploy and locate error logs
Chapter 5 performance platform godeye source code analysis - third party module
PAC Decade: witness HPC from CPU era to XPU Era
In the era of super video, what is the solution to the data flood?
VS Code 常用快捷键
Introduction to Maui framework 05 MVVM data model understanding
[database] must know and know at the end of the period ----- Chapter 12 database recovery
V4l2 learning materials collection
Some problems after xcode11 new project
Openresty as a static resource server
Find the central subscript of the array
Laravel's file upload
Record a troubleshooting when overseas pictures cannot be loaded
【数据库】期末必知必会-----第九章 数据库设计
To build agile teams, these methods are indispensable
Academic sharing | design and development of multi staining pathological image information evaluation system based on openvino
[database] must know and be able at the end of the term ----- Chapter 10 database programming