CF #623 div.2

话说,总有人认为我是黑别人电脑的(雾??其实,我不黑电脑,我黑手机

T1

此题巨水,比较四个面积就就好了。。

/* make by ltao */
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <time.h>
#include <cmath>
#include <math.h>
#include <fstream>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define inf 1e6
#define sz 666666
#define fake int
#define re return
#define get() getchar()
using namespace std;
int read(){
    int x=0;bool f=0;
    char ch=get();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=1;
        ch=get();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=get();
    }
    re f?-x:x;
}
int t,a,b,x,y;
int main(){
    //freopen("EE.in","r",stdin);
    t=read();
    while(t--){
        a=read();b=read();x=read();y=read();
        printf("%d\n",max(max((a-x-1)*b,(x)*b),max((b-y-1)*a,y*a)));
    }
    
    re 0;
}

至于我为什么把 那个 return define 成了 re ,这是一种信仰吧。

T2

此题做法显然,但是,最好判一下最后是不是单独一个。。

/* make by ltao */
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <time.h>
#include <cmath>
#include <math.h>
#include <fstream>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define inf 1e6
#define sz 666666
#define fake int
#define re return
#define get() getchar()
using namespace std;
int read(){
    int x=0;bool f=0;
    char ch=get();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=1;
        ch=get();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=get();
    }
    re f?-x:x;
}
const int Maxn=1e5+11;
int t,a,b,cc,cnt;
struct Node{
    int l,r;//l 闭 ,r开
    char d;
}aa[Maxn];
char c[Maxn];
int main(){
//  freopen("EE.in","r",stdin);
    t=read();
    while(t--){
        a=read();b=read();cc=read();cnt=0;
        scanf("%s",c+1);
        int len=strlen(c+1);
        int last=1;
        for(int i=2;i<=len;i++){
            if(c[i]!=c[i-1]){
                aa[++cnt].d=c[i-1];
                aa[cnt].l=last;aa[cnt].r=i;
                last=i;
            }
        }
        aa[++cnt].d=c[len];
        aa[cnt].l=last;aa[cnt].r=len+1;
        int s=0,ind=len;
        for(int i=(aa[cnt].l==len)?cnt-1:cnt;i>=1;i--){
            s+=aa[i].d=='A'?a:b;
            if(s>cc) break;
            ind=aa[i].l;
        }
        printf("%d\n",ind);
    }
    re 0;
}

T3

此题做法真是(雾,因为我看到了他的 \(\sum n=100\) ,然后因为信仰打了爆搜,考场的时候过了,,然后,再测就 TLE

然后,事实上有贪心的想法,而且是成立的。。其实有道理

/* make by ltao */
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <time.h>
#include <cmath>
#include <math.h>
#include <fstream>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define inf 1e6
#define sz 666666
#define fake int
#define re return
#define get() getchar()
using namespace std;
int read(){
    int x=0;bool f=0;
    char ch=get();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=1;
        ch=get();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=get();
    }
    re f?-x:x;
}
const int Maxn=1e3+11;
int t,b[Maxn],a[Maxn*2],n;
bool f,flag[Maxn];
void solve(){
    for(int i=1;i<=n;++i){
        bool f=0;
        for(int j=a[2*i-1]+1;j<=2*n;++j)if(!flag[j]){
            a[2*i]=j;
            flag[j]=1;
            f=1;break;
        }
        if(!f){
            printf("-1\n");return;
        }
    }
    for(int i=1;i<=2*n;++i)printf("%d ",a[i]);
    printf("\n");
}

int main(){
    //freopen("EE.in","r",stdin);
    t=read();
    while(t--){
        memset(flag,0,sizeof flag);f=0;
        n=read();
        for(int i=1;i<=n;i++) {
            b[i]=read();
            flag[b[i]]=1;
            a[i*2-1]=b[i];
        }
        if(!flag[1]||flag[n*2]){
            printf("-1\n");
            continue;
        }
        solve();
    }
    re 0;
}

T4

此题真是太心酸了。

其实,用贪心的想法,做好堆就好了。。其实是大根堆。。。

#include<cstdio>
#include <iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN=200010;
int n;
ll totw,ans;
struct Node{
    int num,w;
}a[MAXN];
bool cmp(Node x,Node y){
    if(x.num!=y.num)return x.num<y.num;
    else return x.w>y.w;
}
int main(){
//  freopen("EE.in","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i].num);
    for(int i=1;i<=n;++i)scanf("%d",&a[i].w);
    sort(a+1,a+n+1,cmp);
    priority_queue<int> q;
    for(int i=2;i<=n;++i){
        if(a[i-1].num==a[i].num){
            totw+=a[i].w;//记录同一位置的总和 
            q.push(a[i].w);
        }
        else{
            for(int p=a[i-1].num+1;totw>0&&p<=a[i].num-1;++p){
                ans+=totw;
                totw-=q.top();q.pop();
            }
            ans+=totw;
            if(totw>0&&a[i].w<q.top()){
                totw-=q.top();q.pop();
                totw+=a[i].w;q.push(a[i].w);
            }
        }
    }
    while(totw>0){
        ans+=totw;
        totw-=q.top();q.pop();
    }
    printf("%lld\n",ans);
    return 0;
}

这几次成绩不好的原因

  1. 实力太弱
  2. 缺乏分析
  3. 没有想法

所以,oi之路漫漫,吾将上下而求索

猜你喜欢

转载自www.cnblogs.com/zhltao/p/12356304.html