编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#31543 #2053. 帽子为什么尖尖的? Time Limit Exceeded 75 8351 ms 7040 K C++ 11 / 1.1 K 192024215716 2025-03-16 18:22:46
显示原始代码
#include <iostream>
#include <set>
using namespace std;

multiset<long> a;

// 增加长度为 x 的帽子
void path1(int x) { a.insert(x); }

// 删除长度为 x 的帽子
void path2(int x) {
    auto it = a.find(x);
    if (it != a.end()) {
        a.erase(it);
    }
}

// 计算区间 [x, y] 内帽子长度的总和
long path3(int x, int y) {
    long ans = 0;
    auto left = a.lower_bound(x);
    auto right = a.upper_bound(y);
    for (auto it = left; it != right; ++it) {
        ans += *it;
    }
    return ans;
}

int main() {
    long n, s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        a.insert(s);
    }
    int q;
    cin >> q;
    long aws[200005];
    int shu = 0;
    for (int i = 0; i < q; i++) {
        int c, x, y;
        cin >> c;
        if (c == 1) {
            cin >> x;
            path1(x);
        } else if (c == 2) {
            cin >> x;
            path2(x);
        } else {
            cin >> x >> y;
            aws[shu++] = path3(x, y);
        }
    }
    for (int i = 0; i < shu; i++) {
        cout << aws[i] << endl;
    }
    return 0;
}
子任务 #1
Time Limit Exceeded
得分:75
测试点 #1
Accepted
得分:100
用时:4 ms
内存:1864 KiB

输入文件(test0.in

5
1 2 3 4 5
6
1 6 
3 1 5
1 3
3 1 6
2 6
3 1 6

答案文件(test0.out

15
24
18

用户输出

15
24
18

系统信息

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

输入文件(test1.in

5
5 1 5 10 5
7
1 2
1 6
1 6
2 5
2 1
1 1
3 1 1

答案文件(test1.out

1

用户输出

1

系统信息

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

输入文件(test2.in

2
5 5
2
2 5
3 5 6

答案文件(test2.out

5

用户输出

5

系统信息

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

输入文件(test3.in

2
4 4
7
1 1
2 4
2 4
2 1
1 1
2 1
3 1 5

答案文件(test3.out

0

用户输出

0

系统信息

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

输入文件(test4.in

8
7 1 3 1 9 1 7 6
2
1 9
3 1 3

答案文件(test4.out

6

用户输出

6

系统信息

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

输入文件(test5.in

4
5 7 9 1
4
1 8
1 1
2 1
3 1 6

答案文件(test5.out

6

用户输出

6

系统信息

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

输入文件(test6.in

2
115259423 28253044
1038
2 115259423
2 28253044
1 307475051
2 307475051
1 164468857
2 16446
<15168 bytes omitted>

答案文件(test6.out

0
0
0
0
0
0
0
0
282170305
0
0
0
532750960
0
0
0
259830191
0
0
0
532966501
0
24
<1041 bytes omitted>

用户输出

0
0
0
0
0
0
0
0
282170305
0
0
0
532750960
0
0
0
259830191
0
0
0
532966501
0
24344213
0
0
0
355632176
0
0
0
0
92107170
0
0
940358
<796 bytes omitted>

系统信息

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

输入文件(test7.in

1936
121720261 394635128 416712751 624433516 374594539 55263553 14876291 673696301 168362961 579559
<33031 bytes omitted>

答案文件(test7.out

38488955979
4902851870
224128963441
59302950097
3220318615
345845382705
116690128191
40153461
<2879 bytes omitted>

用户输出

38488955979
4902851870
224128963441
59302950097
3220318615
345845382705
116690128191
401534610437
175011406786
24951864447
92772
<2628 bytes omitted>

系统信息

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

输入文件(test8.in

522
399073417 591762126 550588639 814575747 613274311 164008367 191226799 551009320 256459589 25885
<18849 bytes omitted>

答案文件(test8.out

38180877637
31770380714
19965688052
27189403257
13638663549
24493953427
17720900291
306969433
<2513 bytes omitted>

用户输出

38180877637
31770380714
19965688052
27189403257
13638663549
24493953427
17720900291
30696943399
52385656879
133625136028
6031593
<2278 bytes omitted>

系统信息

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

输入文件(test9.in

554
133526225 896859685 24003797 339292381 276541237 137642212 92629057 2458345 335197501 79370053 
<31159 bytes omitted>

答案文件(test9.out

114072589044
13693727021
50245542258
21803871076
6304729890
10887377944
72731751776
207850772
<4510 bytes omitted>

用户输出

114072589044
13693727021
50245542258
21803871076
6304729890
10887377944
72731751776
20785077212
46634983775
142849474371
1238708
<4111 bytes omitted>

系统信息

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

输入文件(test10.in

38
814483119 395336516 331219657 356069069 65021761 354602593 236429036 747258583 116036251 1485939
<604 bytes omitted>

答案文件(test10.out

1174283405
3428900526
3714456096
421142855
3035163148

用户输出

1174283405
3428900526
3714456096
421142855
3035163148

系统信息

Exited with return code 0
测试点 #12
Time Limit Exceeded
得分:0
用时:2006 ms
内存:4128 KiB

输入文件(test11.in

48162
135422288 321226753 82340641 141819627 546276885 431918731 52269716 242925026 121290427 14443
<2259107 bytes omitted>

答案文件(test11.out

5707342597939
8196901066790
8618661524248
4847553779110
5789337351978
2638600867993
1304841575
<391973 bytes omitted>
测试点 #13
Time Limit Exceeded
得分:0
用时:2050 ms
内存:7040 KiB

输入文件(test12.in

110132
98711952 18771588 104464313 40017 760298345 15968101 40742562 243162271 41807041 11913049 80
<3110071 bytes omitted>

答案文件(test12.out

27909892412904
12782795747100
8052314007188
1553086360891
20439251739839
1217840531261
1318370
<462732 bytes omitted>
测试点 #14
Accepted
得分:100
用时:185 ms
内存:2020 KiB

输入文件(test13.in

1438
841182037 94167954 266760769 297573515 325638721 127872097 687042550 819253621 65774743 931701
<2162775 bytes omitted>

答案文件(test13.out

176284880320
38851829306
10760727510
36933880974
50254246424
15618058636
26578837837
23644934
<180116 bytes omitted>

用户输出

176284880320
38851829306
10760727510
36933880974
50254246424
15618058636
26578837837
236449342091
149697914288
49951775619
73073
<147590 bytes omitted>

系统信息

Exited with return code 0
测试点 #15
Time Limit Exceeded
得分:0
用时:2050 ms
内存:6496 KiB

输入文件(test14.in

98454
382298281 373982896 267712138 200416321 27855981 69938290 680850329 173654113 467811147 34624
<1684079 bytes omitted>

答案文件(test14.out

7338160962500
6316217938350
8964872715714
22127709951049
515902818729
10146308214185
119326116
<167982 bytes omitted>
测试点 #16
Time Limit Exceeded
得分:0
用时:2003 ms
内存:5568 KiB

输入文件(test15.in

79343
24566027 355571281 202018431 62222749 76923149 439775425 433400717 272139655 95674806 1590428
<1630249 bytes omitted>

答案文件(test15.out

12061795430409
1383695185040
4489725526915
20554962987170
3957835634395
7271785264787
24675559
<192980 bytes omitted>