2019.6.20义乌测试赛自我成绩分析

A. 平均分(average)

  • 提交程序:
#include<bits/stdc++.h>
using namespace std;
int n,a;
int sum=0;
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
        a=read(),sum+=a;
    cout<<fixed<<setprecision(2)<<(double)sum/(double)n<<endl;
    return 0;
}       
  • 评测结果:

Accepted 100分

  • 错误原因
  • 正确代码

B.非降(nodown)

  • 提交程序:
#include<bits/stdc++.h>
using namespace std;
char s[1000];
int n;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=2;i<=n;i++)
    {
        if(s[i]<s[i-1])
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}
  • 评测结果:

Accepted 100分

  • 错误原因
  • 正确代码

C.新魔法(new)

  • 提交程序:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100000+10;
int n,k;
ll a[MAXN];
ll g[MAXN];
ll ans=0;
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
int main()
{
    n=read();k=read();
    for(int i=1;i<=n;i++)
    {
        a[i]=read();
        a[i]*=1000;
        g[i]=g[i-1]+a[i];
        //cout<<g[i]<<endl;
    }
    for(int i=k;i<=n;i++)
    {
        ans=max(ans,(g[i]-g[i-k])/k);
    }
    cout<<ans<<endl;
    return 0;
}
  • 评测结果:

Accepted 100分

  • 错误原因
  • 正确代码

D.排名(sort)

  • 提交程序:
#include<bits/stdc++.h>
using namespace std;
const int MAXN=3000+10;
int n;
struct Node
{
    int sum;
    int s;
}a[MAXN];
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
inline int get(int x)
{
    int tot=0;
    while(x)
    {
        tot+=x%10;
        x/=10;
    }
    return tot;
}
inline bool cmp(Node x,Node y)
{
    if(x.sum==y.sum)return x.s>y.s;
    else return x.sum>y.sum;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
    {
        a[i].s=read();
        a[i].sum=get(a[i].s);
        //cout<<a[i].s<<" "<<a[i].sum<<endl;
    }
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=n;i++)
        printf("%d\n",a[i].s);
    return 0;
} 
  • 评测结果:

Accepted 100分

  • 错误原因
  • 正确代码

E.宿舍改建(build)

  • 提交程序:
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10000+10;
int n,m,a;
int w[MAXN];
int cnt=0;
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;i++)
    {
        a=read();
        int pos=1;
        while(pos<=cnt&&w[pos]+a>m)pos++;
        if(pos>cnt)w[++cnt]=a;
        else
        {
            w[pos]+=a;
        }
    }
    cout<<cnt<<endl;
    return 0;
}       
  • 评测结果:

Unaccepted 40分

  • 错误原因
