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

Ended

Participants:955

Verdict:Accepted
Score:100 / 100
Submitted:2016-03-06 14:39:38

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 <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <string>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
const int N = 5 + 1e5,MOD = 7+1e9;
int n, a[N];
LL Q;
bool check(int k)
{
    if(k > n) return 0;
    LL ans = 0;
    int cnt = 0;
    priority_queue<int,vector<int>,less<int> > q;
    for(int i = 1;i <= k;i ++) q.push(a[i]);
    for(int i = k + 1;i <= n;i ++) {
        ans += 1LL * (++cnt) * q.top();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX