/ 科创班 /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 1ms 480.0 KiB
#2 Accepted 2ms 476.0 KiB
#3 Accepted 2ms 384.0 KiB
#4 Accepted 3ms 468.0 KiB
#5 Accepted 32ms 384.0 KiB

代码

#include <stdio.h>
#define N 50000

int main()
{
    int i, j, n, a[N] = {0};
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    
    int count = 0;
    for (i = 0; i < n; i++)
    {
        int the_max = a[i];
        int the_min = a[i];
        count += 1;
        for (j = i + 1; j < n; j++)
        {
            if (the_max < a[j]) the_max = a[j];
            if (the_min > a[j]) the_min = a[j];
            if (the_max - the_min == j - i)
                count += 1;
        }
    }
    
    printf("%d", count);
    return 0;
}

信息

递交者
类型
递交
题目
连号区间数
题目数据
下载
语言
C
递交时间
2018-10-17 22:02:42
评测时间
2018-10-17 22:02:42
评测机
分数
100
总耗时
42ms
峰值内存
480.0 KiB