编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#66949 #1320. [L1-7]救火队员 Accepted 100 45 ms 368 K C++ / 939 B q3w5 2022-03-26 22:29:39
显示原始代码
#include <bits/stdc++.h>
using namespace std;
stack<pair<int, int> > v;
int main() {
    int n;
    cin >> n;
    int anss = -1;
    for (int i = 0; i < n; i++) {
        int pos = i;
        pair<int, int> aa;
        cin >> aa.first;
        int lastPos = 2000000;
        while (!v.empty() && v.top().first > aa.first) {
            pair<int, int> topp = v.top();
            v.pop();
            int value = topp.first;
            int poss = topp.second;
            int dpos = pos - poss;
            int mul = dpos * value;
            if (mul > anss)
                anss = mul;
            if (poss < lastPos)
                lastPos = poss;
            // cout<<"now="<<aa.first<<" pos="<<pos<<endl;
            // cout<<"pop! "<<value<<" "<<poss<<endl;
        }
        aa.second = pos;
        if (lastPos < 2000000) {
            v.push(make_pair(aa.first, lastPos));
        }
        v.push(aa);
    }

    while (!v.empty()) {
        pair<int, int> topp = v.top();
        v.pop();
        int value = topp.first;
        int poss = topp.second;
        int dpos = n - poss;
        int mul = dpos * value;
        if (mul > anss)
            anss = mul;
    }
    cout << anss << endl;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:6 ms
内存:368 KiB

输入文件(min_01.in

1
1

答案文件(min_01.out

1

用户输出

1

系统信息

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

输入文件(random_01.in

8192
60522 14575 36426 79445 48772 90081 33447 90629 3497 47202 7775 94325 63982 4784 68417 2156 319
<48151 bytes omitted>

答案文件(random_01.out

901408

用户输出

901408

系统信息

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

输入文件(sample_01.in

6
2 4 4 9 4 9

答案文件(sample_01.out

20

用户输出

20

系统信息

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

输入文件(random_02.in

8191
85925 39836 63225 34999 22439 10902 3198 53774 26740 40447 83006 28518 67297 37973 86792 80230 
<48192 bytes omitted>

答案文件(random_02.out

1201200

用户输出

1201200

系统信息

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

输入文件(sample_02.in

6
200 4 4 9 4 9

答案文件(sample_02.out

200

用户输出

200

系统信息

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

输入文件(random_03.in

10000
68547 24256 53097 1352 49208 27787 55371 32853 50232 66335 14396 91997 93687 85044 21626 16751
<58788 bytes omitted>

答案文件(random_03.out

823277

用户输出

823277

系统信息

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

输入文件(random_04.in

8192
94564 65283 16004 30238 9987 91514 57736 52928 65520 45505 31845 84075 14031 61374 85994 25599 
<48080 bytes omitted>

答案文件(random_04.out

928620

用户输出

928620

系统信息

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

输入文件(random_05.in

8191
59453 639 55985 4685 57316 93757 24797 65975 53785 38796 92578 82666 31328 57969 19952 71686 59
<48171 bytes omitted>

答案文件(random_05.out

983232

用户输出

983232

系统信息

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

输入文件(random_06.in

10000
79719 33046 3578 77246 51964 1670 78656 10898 70510 32707 30807 65248 39849 60178 97957 3125 8
<58852 bytes omitted>

答案文件(random_06.out

997808

用户输出

997808

系统信息

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

输入文件(random_07.in

8192
37280 78466 20270 23588 83436 34033 66462 27024 21459 15174 21402 43592 31572 13265 17706 61686
<48124 bytes omitted>

答案文件(random_07.out

830620

用户输出

830620

系统信息

Exited with return code 0