提交记录 6874


用户 题目 状态 得分 用时 内存 语言 代码长度
Kaizyn noip18a. 【NOIP2018】铺设道路 Accepted 100 3.263 ms 432 KB C++ 533 B
提交时间 评测时间
2018-11-11 19:26:06 2020-08-01 00:52:15
#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5+7;

int n, ans;
int a[Maxn];
int stk[Maxn], sz;

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", a+i);
    stk[++sz] = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(a[i] > stk[sz])
        {
            ans += a[i]-stk[sz];
            stk[++sz] = a[i];
        }
        else
        {
            while(sz && stk[sz] >= a[i]) sz--;
            stk[++sz] = a[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #136.96 us44 KBAcceptedScore: 10

Testcase #241.69 us44 KBAcceptedScore: 10

Testcase #343.66 us48 KBAcceptedScore: 10

Testcase #437.56 us48 KBAcceptedScore: 10

Testcase #539.2 us48 KBAcceptedScore: 10

Testcase #643.72 us48 KBAcceptedScore: 10

Testcase #767.79 us48 KBAcceptedScore: 10

Testcase #8351.76 us84 KBAcceptedScore: 10

Testcase #91.65 ms240 KBAcceptedScore: 10

Testcase #103.263 ms432 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:05:46 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