2017 Multi-University Training Contest - Team 2

1001

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
char a[1000000];
char b[1000000];
int count(int n,int s,int x,int y){
    if(x + y > n + s)
        return 0;
    if(abs(x-y) > n-s)
        return 0;
    return 1;
}
int main(){
    int t,n,x,y;
    cin>>t;
    while(t--){
        cin>>n>>x>>y;
        scanf("%s",a);
        scanf("%s",b);
        int same = 0;
        for(int i = 0;i < n; i++){
            if(a[i] == b[i])
                same++;
        }
        if(count(n,same,x,y) == 1) cout<<"Not lying"<<endl;
        else cout<<"Lying"<<endl;

    }
}

1003


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
#define maxn 250007
int ans[maxn];
int tree[maxn];


int get(int p){
    int ans = 0;
    while(p < maxn){
        ans = max(ans,tree[p]);
        p +=(p&(-p));
    }
    return ans;
}
void set(int p,int d){
    while(p > 0){
        tree[p] = max(tree[p],d);
        p-=(p&-p);
    }
}
int a[maxn];
int b[maxn];
int c[maxn];
int main(){
    int t;
    while(cin>>t){
        memset(tree,0,sizeof(tree));
        for(int i = 0;i < t; i++){
            scanf("%d",&a[i]);
        }
        for(int j = 0;j < t; j++)
            scanf("%d",&b[j]);
        int p = t ;
        sort(b,b+t);
        for(int j = t-1;j >=0;j--){
            while(p>=b[j]){
                set(p,a[p-1]-p);
                p--;
            }
            c[j] = get(b[j]);
//            cout<<c[j]<<endl;
        }
        sort(c,c+t);
        int maxv = 0;
        p = t-1;
        long long ans = 0;
        for(int i = 0;i < t; i++){
            int u = max(maxv,c[p]);
            ans += u;
            maxv = max(maxv,u-(t+1+i));
            p--;
        }
        cout<<ans%1000000007<<endl;
    }
}
















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GDRetop

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值