[Offer收割]编程练习赛1 register

Ended

Participants:955

Verdict:Accepted
Score:100 / 100
Submitted:2016-03-06 14:42:33

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
// head
const int N = 1e5+5;
int a[N];
LL cal(int len, int n) {
    priority_queue<int> q;
    LL cnt = 1;
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        if (q.size() == len) {
            ans += cnt * q.top();
            cnt++;
            q.pop();
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX