• 河南省多校连萌(三)


    点击打开链接


    问题 D: QAQ & ORZ 的签到题

    时间限制: 1 Sec 内存限制: 128 MB

    提交: 834 解决: 204

    题目描述

    QAQ 的好朋友 ORZ,最近在做一个选拔节目的评委,对于每位选手 ORZ 想知道在这个选手以及这位选手前面的的选手中,得分最高和最低的选手的序号分别是多少....

    ORZ 找了 QAQ 帮忙,但是 QAQ 最近在追火星情报局....所以你可以帮助 QAQ 解决 ORZ 的问题吗?

    输入

    第一行一个数 T  (1T101≤T≤10),表示 T 组测试数据

    第二行一个数 n  (1n1051≤n≤105 ),表示有 n 位选手

    接下来 n 行,每行一个数 a (1a1081≤a≤108),表示第 i 位选手的得分,打分总是从第一位选手开始

    输出

    输出从 1 ~ n 位选手中 a[i],在 1 ~ i 之间的选手中得分最高和得分最低的选手的序号分别是多少。

    如果得分相同则优先输出较小的序号。

    样例输入

    1
    3
    1
    2
    3

    样例输出

    1 1
    2 1
    3 1
    

    AC代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int MAX = 1e5 + 10;
    typedef long long LL;
    int d[MAX],x[MAX],a[MAX];
    int main()
    {
        int T,n;
        scanf("%d",&T);
        while(T--){
            scanf("%d",&n);
            LL md = 1,mx = 1;
            for(int i = 1; i <= n; i++){
                scanf("%lld",&a[i]);
                if(a[md] < a[i]) md = i;
                if(a[mx] > a[i]) mx = i;
                d[i] = md,x[i] = mx;
            }
            for(int i = 1; i <= n; i++) printf("%d %d ",d[i],x[i]);
        }
        return 0;
    }
    /**************************************************************
        Problem: 1411
        User: test
        Language: C++
        Result: 正确
        Time:548 ms
        Memory:868 kb
    ****************************************************************/




    TEL代码


    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    using namespace std;
    int a[100009];
    int Maxn,Minn;
    int main()
    {
    // memset(a,0,sizeof(a));
    int n;
    scanf("%d",&n);
    while(n--)
    {
    int m;
    scanf("%d",&m);
    for(int i=0; i<m; i++)
    {
    scanf("%d",&a[i]);
    }
    for(int k=0; k<m; k++)
    {
    sort(a,a+k);
    printf("%d %d ",a[k],a[0]);
    }
    }
    return 0;
    }


    都是两个for,为什么我的超时,它的AC发火








    永远渴望,大智若愚(stay hungry, stay foolish)
  • 相关阅读:
    Java多线程学习(吐血超具体总结)
    java.lang.Integer can not be cast to java.lang.Long
    【转】随身HiFi 安卓OTG功能在音频上的妙用
    【转】锋狂百科:手机也能接外设 OTG技术详解
    【转】用串口登录Beaglebone Black、用usb共享电脑网络、内核模块的本地编译
    【转】Beagleboard:BeagleBoneBlack
    【转】
    【转】Beaglebone Black
    【转】你应该知道的 10 个 VirtualBox 技巧与高级特性
    如何把SKYPE的发送消息由enter改为ctrl+enter?
  • 原文地址:https://www.cnblogs.com/h-hkai/p/7406503.html
Copyright © 2020-2023  润新知