由于之前去华东吃饭大学参加了“游族杯”的比赛,其中有一题和这题非常非常非常相似,简直就是翻版(然而其实本质上是不一样的)。
于是我就被洗脑了,一时没想到这题其实时一道很简单的二分题,而是用了一种奇奇怪怪的贪心来做
  • 正确代码
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10000+10;
int n,m;
int a[MAXN];
int tt[MAXN];
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
inline bool check(int t)
{
    for(int i=1;i<=t;i++)
        tt[i]=a[i];
    for(int i=t+1;i<=n;i++)
    {
        int minn=0x3f3f3f3f,pos=0;
        for(int j=1;j<=t;j++)//这一部分也可以用单调队列优化
            if(tt[j]<minn)minn=tt[j],pos=j;
        tt[pos]+=a[i];
        if(tt[pos]>m)return 0;
    }
    return 1;
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
    int l=1,r=n,ans;
    while(l<=r)
    {
        int mid=l+r>>1;
        //cout<<l<<" "<<r<<" "<<mid<<" "<<check(mid)<<endl;
        if(check(mid))r=mid-1,ans=mid;
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}

F.争霸赛(game)

  • 提交代码:
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2500+10;
int n,k;
int a[MAXN],b[MAXN];
int cnt=0;
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
int main()
{
    ios::sync_with_stdio(false);
    //freopen("data2.in","r",stdin);
    n=read();k=read();
    char c;
    for(int i=1;i<=n;i++)
    {
        a[i]=a[i-1];
        b[i]=b[i-1];
        cin>>c;
        if(c=='H')a[i]++;
        else b[i]++;
        //cout<<a[i]<<" "<<b[i]<<endl;
    }
    int pos=n;
    while(a[n]!=0||b[n]!=0)
    {
        bool flag=0;
        //Sleep(100);
        if(abs(a[pos]-b[pos])<=k||!a[pos]||!b[pos])
        {
            cnt++;
            flag=1;
        }
        else pos--;
        if(flag)
        {
            int x=a[pos],y=b[pos];
            for(int i=pos;i<=n;i++)
            {
                a[i]-=x;
                b[i]-=y;
            }
            pos=n;
        }
        /*cout<<pos<<" "<<flag<<" "<<cnt<<endl;
        for(int i=1;i<=n;i++)cout<<a[i]<<" "<<b[i]<<endl;
        cout<<endl;*/
    }
    cout<<cnt<<endl;
    return 0;
}
  • 评测结果:

Unaccepted 30分

  • 错误原因:
对于这题的30分,我感到十分恼火与悲哀,看到错误代码了吗?只要我把主函数里的"ios::sync_with_stdio(false)"给去掉,我就可以拿80分的高分!!!
ios::sync_with_stdio(false)是关闭同步输入输出流的意思,在一定条件下可以加快读入数据的速度。
值得一提的是:这个流氓一样的东西还是叶康杰教我们的,但却让我白白丢了50分TAT
把这个东西去掉,还是只能拿80分,并拿不到满分,说明了贪心思想在本题是行不通的,要AC此题必须要进行DP
  • 正确代码:
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2500+10;
int n,k;
int a[MAXN],b[MAXN];
int cnt=0;
int dp[MAXN];
inline int read()
{
    int tot=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        tot=(tot<<1)+(tot<<3)+c-'0';
        c=getchar();
    }
    return tot*f;
}
int main()
{
    //freopen("data2.in","r",stdin);
    n=read();k=read();
    char c;
    dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        a[i]=a[i-1];
        b[i]=b[i-1];
        cin>>c;
        if(c=='H')a[i]++;
        else b[i]++;
        //cout<<a[i]<<" "<<b[i]<<endl;
        dp[i]=i;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            int x=a[i]-a[j-1],y=b[i]-b[j-1];
            if(abs(x-y)<=k||!x||!y)dp[i]=min(dp[i],dp[j-1]+1);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

原文地址:https://www.cnblogs.com/hulean/p/11105839.html

时间: 2024-08-30 13:48:20

2019.6.20义乌测试赛自我成绩分析的相关文章

【2016北京集训测试赛(八)】 crash的数列

Description 题解 题目说这是一个具有神奇特性的数列!这句话是非常有用的因为我们发现,如果套着这个数列的定义再从原数列引出一个新数列,它居然还是一样的...... 于是我们就想到了能不能用多点数列套着来加速转移呢? 但是发现好像太多数列套起来是可以烦死人的...... 我们就采用嵌套两次吧,记原数列为A,第一层嵌套为B,第二层嵌套为C. 我们其实可以发现一些规律,对于Ci,它对应了B中i的个数:对于Bi,它对应了A中i的个数. 稍加处理即可,我们一边计算一边模拟数列的运算,同时可以计算

测试赛B - Balance(天平的dp问题)

B - Balance Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Description Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It

测试赛D - The War(有控制范围的贪心)

D - The War Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Description A war had broken out because a sheep from your kingdom ate some grasses which belong to your neighboring kingdom. The counselor of your k

2018冬令营模拟测试赛(十九)

2018冬令营模拟测试赛(十九) [Problem A]小Y 试题描述 输入 见"试题描述" 输出 见"试题描述" 输入示例 见"试题描述" 输出示例 见"试题描述" 数据规模及约定 见"试题描述" 题解 目前未知. 这题目前就能做到 \(O(n \sqrt{M} \log n)\),其中 \(M\) 是逆序对数,然而会被卡 \(T\):当然这题暴力可以拿到和左边那个算法一样的分数,只要暴力加一个剪枝:当左

SDUT2013级测试赛_D

题目描述 给出一棵含有n个点的树,每个点权值为wi,求从根节点到叶子结点权值和最大的那条路经的权值和是多少. 输入 n(1<= n && n <= 10000). 接下来n+1行,每行两个整数w(w <= 1000). 第i个节点的父节点为w,若 i为根节点.600组数据. 输出 对于每组数据,输出一个数代表答案. 示例输入 3 0 5 1 5 1 6 示例输出 11 提示 来源 解题报告 求从根节点出发到叶子的最长路...很像数塔... 我暴力dfs过了.怒搜所有数枝,

计蒜之道 测试赛 (BCD)

测试赛写写题解不会被吐槽吧... 淘汰赛车 时限:1000ms 内存:262144K 赛车比赛在潘多拉星球变得越来越流行了.但是他们的比赛跟我们平常的不太一样:n 辆赛车在一条长长的直道上展开同台竞技.每辆赛车的速度都为 1m/s,整条赛道在每一米都有坐标标记. 在比赛的赛车中,赛车 i 从 0 秒开始由 ai 向 bi 移动.到达 bi 之后转而返回由 bi 向 ai 移动.循环往复. 又是蒜头菌!原来这是蒜头菌正在玩的一个手机小游戏.蒜头菌可以在某些位置放下 TNT 炸毁某些赛车.因为他有

测试赛A - Colored Sticks(并查集+字典树+欧拉回路)

A - Colored Sticks Time Limit:5000MS     Memory Limit:128000KB     64bit IO Format:%I64d & %I64u Submit Status Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sti

测试赛F - Dragon Balls(并查集)

F - Dragon Balls Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Five hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to

测试赛C - Eqs(哈希)

C - Eqs Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description Consider equations having the following form: a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=0 The coefficients are given integers from the interva