UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#192940#851. 公交换乘yzxfatherchy0962ms6608kbC++1.2kb2023-10-13 20:39:132023-10-13 20:39:14

answer

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<int> > records(n, vector<int>(3));
    for (int i = 0; i < n; ++i) {
        cin >> records[i][0] >> records[i][1] >> records[i][2];
    }
    
    int metro_cost = 0;
    int bus_cost = 0;
    int coupons = 0;
    
    for (int i = 0; i < n; ++i) {
        int vehicle_type = records[i][0];
        int price = records[i][1];
        int time = records[i][2];
        
        if (vehicle_type == 0) {  // 地铁
            if (coupons > 0 && time - records[i-1][2] <= 45) {  // 可以使用优惠票
                coupons -= 1;
            } else {  // 需要支付地铁票价
                metro_cost += price;
                coupons = 1;
            }
        }
        
        if (vehicle_type == 1) {  // 公交车
            if (coupons > 0) {  // 可以使用优惠票
                bus_cost += 0;  // 不产生额外费用
                coupons -= 1;
            } else {  // 需要支付公交车票价
                bus_cost += price;
            }
        }
    }
    
    int total_cost = metro_cost + bus_cost;
    cout << total_cost << endl;
    
    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1248kb

input:

100
0 85 6
1 61 35
0 117 44
0 114 45
0 182 47
1 19 48
1 52 49
0 265 838
1 408 866
0 946 867
1 86 872...

output:

19264

result:

wrong answer 1st lines differ - expected: '21240', found: '19264'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 1252kb

input:

200
0 261 132
0 400 161
0 249 197
1 554 202
0 661 203
1 105 204
1 408 205
0 476 543
1 769 553
0 846 ...

output:

41989

result:

wrong answer 1st lines differ - expected: '48175', found: '41989'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

400
0 241 273
0 208 276
1 100 297
1 105 300
1 143 303
1 255 304
1 72 305
0 216 306
1 48 307
1 331 30...

output:

87717

result:

wrong answer 1st lines differ - expected: '99096', found: '87717'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

800
0 278 290
1 234 311
1 29 312
0 953 316
0 460 326
1 421 328
0 701 329
0 776 330
0 108 331
1 504 3...

output:

180171

result:

wrong answer 1st lines differ - expected: '198270', found: '180171'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1296kb

input:

1000
0 139 550
1 167 589
0 123 823
0 93 854
1 123 855
1 159 858
1 3 861
1 6 863
1 94 864
1 189 865
1...

output:

221194

result:

wrong answer 1st lines differ - expected: '251527', found: '221194'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1296kb

input:

1000
0 315 307
0 703 312
1 590 325
1 78 326
1 545 333
1 583 334
1 378 338
1 198 341
1 492 343
1 30 3...

output:

240725

result:

wrong answer 1st lines differ - expected: '275868', found: '240725'

Test #7:

score: 0
Wrong Answer
time: 40ms
memory: 3704kb

input:

50000
0 321 7
0 321 18
0 321 44
0 321 47
1 321 48
0 321 49
1 321 51
0 321 130
1 321 131
0 321 154
1 ...

output:

12148245

result:

wrong answer 1st lines differ - expected: '11524221', found: '12148245'

Test #8:

score: 0
Wrong Answer
time: 57ms
memory: 5552kb

input:

80000
0 334 32
1 334 44
0 334 60
1 334 61
1 334 65
1 334 66
0 334 67
1 334 68
1 334 69
1 334 70
1 33...

output:

20229378

result:

wrong answer 1st lines differ - expected: '19191974', found: '20229378'

Test #9:

score: 0
Wrong Answer
time: 82ms
memory: 6608kb

input:

100000
0 344 63
1 344 83
1 344 93
0 344 100
0 344 101
0 344 103
1 344 104
1 344 105
1 344 106
1 344 ...

output:

26044584

result:

wrong answer 1st lines differ - expected: '24739448', found: '26044584'

