当前位置:网站首页>Educational codeforces round 129 (rated for Div. 2) supplementary problem solution
Educational codeforces round 129 (rated for Div. 2) supplementary problem solution
2022-07-02 19:39:00 【Mr. Qiao Da】
Educational Codeforces Round 130 Rated for Div. 2
I haven't practiced for a while , Two questions in ten minutes , But the third question is still lack of thinking ability , Keep practicing , come on.
A Parkway Walk
Simple thinking , Calculate the distance and , Then subtract the distance between the stools
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
#define int long long
int T;
int a[N];
int n, m;
signed main()
{
cin>>T;
while(T -- ){
int res = 0;
cin>>n>>m;
for(int i = 0; i < n; i ++ ){
int t;
cin>>t;
res += t;
}
if(m >= res) cout<<0<<endl;
else{
cout<<res - m<<endl;
}
}
return 0;
}
B Promo
Simple thinking , Arrange the order , Find a prefix and , Prefix and output the following part as required
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
#define int long long
int T;
int a[N];
int n, m, q;
int res[N]; // Prefixes and arrays
signed main()
{
cin>>n>>q;
for(int i = 1; i <= n; i ++ ){
cin>>a[i];
}
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i ++ ) res[i] = res[i - 1] + a[i];
// cout<<res[n]<<endl;
while(q -- ){
int x, y;
cin>>x>>y;
// cout<<n - x + y<<' '<<n - x<<"***"<<endl;
int op = res[n - x + y] - res[n - x];
cout<<op<<endl;
}
return 0;
}
C awoo’s Favorite Problem
Thinking questions , It's not too late for the game , The official solution is quite clear :
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
string s, t;
int T;
int n;
int res1, res2;
bool st;
int main()
{
cin>>T;
while(T -- ){
res1 = 0;
res2 = 0;
s.clear();
t.clear();
cin>>n;
cin>>s;
cin>>t;
int j = 0;
st = false;
//b The number of will not change , If two strings b The number of different , Then it must not be a string
for(int i = 0; i < n; i ++ ){
if(s[i] == 'b') res1 ++ ;
if(t[i] == 'b') res2 ++ ;
}
if(res1 != res2){
cout<<"NO"<<endl;
continue;
}
// Transformation s, Give Way s And t equal
//a Can only move right
//c It can only be moved to the left
for(int i = 0; i < n; i ++ ){
if(s[i] == 'b'){
while(t[j] == 'b'){
// find t The first of them is not b The letter of
j ++ ;
}
continue;
}
while(t[j] == 'b'){
// find t The first of them is not b The letter of
j ++ ;
}
//s[i] May be b, however t[j] It must not be for b, In three cases, two strings can never be equal
//①s[i] and t[j] Remove b The first one traversed after is not b Different characters , because a、c Unable to cross b swap , therefore s It must not be able to become t
//s[i] by a, But at this time s The pointer is in t To the right of , because a Can only move right , therefore s It must not be able to become t
//s[i] by c, But at this time s The pointer is in t Left side , because c It can only be moved to the left , therefore s It must not be able to become t
if(s[i] != t[j] || (s[i] == 'a' && i > j) || (s[i] == 'c' && i < j)){
st = true;
break;
}
j ++ ;
if(i == n - 1 && t[j] == 'b') res2 ++ ;
}
if(st){
cout<<"NO"<<endl;
continue;
}
else cout<<"YES"<<endl;
}
return 0;
}
边栏推荐
- Watchful pioneer world outlook Architecture - (how does a good game come from)
- 定了,就是它!
- What is the MySQL backup suffix_ MySQL backup restore
- rxjs Observable 自定义 Operator 的开发技巧
- IEDA refactor的用法
- 程序猿入门攻略(十二)——数据的存储
- AcWing 342. Road and route problem solving (shortest path, topological sorting)
- AcWing 342. 道路与航线 题解 (最短路、拓扑排序)
- Implementation of 453 ATOI function
- Memory management of C
猜你喜欢

KT148A语音芯片ic的硬件设计注意事项
Bubble sort array

IDEA编辑器去掉sql语句背景颜色SQL语句警告No data sources are configured to run this SQL...和SQL Dialect is Not Config

Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3

Detailed tutorial on installing stand-alone redis

Data dimensionality reduction principal component analysis

rxjs Observable 自定义 Operator 的开发技巧

数据湖(十二):Spark3.1.2与Iceberg0.12.1整合

AcWing 903. 昂贵的聘礼 题解(最短路—建图、dijkstra)

《架构整洁之道》读书笔记(下)
随机推荐
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
电脑使用哪个录制视频软件比较好
【pytorch学习笔记】Tensor
mysql函数
Codeforces Round #802 (Div. 2) 纯补题
Data dimensionality reduction principal component analysis
Windows2008R2 安装 PHP7.4.30 必须 LocalSystem 启动应用程序池 不然500错误 FastCGI 进程意外退出
LeetCode 0871. Minimum refueling times - similar to poj2431 jungle adventure
451 implementation of memcpy, memmove and memset
Usage of ieda refactor
AcWing 1127. 香甜的黄油 题解(最短路—spfa)
AcWing 1135. 新年好 题解(最短路+搜索)
Gmapping code analysis [easy to understand]
checklistbox控件用法总结
简书自动阅读
Chic Lang: completely solve the problem of markdown pictures - no need to upload pictures - no need to network - there is no lack of pictures forwarded to others
AcWing 383. 观光 题解(最短路)
Yes, that's it!
c语言里怎么设立优先级,细说C语言优先级
Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3