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

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之路漫漫,吾将上下而求索

CF #623 div.2的更多相关文章

  1. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  2. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

  3. CF #374 (Div. 2) D. 贪心,优先队列或set

    1.CF #374 (Div. 2)   D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...

  4. CF #374 (Div. 2) C. Journey dp

    1.CF #374 (Div. 2)    C.  Journey 2.总结:好题,这一道题,WA,MLE,TLE,RE,各种姿势都来了一遍.. 3.题意:有向无环图,找出第1个点到第n个点的一条路径 ...

  5. CF #371 (Div. 2) C、map标记

    1.CF #371 (Div. 2)   C. Sonya and Queries  map应用,也可用trie 2.总结:一开始直接用数组遍历,果断T了一发 题意:t个数,奇变1,偶变0,然后与问的 ...

  6. CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组

    题目链接:CF #365 (Div. 2) D - Mishka and Interesting sum 题意:给出n个数和m个询问,(1 ≤ n, m ≤ 1 000 000) ,问在每个区间里所有 ...

  7. CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组(转)

    转载自:http://www.cnblogs.com/icode-girl/p/5744409.html 题目链接:CF #365 (Div. 2) D - Mishka and Interestin ...

  8. CF round 623 Div.1D Tourism 题解

    题目链接:https://codeforces.com/contest/1314/problem/D 大意: \(n\) 个顶点的有向图,顶点编号为 \(1\) 到 \(n\),任意两个不同的顶点 \ ...

  9. CF#138 div 1 A. Bracket Sequence

    [#138 div 1 A. Bracket Sequence] [原题] A. Bracket Sequence time limit per test 2 seconds memory limit ...

随机推荐

  1. Leetcode | 刷题日记(1)

    本文记录个人刷题记录 推荐两个刷题网站: 地址:https://leetcode.com/ 另外一个地址:http://www.lintcode.com/ 1.Write a SQL query to ...

  2. 全国疫情精准定点动态更新(.net core)

    前言 疫情远比我们在年初想的发展迅速,在过年前还计划着可以亲戚聚聚,结果都泡汤了,开始了自家游. 在初三的时候,看到那个丁香医生,觉得不够详细,比如说我想看下周边城市的疫情情况,但是我地理不好,根本不 ...

  3. 一次DB故障引起的反思和MySQL Operator选型

    前言 在一次数据库故障后,我们发现业务库会根据业务的等级会划分多个 MySQL 实例,许多业务库会同时属于一个 MySQL 实例,当一个库引发问题后整个实例的状态是不可控的.从而导致这个实例上的所有业 ...

  4. 用ExpressionTree实现JSON解析器

    今年的春节与往年不同,对每个人来说都是刻骨铭心的.突入其来的新型冠状病毒使大家过上了“梦想”中的生活:吃了睡,睡了吃,还不用去公司上班,如今这样的生活就在我们面前,可一点都不踏实,只有不停的学习才能让 ...

  5. Codeforces 1138B Circus (构造方程+暴力)

    题意: 给你两个01串,要你选n/2个位置,使得选的位置在s1中"1"的数量等于未选的s2中"1"的数量 n<=5000,1s 思路: 设两个串中出现&q ...

  6. Codeforces 1092 D2 Great Vova Wall (Version 2) (栈)

    题意: 给一排砖,每列的高度$a_i$,问是否可以放1*2的砖,使得n列高度一样,砖只能横着放 思路: 每两个相邻的高度相同的砖可以变成大于等于它的高度的任意高度 所以像这样的 123321 是不满足 ...

  7. 题解 CSP2019-J2T4【加工零件】

    这题我们要求的是啥呢?仔细读题可以发现,工人传送带的关系可以看成一个 \(n\) 个点和 \(m\) 条边的无向图,然后对于每组询问 \((a,L)\),其实就是问: \(1\) 到 \(a\) 有没 ...

  8. Import This - The Zen of Python

    The Zen of Python -- by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Si ...

  9. 阿里云服务器ECS Ubuntu18.04 初次使用配置教程(图形界面安装)

    最近由于工作需要,要使用服务器测试,就先自已买了个服务器,就在阿里云买了一个,先买了那个叫虚拟主机的,后来发现不是我需要的,所以退了,就先了这个ECS主机.3年.如果购买就上图了.下面直接进入正题. ...

  10. 《Head first设计模式》学习笔记

    1. 单例模式 2. 工厂模式 3. 抽象工厂 4. 策略模式 5. 观察者模式 6. 装饰者模式 7. 命令模式 8. 适配器模式 9. 外观模式 10. 模版方法模式 11. 迭代器模式 设计模式 ...