编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#21154 #1022. jwp的排队难题 Accepted 100 100 ms 2264 K C++ 17 / 792 B 自动化82-郭筠陶 2020-01-18 9:42:02
显示原始代码
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
class person {
public:
    int angry, time;
    person(int angry, int time) {
        this->angry = angry;
        this->time = time;
    }
    ~person() {}
    bool operator<(person a) { return this->time * a.angry < this->angry * a.time; }
};

int main() {
    int n;
    cin >> n;
    vector<person> persons;
    for (int i = 0; i < n; i++) {
        int a, t;
        cin >> a >> t;
        persons.push_back(person(a, t));
    }
    sort(persons.begin(), persons.end());
    vector<ull> time;
    ull curTime = 0;
    for (auto curPerson : persons) {
        curTime += curPerson.time;
        time.push_back(curTime);
    }
    ull ans = 0;
    for (int i = 0; i < persons.size(); i++) {
        ans += persons.at(i).angry * time.at(i);
    }
    cout << ans;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:16 ms
内存:1396 KiB

输入文件(1.in

45105
56 94
38 17
45 46
94 65
42 77
4 31
71 51
49 31
82 9
11 62
33 30
50 19
52 61
32 8
<308494 bytes omitted>

答案文件(1.out

1349072953962

用户输出

1349072953962

系统信息

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

输入文件(2.in

6667
81 6
83 71
57 69
97 27
5 84
20 77
28 77
77 57
97 49
40 18
78 39
41 69
14 11
99 1
<45515 bytes omitted>

答案文件(2.out

29669490408

用户输出

29669490408

系统信息

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

输入文件(3.in

55457
60 47
63 7
81 14
91 88
2 83
4 35
80 77
55 46
97 57
65 10
56 14
15 43
88 3
19 62
<379227 bytes omitted>

答案文件(3.out

2046293880925

用户输出

2046293880925

系统信息

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

输入文件(4.in

54839
31 85
77 24
87 83
9 18
35 74
88 40
59 14
47 63
50 31
17 40
1 23
71 10
43 69
24 1
<374961 bytes omitted>

答案文件(4.out

1999020249779

用户输出

1999020249779

系统信息

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

输入文件(5.in

97283
84 38
84 25
91 67
37 41
99 22
8 77
5 20
10 18
56 87
45 93
70 16
27 19
26 93
86 6
<665332 bytes omitted>

答案文件(5.out

6328734044320

用户输出

6328734044320

系统信息

Exited with return code 0