编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#57589 #1294. 小巨人 Accepted 100 607 ms 384 K C++ 17 / 1.5 K 丁丁跑卡车 2021-07-12 21:59:56
显示原始代码
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ud unsigned int
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
//#define pi 3.141592653589
#define eps 1e-9
#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
#define G(x) ((x) < tb ? (x)*3 + 1 : ((x)-tb) * 3 + 2)
//#define p 2173412051LL
//#define sz 2

using namespace std;

template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-')
            f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    int x;
    stack<pair<int, int> > q;
    ll ans = 0;
    q.push({ 0, 1e9 + 10 });
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        while (q.top().second < x) q.pop();
        ans += i - q.top().first - 1;
        q.push({ i, x });
    }
    cout << ans;
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:18 ms
内存:288 KiB

输入文件(1.in

88038
525000372 80012714 109225034 202750922 130487539 728482754 12221732 415580934 676277240 62820
<870707 bytes omitted>

答案文件(1.ans

827480

用户输出

827480

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:77 ms
内存:376 KiB

输入文件(2.in

579587
856853027 491128544 890854354 153519960 984791609 206048293 825864731 757030299 454709263 71
<5731544 bytes omitted>

答案文件(2.ans

6654540

用户输出

6654540

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:46 ms
内存:384 KiB

输入文件(3.in

332776
20214786 25643449 85875229 669189822 786830323 78956882 896957608 316275871 996659486 112043
<3290502 bytes omitted>

答案文件(3.ans

3640628

用户输出

3640628

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:52 ms
内存:376 KiB

输入文件(4.in

378106
649277098 602235533 676791970 565157587 871478991 969866980 305951880 349922654 219356112 71
<3739348 bytes omitted>

答案文件(4.ans

4255686

用户输出

4255686

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:10 ms
内存:376 KiB

输入文件(5.in

50707
573885207 16269207 484510054 235771559 126486098 416813941 239447948 228122492 605078855 5606
<501320 bytes omitted>

答案文件(5.ans

454772

用户输出

454772

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:94 ms
内存:376 KiB

输入文件(6.in

718010
395903754 395576340 135364929 667873133 671849068 433013211 158510201 649491954 345164287 81
<7100232 bytes omitted>

答案文件(6.ans

8739603

用户输出

8739603

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:91 ms
内存:376 KiB

输入文件(7.in

687980
359487458 74032531 780864892 968394410 12251982 7681806 193646009 858538586 146826885 130208
<6803076 bytes omitted>

答案文件(7.ans

8165253

用户输出

8165253

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:18 ms
内存:376 KiB

输入文件(8.in

114647
704295242 692354435 905240998 987254045 310468104 743698300 292349193 960759587 489744508 39
<1133571 bytes omitted>

答案文件(8.ans

1145186

用户输出

1145186

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:103 ms
内存:376 KiB

输入文件(9.in

781448
0 969 1941 2489 3864 4571 5811 6134 7960 7492 9437 10456 11609 12377 12968 13066 15126 14617
<7690522 bytes omitted>

答案文件(9.ans

1295853917

用户输出

1295853917

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:98 ms
内存:372 KiB

输入文件(10.in

817680
1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 11000 12000 13000 14000 15000 16000 17000
<8065604 bytes omitted>

答案文件(10.ans

334299882360

用户输出

334299882360

系统信息

Exited with return code 0