A

直接输出”Hello,World!"

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
void sove(){
cout<<"Hello,World!"<<"\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0); 
    ll t;
    t=1;
  //  cin>>t;
    while(t--)sove();
    
    return 0;
}

B

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll a[100005],b[100005];
void sove(){
ll n,q;
cin>>n;
for(ll i=1;i<=n;i++){
    cin>>a[i];
b[i]=a[i]+b[i-1];
}
cin>>q;
while(q--){
    ll l,r;
    cin>>l>>r;
    cout<<b[r]-b[l-1]<<"\n";
}
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0); 
    ll t;
    t=1;
  //  cin>>t;
    while(t--)sove();
    
    return 0;
}

C

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n,p,minn=1e9;
void sove(){
cin>>n>>p;
vector<ll>a(n+1);
for(ll i=1;i<=n;i++)cin>>a[i];
vector<ll>d(n+10);
for(ll i=1;i<=n;i++)d[i]=a[i]-a[i-1];
while(p--){
    ll l,r,z;
    cin>>l>>r>>z;
    d[l]+=z;
    d[r+1]-=z;
}
for(ll i=1;i<=n;i++){
    a[i]=a[i-1]+d[i];
    minn=min(minn,a[i]);
}
cout<<minn<<"\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0); 
    ll t;
    t=1;
   // cin>>t;
    while(t--)sove();
    
    return 0;
}

 

D

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n,m;
ll a[6];
void dfs(ll x){
    if(x>n){
        for(ll i=1;i<=n;i++)cout<<a[i]<<" ";
        cout<<"\n";
        return ;
        }   
    for(ll i=1;i<=m;i++){
        a[x]=i;
        dfs(x+1);
    }
}
void sove(){
cin>>n>>m;
dfs(1);
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0); 
    ll t;
    t=1;
   // cin>>t;
    while(t--)sove();
    
    return 0;
}

E

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
void sove(){
ll n,ans=0;
cin>>n;
vector<ll>a(n+1),b(n+1);
for(ll i=1;i<=n;i++)cin>>a[i];
for(ll i=1;i<=n;i++)cin>>b[i];
ll l=1,r=1;
sort(a.begin()+1,a.end());
sort(b.begin()+1,b.end());
while(l<=n&&r<=n){
if(a[l]>b[r]){
    ans++;
    r++;
    l++;
}
else l++;
}
cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0); 
    ll t;
    t=1;
 //   cin>>t;
    while(t--)sove();
    
    return 0;
}

 

F

dfs

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll a[210],f[210];
ll n,m,k,ans=1e18;
void dfs(ll x,ll y,ll z){
    if(x<1||x>n)return ;
    if(z>=f[x])return ;
    if(x==y){
        ans=min(ans,z);
        return ;
    }
    f[x]=z;
    dfs(x+a[x],y,z+1);
    dfs(x-a[x],y,z+1);
}
void sove(){
    cin>>n>>m>>k;
for(ll i=1;i<=n;i++){
cin>>a[i];
f[i]=1e18;
}
dfs(m,k,0);
if(ans==1e18)cout<<"-1\n";
else cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0); 
    ll t;
    t=1;
    //cin>>t;
    while(t--)sove();   
    return 0;
}

bfs

#include<bits/stdc++.h>
using namespace std;
int k[205];
int main(){
    int n,a,b,f=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        cin>>k[i];
    }
    queue<int>q;
    vector<int>vis(205,0);
        vector<int>dep(205,0);
    vis[a]=1;
    q.push(a);
    while(!q.empty()){
        int u=q.front();q.pop();
        if(u==b){
            f=1;
            cout<<dep[b]<<"\n";
            return 0;
        }
        int vs=u+k[u];
        if(vs<=n&&!vis[vs]){
             vis[vs]=1;
            dep[vs]=dep[u]+1;
            q.push(vs);
            }
        int vx=u-k[u];
        if(vx<=n&&vx>=1&&vis[vx]==0){
            vis[vx]=1;
            dep[vx]=dep[u]+1;
            q.push(vx);
        }
    }
    if(!f)cout<<-1<<"\n";
    return 0;
}