Test #10:

score: 0
Wrong Answer
time: 66ms
memory: 5548kb

input:

80000
0 480 4
0 480 18
1 480 37
1 480 47
0 480 48
1 480 49
1 480 51
1 480 52
1 480 55
1 480 56
1 480...

output:

29111520

result:

wrong answer 1st lines differ - expected: '27551040', found: '29111520'

Test #11:

score: 0
Wrong Answer
time: 82ms
memory: 6608kb

input:

100000
0 493 623
1 493 648
1 493 650
1 493 654
1 493 660
1 493 661
1 493 662
0 493 664
1 493 665
1 4...

output:

37315663

result:

wrong answer 1st lines differ - expected: '35354016', found: '37315663'

Test #12:

score: 0
Wrong Answer
time: 80ms
memory: 6604kb

input:

100000
0 503 11
1 503 39
0 503 45
1 503 46
0 503 150
0 503 166
0 503 184
1 503 185
0 503 187
1 503 1...

output:

38055471

result:

wrong answer 1st lines differ - expected: '36149101', found: '38055471'

Test #13:

score: 0
Wrong Answer
time: 69ms
memory: 3704kb

input:

50000
0 377 261
0 552 299
0 182 302
1 5 305
0 385 717
1 51 746
1 653 754
1 182 759
1 715 760
1 563 7...

output:

11551416

result:

wrong answer 1st lines differ - expected: '13038408', found: '11551416'

Test #14:

score: 0
Wrong Answer
time: 40ms
memory: 4496kb

input:

60000
0 367 781
1 144 790
1 362 810
1 689 814
1 556 815
1 622 816
1 676 818
1 34 819
0 444 820
1 584...

output:

13810942

result:

wrong answer 1st lines differ - expected: '15653349', found: '13810942'

Test #15:

score: 0
Wrong Answer
time: 69ms
memory: 5552kb

input:

80000
0 172 798
0 975 801
1 190 828
1 120 830
0 861 836
1 23 839
0 26 875
1 21 881
1 11 883
1 26 903...

output:

18407630

result:

wrong answer 1st lines differ - expected: '20891633', found: '18407630'

Test #16:

score: 0
Wrong Answer
time: 64ms
memory: 5552kb

input:

80000
0 348 6
1 56 21
1 491 25
0 30 27
0 354 31
1 300 34
1 685 37
1 460 38
1 317 39
0 389 40
1 645 4...

output:

18392424

result:

wrong answer 1st lines differ - expected: '20842471', found: '18392424'

Test #17:

score: 0
Wrong Answer
time: 73ms
memory: 6604kb

input:

100000
0 209 815
1 19 826
1 209 848
1 381 852
1 29 853
1 197 854
0 8 855
1 261 856
1 310 857
1 393 8...

output:

23080694

result:

wrong answer 1st lines differ - expected: '26186051', found: '23080694'

Test #18:

score: 0
Wrong Answer
time: 79ms
memory: 6604kb

input:

100000
0 385 31
0 325 60
1 642 64
1 559 71
1 658 73
0 245 80
1 11 103
1 481 121
0 227 967
1 105 999
...

output:

23197729

result:

wrong answer 1st lines differ - expected: '26338428', found: '23197729'

Test #19:

score: 0
Wrong Answer
time: 83ms
memory: 6608kb

input:

100000
0 190 3
1 163 39
1 8 40
1 300 41
0 404 42
1 290 43
1 325 44
1 240 45
1 131 47
0 32 68
0 917 9...

output:

23228581

result:

wrong answer 1st lines differ - expected: '26294656', found: '23228581'

Test #20:

score: 0
Wrong Answer
time: 78ms
memory: 6604kb

input:

100000
0 412 577
0 747 585
1 384 601
1 269 605
1 385 607
1 412 608
0 824 609
1 17 610
1 774 611
0 31...

output:

23008737

result:

wrong answer 1st lines differ - expected: '26064375', found: '23008737'