SDUT 2021 Winter Individual Contest - I(Kattis)

74 篇文章 12 订阅
48 篇文章 0 订阅

A - Alehouse

题目链接

答案

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int M = 11;
using namespace std;

int n,k;
vector<PII> dp;


void solve(){
    cin>>n>>k;
    int u,v;
    rep(i,0,n-1){
        cin>>u>>v;
        dp.pb({u,1});
        dp.pb({v+1,-1});
    }
    sort(dp.begin(),dp.end());
    int m=n*2;
    int maxn=-1;
    int res=0;
    int j=0;
    rep(i,0,m-1){
        while(j<m&&dp[j].first<=dp[i].first+k-1){
            if(dp[j].second==1) res++;
            j++;
        }
        if(dp[i].second==-1){
            maxn=max(maxn,res);
            res--;
        }
    }
    cout<<maxn<<endl;
}

int main() {
    solve();
    return 0;
}

C - Climbing Stairs

题目链接

答案

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int M = 11;
using namespace std;

void solve(){
     int n,r,k;
     cin>>n>>r>>k;
     if(r>=k)
    {
        if(n<=r)
            cout<<2*r<<endl;
        else{
            if((n%2!=r%2)||(n%2!=r%2)) cout<<n+r+1<<endl;
            else cout<<n+r<<endl;
        }
    }
    else
    {
        if(n<=2*k-r) cout<<2*k<<endl;
        else{
            if((n%2!=r%2)||(n%2!=r%2)) cout<<n+r+1<<endl;
            else cout<<n+r<<endl;
        }
    }
}

int main() {
    solve();
	return 0;
}

H - Howl

题目链接

答案

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int M = 11;
using namespace std;

void solve(){
    string s;
    cin>>s;
    int len=s.size();
    string str="AWH";
    int cnt=len-2;
    cout<<str;
    rep(i,0,cnt-1){
        cout<<"O";
    }
    cout<<endl;
}

int main() {
    solve();
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值