标签:while names complex upd color namespace temp oid mes
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 << ‘\n‘; } }
标签:while names complex upd color namespace temp oid mes
原文地址:https://www.cnblogs.com/Marigolci/p/12329407.html