码迷,mamicode.com
首页 > 其他好文 > 详细

GKH result insist

时间:2020-02-19 01:18:18      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:while   names   complex   upd   color   namespace   temp   oid   mes   

1.H-index

a researcher 

at least 

h paper h score

input: 

T test case

Ai

output:

thought:

好用的模板:

 

Answer:

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int f[N];

void update(int m, int x) { ++m;
    while (m < N) {
        f[m] += x;
        m += m & -m;
    }
}
int query(int m) { ++m;
    int res = 0;
    while (m > 0) {
        res += f[m];
        m -= m & -m;
    }
    return res;
}
int main() {
    int tc;
    cin >> tc;
    for (int tt = 1; tt <= tc; ++tt) {
        cout << "Case #" << tt << ": ";
        int n;
        cin >> n;
        memset(f, 0, sizeof f);
        for (int j = 0; j < n; ++j) {
            int x;
            cin >> x;
            update(x, 1);
            int bl = 0, br = n + 1;
            while (bl < br - 1) {
                int bm = bl + br >> 1;
                int see = j + 1 - query(bm - 1);
                if (see >= bm) {
                    bl = bm;
                } else {
                    br = bm;
                }
            }    
            cout << bl <<  ;
        }
        cout << \n;
    }
}

 

GKH result insist

标签:while   names   complex   upd   color   namespace   temp   oid   mes   

原文地址:https://www.cnblogs.com/Marigolci/p/12329407.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!