河南省多校连萌(三)

点击打开链接


问题 D: QAQ & ORZ 的签到题

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

提交: 834  解决: 204

题目描述

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

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

输入

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

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

接下来 n 行,每行一个数 a ( 1a108 1≤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\n" ,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\n",a[k],a[0]);
}
}
return 0;
}


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








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值