GKH result insist
Posted marigolci
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GKH result insist相关的知识,希望对你有一定的参考价值。
1.H-index
a researcher
at least
h paper h score
input:
T test case
N
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 << ‘ ‘; } }
以上是关于GKH result insist的主要内容,如果未能解决你的问题,请参考以下文章
Android:片段在活动结果合同中未收到 RESULT_OK