This commit is contained in:
Zengtudor 2024-10-16 10:53:15 +08:00
parent 4efd741fa9
commit 9084dd9b7e
2 changed files with 76 additions and 1 deletions

View File

@ -1 +1,35 @@
int main(){}
#include <algorithm>
#include <iostream>
#include <string>
using ll = long long;
auto &is = std::cin;
auto &os = std::cout;
std::string m, r;
void dfs(const std::string_view &sv)noexcept{
if(sv.size()==0){
return;
}
ll max_rpos{};
for(auto &i:sv){
max_rpos = std::max((ll)r.find(i),max_rpos);
}
const ll sv_root_pos{(ll)sv.find(r[max_rpos])};
os<<sv[sv_root_pos];
dfs(std::string_view(sv.data(),sv_root_pos));
dfs(std::string_view(sv.begin()+sv_root_pos+1,sv.size()-sv_root_pos-1));
}
int main(){
is>>m>>r;
os<<r.back();
dfs(std::string_view(m.data(),m.find(r.back())));
dfs(std::string_view(m.data()+1+m.find(r.back())
,m.size()-m.find(r.back())-1));
os<<'\n';
}

41
src/P5019/P5019.cpp Normal file
View File

@ -0,0 +1,41 @@
#include <cctype>
#include <cstdio>
#include <iostream>
using ll = long long;
ll n,a,b,ans;
struct ReadLL{
char c;
ll n,w;
ReadLL&operator>>(ll &num)noexcept{
c=0,n=0,w=1;
while(!isdigit(c)){
if(c=='-')w=-1;
c=getchar();
}
while(isdigit(c)){
n=n*10+c-'0';
c=getchar();
}
num=n*w;
return *this;
}
}readll;
// auto &is = std::cin;
auto &is = readll;
auto &os = std::cout;
int main(){
is>>n;
for(ll i{0};i!=n;i++){
is>>b;
if(b>a){
ans+=b-a;
}
a=b;
}
os<<ans<<'\n';
}