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

Ended

Participants:955

Verdict:Accepted
Score:100 / 100
Submitted:2016-03-06 15:36:19

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<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int N=100005;
ll Q;
ll p[N];
int n;
priority_queue<ll>que;
bool check(int num)
{
    while(que.size())que.pop();
    int x=0;
    ll ans=0;
    int time=1;
    for(int i=0; i<n; i++)
    {
        que.push(p[i]);
        x++;
        if(x==num)
        {
            x--;
            ll k=que.top();
            que.pop();
            ans+=time*k;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX