Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p02973
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define pll pair<ll, ll> #define pii pair<int, int> #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define endl '\n' #define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define lb(c, x) distance(c.begin(), lower_bound(all(c), x)) #define ub(c, x) distance(c.begin(), upper_bound(all(c), x)) using namespace std; const ll mod = 1e9 + 7; int main() { ll n; cin >> n; multiset<ll> a; ll ans = 0; rep(i, n) { ll x; cin >> x; auto it = a.lower_bound(x); if (it == a.begin()) { a.insert(x); } else { it--; ll v = *it; a.erase(v); a.insert(x); } } cout << a.size() << endl; return 0; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define pll pair<ll, ll> #define pii pair<int, int> #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define endl '\n' #define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define lb(c, x) distance(c.begin(), lower_bound(all(c), x)) #define ub(c, x) distance(c.begin(), upper_bound(all(c), x)) using namespace std; const ll mod = 1e9 + 7; int main() { ll n; cin >> n; multiset<ll> a; ll ans = 0; rep(i, n) { ll x; cin >> x; auto it = a.lower_bound(x); if (it == a.begin()) { a.insert(x); } else { it--; ll v = *it; a.erase(a.find(v)); a.insert(x); } } cout << a.size() << endl; return 0; }
[ "call.add", "call.arguments.change" ]
780,858
780,859
u882039496
cpp
p02973
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repo(i, n) for (int i = 1; i <= n; i++) #define INF 1001001001 #define INFll 100100100100100 // debug用 #define PrintVec(x) \ for (auto elementPrintVec : x) { \ cout << elementPrintVec << " "; \ } \ cout << endl; using namespace std; using ull = unsigned long long; using ll = long long; using P = pair<int, int>; const int mod = 1000000007; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[n - 1 - i]; } vector<int> dp(n, INF); for (int i = 0; i < n; ++i) { *lower_bound(dp.begin(), dp.end(), a[i]) = a[i]; } int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin(); cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repo(i, n) for (int i = 1; i <= n; i++) #define INF 1001001001 #define INFll 100100100100100 // debug用 #define PrintVec(x) \ for (auto elementPrintVec : x) { \ cout << elementPrintVec << " "; \ } \ cout << endl; using namespace std; using ull = unsigned long long; using ll = long long; using P = pair<int, int>; const int mod = 1000000007; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[n - 1 - i]; } vector<int> dp(n, INF); for (int i = 0; i < n; ++i) { *upper_bound(dp.begin(), dp.end(), a[i]) = a[i]; } int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin(); cout << ans << endl; return 0; }
[ "assignment.variable.change", "identifier.change", "call.function.change" ]
780,863
780,864
u930997891
cpp
p02973
#include <bits/stdc++.h> using namespace std; /***** type *****/ using ll = long long; using ld = long double; template <class T> using vt = vector<T>; template <class T> using vvt = vector<vector<T>>; template <class T> using vvvt = vector<vector<vector<T>>>; template <class T> using uset = unordered_set<T>; template <class T1, class T2> using umap = unordered_map<T1, T2>; /***** define *****/ #define all(c) (c).begin(), (c).end() // begin to end #define coutld cout << fixed << setprecision(10) // cout long double #define rep(i, b, e) for (ll i = b; i < e; i++) // repeat #define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse #define pair NyaaPair // nyaa pair #define first f // pair::first #define second s // pair::second /***** const value *****/ #define llong_max 9223372036854775807 // 9 * 10^18 #define ldbl_max 1.79769e+308 // 1.7 * 10^308 #define pi 3.1415926535897932 // 3.14 ... #define loop_end 9223372036854775806 // LLONG_MAX-1 /***** for each macro *****/ #define fori(i, ...) \ if (ll i = -1) \ for (__VA_ARGS__) \ if (i++, true) #define each(i, e, c) fori(i, auto &e : c) #define forir(i, v, ...) \ if (ll i = (ll)v.size()) \ for (__VA_ARGS__) \ if (i--, true) #define eachr(i, e, c) forir(i, auto e = c.rbegin(); e != c.rend(); ++e) /***** lambda *****/ auto Count = [] // long long count value (auto b, auto e, auto x) { return (ll)count(b, e, x); }; auto CtoN = [] // char to number (auto c) { return (ll)(c - '0'); }; auto CeilD = [] // long double ceiling div (auto a, auto b) { return ceil((ld)a / (ld)b); }; auto Fix = [] // fix value (auto b, auto e, auto fix) { for (auto it = b; it != e; ++it) *it += fix; }; auto NtoC = [] // number to char (auto n) { return (char)('0' + n); }; auto Pow = [] // long long pow (auto a, auto b) { return (ll)pow(a, b); }; auto Pow2 = [] // long long pow2 (auto n) { return (1LL << n); }; auto Pow10 = [] // long long pow10 (auto n) { return (ll)pow(10, n); }; auto Size = [] // long long collection size (auto &c) { return (ll)(c).size(); }; auto Sum = [] // long long accumulate (auto b, auto e) { return accumulate(b, e, 0LL); }; /***** template *****/ template <class T> void MakeVVT(ll ys, ll xs, vvt<T> &v, T fill = T()) { // vector<vector<T>> resize + fill v.resize(ys); rep(y, 0, ys) v[y].resize(xs, fill); } template <class T> void MakeVVVT(ll zs, ll ys, ll xs, vvvt<T> &v, T fill = T()) { // vector<vector<vector<T>>> resize + fill v.resize(zs); rep(z, 0, zs) MakeVVT(ys, xs, v[z], fill); } template <class T> void InputVT(ll xs, vt<T> &v, T fix = T()) { // input vector<T> (T != struct) + fix v.resize(xs); rep(i, 0, xs) { cin >> v[i]; v[i] += fix; } } template <class T> void InputVVT(ll ys, ll xs, vvt<T> &v, T fix = T()) { // input vector<vector<T>> (T != struct) + fix MakeVVT(ys, xs, v, fix); rep(y, 0, ys) rep(x, 0, xs) { cin >> v[y][x]; v[y][x] += fix; } } template <class T> void InputVVVT( ll zs, ll ys, ll xs, vvvt<T> &v, T fix = T()) { // input vector<vector<vector<T>>> (T != struct) + fix v.resize(zs); rep(z, 0, zs) InputVVT(ys, xs, v[z], fix); } template <class T1, class T2> struct NyaaPair { // nyaa pair template T1 f; T2 s; }; template <class T1, class T2> bool operator<(const NyaaPair<T1, T2> &l, const NyaaPair<T1, T2> &r) { // nyaa pair template operator < return (l.f != r.f) ? l.f < r.f : l.s < r.s; } template <class T1, class T2> bool operator>(const NyaaPair<T1, T2> &l, const NyaaPair<T1, T2> &r) { // nyaa pair template operator > return (l.f != r.f) ? l.f > r.f : l.s > r.s; } /**************************************/ /********** BEGIN OF NYA LIB **********/ /**************************************/ namespace NyaGadget {} namespace NyaGadget { /***** 最長減少部分列ライブラリ *****/ template <class T> struct ResultLDS { vector<T> dsub; // 最長減少部分列 vector<vector<T>> isub; // 分解個数最小の増加部分列集合 }; /** @brief 最長減少部分列を返す関数 @param v 入力数列 @param res 出力 @param eq false=狭義減少部分列, true=広義減少部分列 @note 計算量O(NlogN)で最長減少部分列(LDS)が得られる。 内部的には配列vを分解個数が最小になるよう増加部分列集合に分解している。 よって、副産物として分解個数最小の増加部分列集合が得られる。 分解個数最小であり、最長増加部分列でないことに注意。 第三引数についてfalseにすると「狭義減少部分列」「分解個数最小の広義増加部分列集合」 trueにすると「広義減少部分列」「分解個数最小の狭義増加部分列集合」が得られる。 **/ template <class T> void DS_NyaaLDS(const vector<T> &v, ResultLDS<T> &res, bool eq = false) { // Longest Decreasing Subsequence vt<ll> test(v.size() + 1, LLONG_MIN); if (eq) { // 同値を含める、つまり広義減少部分列を得る for (auto &e : v) { auto it = --lower_bound(test.begin(), test.end(), e); if ((long long)res.isub.size() <= (long long)v.size() - distance(test.begin(), it)) res.isub.resize(res.isub.size() + 1); res.isub[(long long)v.size() - distance(test.begin(), it)].push_back(e); *it = e; } } else { // 同値を含めない、つまり狭義減少部分列を得る for (auto &e : v) { auto it = --upper_bound(test.begin(), test.end(), e); if ((long long)res.isub.size() <= (long long)v.size() - distance(test.begin(), it)) res.isub.resize(res.isub.size() + 1); res.isub[(long long)v.size() - distance(test.begin(), it)].push_back(e); *it = e; } } for (auto &e : res.isub) res.dsub.push_back(e.front()); } } // namespace NyaGadget /**************************************/ /*********** END OF NYA LIB ***********/ /**************************************/ using namespace NyaGadget; // using mll = ModLL< 1000000007 >; // using mll = ModLL< 998244353 >; int main(void) { ll N; cin >> N; vt<ll> A; InputVT(N, A); ResultLDS<ll> res; DS_NyaaLDS(A, res, false); cout << Size(res.dsub); return 0; }
#include <bits/stdc++.h> using namespace std; /***** type *****/ using ll = long long; using ld = long double; template <class T> using vt = vector<T>; template <class T> using vvt = vector<vector<T>>; template <class T> using vvvt = vector<vector<vector<T>>>; template <class T> using uset = unordered_set<T>; template <class T1, class T2> using umap = unordered_map<T1, T2>; /***** define *****/ #define all(c) (c).begin(), (c).end() // begin to end #define coutld cout << fixed << setprecision(10) // cout long double #define rep(i, b, e) for (ll i = b; i < e; i++) // repeat #define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse #define pair NyaaPair // nyaa pair #define first f // pair::first #define second s // pair::second /***** const value *****/ #define llong_max 9223372036854775807 // 9 * 10^18 #define ldbl_max 1.79769e+308 // 1.7 * 10^308 #define pi 3.1415926535897932 // 3.14 ... #define loop_end 9223372036854775806 // LLONG_MAX-1 /***** for each macro *****/ #define fori(i, ...) \ if (ll i = -1) \ for (__VA_ARGS__) \ if (i++, true) #define each(i, e, c) fori(i, auto &e : c) #define forir(i, v, ...) \ if (ll i = (ll)v.size()) \ for (__VA_ARGS__) \ if (i--, true) #define eachr(i, e, c) forir(i, auto e = c.rbegin(); e != c.rend(); ++e) /***** lambda *****/ auto Count = [] // long long count value (auto b, auto e, auto x) { return (ll)count(b, e, x); }; auto CtoN = [] // char to number (auto c) { return (ll)(c - '0'); }; auto CeilD = [] // long double ceiling div (auto a, auto b) { return ceil((ld)a / (ld)b); }; auto Fix = [] // fix value (auto b, auto e, auto fix) { for (auto it = b; it != e; ++it) *it += fix; }; auto NtoC = [] // number to char (auto n) { return (char)('0' + n); }; auto Pow = [] // long long pow (auto a, auto b) { return (ll)pow(a, b); }; auto Pow2 = [] // long long pow2 (auto n) { return (1LL << n); }; auto Pow10 = [] // long long pow10 (auto n) { return (ll)pow(10, n); }; auto Size = [] // long long collection size (auto &c) { return (ll)(c).size(); }; auto Sum = [] // long long accumulate (auto b, auto e) { return accumulate(b, e, 0LL); }; /***** template *****/ template <class T> void MakeVVT(ll ys, ll xs, vvt<T> &v, T fill = T()) { // vector<vector<T>> resize + fill v.resize(ys); rep(y, 0, ys) v[y].resize(xs, fill); } template <class T> void MakeVVVT(ll zs, ll ys, ll xs, vvvt<T> &v, T fill = T()) { // vector<vector<vector<T>>> resize + fill v.resize(zs); rep(z, 0, zs) MakeVVT(ys, xs, v[z], fill); } template <class T> void InputVT(ll xs, vt<T> &v, T fix = T()) { // input vector<T> (T != struct) + fix v.resize(xs); rep(i, 0, xs) { cin >> v[i]; v[i] += fix; } } template <class T> void InputVVT(ll ys, ll xs, vvt<T> &v, T fix = T()) { // input vector<vector<T>> (T != struct) + fix MakeVVT(ys, xs, v, fix); rep(y, 0, ys) rep(x, 0, xs) { cin >> v[y][x]; v[y][x] += fix; } } template <class T> void InputVVVT( ll zs, ll ys, ll xs, vvvt<T> &v, T fix = T()) { // input vector<vector<vector<T>>> (T != struct) + fix v.resize(zs); rep(z, 0, zs) InputVVT(ys, xs, v[z], fix); } template <class T1, class T2> struct NyaaPair { // nyaa pair template T1 f; T2 s; }; template <class T1, class T2> bool operator<(const NyaaPair<T1, T2> &l, const NyaaPair<T1, T2> &r) { // nyaa pair template operator < return (l.f != r.f) ? l.f < r.f : l.s < r.s; } template <class T1, class T2> bool operator>(const NyaaPair<T1, T2> &l, const NyaaPair<T1, T2> &r) { // nyaa pair template operator > return (l.f != r.f) ? l.f > r.f : l.s > r.s; } /**************************************/ /********** BEGIN OF NYA LIB **********/ /**************************************/ namespace NyaGadget {} namespace NyaGadget { /***** 最長減少部分列ライブラリ *****/ template <class T> struct ResultLDS { vector<T> dsub; // 最長減少部分列 vector<vector<T>> isub; // 分解個数最小の増加部分列集合 }; /** @brief 最長減少部分列を返す関数 @param v 入力数列 @param res 出力 @param eq false=狭義減少部分列, true=広義減少部分列 @note 計算量O(NlogN)で最長減少部分列(LDS)が得られる。 内部的には配列vを分解個数が最小になるよう増加部分列集合に分解している。 よって、副産物として分解個数最小の増加部分列集合が得られる。 分解個数最小であり、最長増加部分列でないことに注意。 第三引数についてfalseにすると「狭義減少部分列」「分解個数最小の広義増加部分列集合」 trueにすると「広義減少部分列」「分解個数最小の狭義増加部分列集合」が得られる。 **/ template <class T> void DS_NyaaLDS(const vector<T> &v, ResultLDS<T> &res, bool eq = false) { // Longest Decreasing Subsequence vt<ll> test(v.size() + 1, LLONG_MIN); if (eq) { // 同値を含める、つまり広義減少部分列を得る for (auto &e : v) { auto it = --lower_bound(test.begin(), test.end(), e); if ((long long)res.isub.size() <= (long long)v.size() - distance(test.begin(), it)) res.isub.resize(res.isub.size() + 1); res.isub[(long long)v.size() - distance(test.begin(), it)].push_back(e); *it = e; } } else { // 同値を含めない、つまり狭義減少部分列を得る for (auto &e : v) { auto it = --upper_bound(test.begin(), test.end(), e); if ((long long)res.isub.size() <= (long long)v.size() - distance(test.begin(), it)) res.isub.resize(res.isub.size() + 1); res.isub[(long long)v.size() - distance(test.begin(), it)].push_back(e); *it = e; } } for (auto &e : res.isub) res.dsub.push_back(e.front()); } } // namespace NyaGadget /**************************************/ /*********** END OF NYA LIB ***********/ /**************************************/ using namespace NyaGadget; // using mll = ModLL< 1000000007 >; // using mll = ModLL< 998244353 >; int main(void) { ll N; cin >> N; vt<ll> A; InputVT(N, A); ResultLDS<ll> res; DS_NyaaLDS(A, res, true); cout << Size(res.dsub); return 0; }
[ "misc.opposites", "call.arguments.change" ]
780,867
780,868
u153390822
cpp
p02973
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> P; const ll MOD = 1000000007; const ll MAX_N = 500010; const ll INF = 1 << 18; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<ll> b(0); b.push_back(a[n - 1]); for (int i = n - 2; i >= 0; i--) { if (a[i] >= *b.rbegin()) { b.push_back(a[i]); } else { int itr = lower_bound(b.begin(), b.end(), a[i]) - b.begin(); b[itr] = a[i]; } } cout << b.size() << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> P; const ll MOD = 1000000007; const ll MAX_N = 500010; const ll INF = 1 << 18; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<ll> b(0); b.push_back(a[n - 1]); for (int i = n - 2; i >= 0; i--) { if (a[i] >= *b.rbegin()) { b.push_back(a[i]); } else { int itr = upper_bound(b.begin(), b.end(), a[i]) - b.begin(); b[itr] = a[i]; } } cout << b.size() << endl; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
780,876
780,877
u118225776
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define len(v) ll(v.size()) #define fi first #define se second template <class T> void cout_vec(const vector<T> &vec) { for (auto itr : vec) cout << itr << ' '; cout << '\n'; } typedef pair<ll, ll> P; const ll mod = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; multiset<ll> cnt; rep(i, n) { ll a; cin >> a; if (i == 0) { cnt.insert(a); continue; } auto itr = cnt.upper_bound(a); if (itr == begin(cnt)) { cnt.insert(a); continue; } // cout<<' '<<*itr<<endl; itr--; if (*itr >= a) cnt.insert(a); else { cnt.erase(itr); cnt.insert(a); } /* for(auto itr:cnt) cout<<itr<<' '; cout<<endl; */ } cout << len(cnt) << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define len(v) ll(v.size()) #define fi first #define se second template <class T> void cout_vec(const vector<T> &vec) { for (auto itr : vec) cout << itr << ' '; cout << '\n'; } typedef pair<ll, ll> P; const ll mod = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; multiset<ll> cnt; rep(i, n) { ll a; cin >> a; if (i == 0) { cnt.insert(a); continue; } auto itr = cnt.lower_bound(a); if (itr == begin(cnt)) { cnt.insert(a); continue; } // cout<<' '<<*itr<<endl; itr--; if (*itr >= a) cnt.insert(a); else { cnt.erase(itr); cnt.insert(a); } /* for(auto itr:cnt) cout<<itr<<' '; cout<<endl; */ } cout << len(cnt) << endl; }
[ "call.function.change" ]
780,888
780,889
u340010271
cpp
p02973
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> typedef char SINT8; typedef short SINT16; typedef int SINT32; typedef long long SINT64; typedef double DOUBLE; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) #define rep(i, a, b) for (SINT64(i) = SINT64(a); (i) < SINT64(b); (i)++) #define rrep(i, a, b) for (SINT64(i) = SINT64(a); (i) >= SINT64(b); (i)--) #define put(a) cout << (a) << endl #define puts(a) cout << (a) << " " #define putr(a) \ rep(testIncrement, 0, a.size()) { puts(a[testIncrement]); } \ cout << endl #define putrr(a) \ rep(Incr1, 0, a.size()) { \ rep(Incr2, 0, a[Incr1].size()) { puts(a[Incr1][Incr2]); } \ cout << endl; \ } \ cout << endl; #define INF 1000000001 #define MOD 1000000007 #define INF64 1000000000000000001 #define PI (acos(-1)) #define F first #define S second #define Pii pair<SINT32, SINT32> #define Pll pair<SINT64, SINT64> #define Piii pair<SINT32, pair<SINT32, SINT32>> #define Plll pair<SINT64, pair<SINT64, SINT64>> #define Vll(a, b, c) vector<vector<SINT64>> (a)((b),vector<SINT64>((c)) #define Vlll(a, b, c, d) vector<vector<vector<SINT64>>> (a)((b),vector<vector<SINT64>>((c),vector<SINT64>((d))) using namespace std; int main() { SINT64 N; cin >> N; multiset<SINT64> mset; // mset.insert(X); //追加 SINT64 aa; cin >> aa; mset.insert(aa); //追加 rep(i, 1, N) { SINT64 a; cin >> a; mset.insert(a); auto b = mset.find(a); if (b == mset.begin()) { } else { b--; mset.erase(*b); } } put(mset.size()); return 0; } // vector<vector<SINT64>> data(N,vector<SINT64>(N)); ////2次元配列 vector<vector<vector<SINT64>>> //data(N,vector<vector<SINT64>>(N,vector<SINT64>(N))); //3次元配列 // Vll(data,N,N); //2次元配列 // Vlll(data,N,N,N); //3次元配列 // sort(data.begin(),data.end()); // sort(data.begin(),data.end(),std::greater<SINT64>()); // __gcd(A,B); // reverse(data.begin(),data.end()); //関数へのvectorポインタ渡し // void dfs(SINT64 poi, SINT64 d, vector<vector<Pll>>& data) { //} /* 複数条件ソート bool sortcompare(Pll A, Pll B) { if(A.F == B.F){ return A.S > B.S; } else { return A.F < B.F; } } sort(data.begin(),data.end(),sortcompare); */ // タプル // vector<tuple<SINT64,SINT64,SINT64>> edges; // edges.emplace_back(a,b,c); // cout << get<0>(edges[i]); // cout << get<1>(edges[i]); // cout << get<2>(edges[i]); // sort(begin(edges), end(edges)); //ソート // data.emplace_back(BUF); //後ろに追加 // data.erase(std::unique(data.begin(), data.end()), data.end()); // //ソート後に使用 同じ値を消す // data.insert(data.begin() + X, 0); //X番目の要素に0を挿入 // 隣接リスト // vector<vector<SINT64>> data(N); // data[ A ].emplace_back( B ); // 両端キュー // deque<SINT64> data; // data.emplace_front(buf); //先頭挿入 // lower_boundは値がなければ最大値(.size())を返す // posi = lower_bound(data.begin(),data.end(), X) - data.begin(); // // X以上を探す posi = lower_bound(data.begin(),data.end(),make_pair(X,0)) - // data.begin(); //pair /* 文字列回転 string N; cin >> N; N = N[N.length()-1] + N.substr(0,N.length()-1); s = to_string(i); //ストリング変換 */ /* 文字列合成 string N,M; cin >> N >> M; SINT64 ans = 0; ans = stoi(N+M); */ /* 文字列変更 string s; cin >> s; rep(i,0,s.length()) { s[i] = (((s[i]-'A' + N) % 26) + 'A'); } put(s); */ /* //ワーシャルフロイド vector<vector<SINT64>> dist(N,vector<SINT64>(N,INF64)); rep(i,0,N) { dist[i][i] = 0; } rep(k,0,N) { rep(i,0,N) { rep(j,0,N) { dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]); } } } */ /* 優先度付きキュー priority_queue<SINT64, vector<SINT64>, greater<SINT64>> q; //小さいほうから取り出せる priority_queue<SINT64, vector<SINT64>> q; //大きいほうから取り出せる q.push(X); //X を挿入 q.top(); //先頭データ読み q.pop(); //先頭データ削除 */ /* キュー queue<SINT64> q; //宣言 q.push(0); //挿入 q.front(); //先頭データ読み q.pop(); //先頭データ削除 */ /* マルチセット multiset<SINT64> mset; mset.insert(X); //追加 auto it = mset.begin(); //先頭取得 auto it = mset.rbegin(); //最後尾取得 mset.erase(X); //削除(X全部) //削除 1個 auto hit(mset.find(X)); if (hit!= mset.end()) mset.erase(hit); */ /* SET コンテナ set<SINT64> data; data.insert(X); //X を挿入 data.erase(data.begin()); //先頭を削除 data.erase(--data.end()); //末尾を削除 *data.begin(); //先頭要素にアクセス *data.rbegin(); //末尾要素にアクセス //全表示 set<SINT64>::iterator it; //イテレータを用意 for(it = data.begin(); it != data.end(); it++) { cout << *it << " "; } cout << endl; //N番目を一部表示 set<SINT64>::iterator it; // イテレータを用意 it = data.begin(); rep (i,0,N) { it++; } cout << *it << endl; */ /* map map<string,SINT64> mp; for(auto it=mp.begin();it!=mp.end();it++) { mx=max(mx,it->second); } */ /* //順列全表示 //sortしてからでないと全列挙にならない sort(data.begin(),data.end()); do { cout << buf << endl; rep(i,0,R) { cout << data[i] << " "; } cout << endl; } while (next_permutation(data.begin(),data.end())); */ /* bit数数え上げ SINT64 bits64(SINT64 bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } */ // bitシフトのLONG対応 // ans += (1L<<50); /* 余弦定理 2辺 A,B その間の角度からもう1辺を求める long double yogen(long double A, long double B, long double angle) { long double ans = A*A+B*B-A*B*2*cosl((PI/180.0)*angle); ans = sqrt(ans); return ans; } */ // 桁指定表示 // ans = ans * M_PI; // cout << setprecision(15) << ans << endl; // 桁数0埋め // cout << std::setfill('0') << std::right << std::setw(2) << 5; //05 // 2次元累積和 /* vector<vector<SINT64>> data(H,vector<SINT64>(W)); vector<vector<SINT64>> rui(H+1,vector<SINT64>(W+1)); rep(i,0,H) { rep(j,0,W) { cin >> data[i][j]; } } rep(i,1,H+1) { rep(j,1,W+1) { rui[i][j] = data[i-1][j-1] + rui[i][j-1]; } } rep(i,1,H+1) { rep(j,1,W+1) { rui[i][j] += rui[i-1][j]; } } */ // 逆元 コンビネーション /* SINT64 modpow(SINT64 a, SINT64 p) { if (p == 0) return 1; if (p % 2 == 0) { //pが偶数の時 SINT64 halfP = p / 2; SINT64 half = modpow(a, halfP); //a^(p/2) をhalfとして、half*halfを計算 return half * half % MOD; } else { //pが奇数の時は、偶数にするために1減らす return a * modpow(a, p - 1) % MOD; } } SINT64 calcComb(SINT64 a, SINT64 b) { SINT64 Mul = 1; SINT64 Div = 1; SINT64 ans = 0; if (b > a - b) { return calcComb(a, a - b); } rep(i,0,b) { Mul *= (a - i); Div *= (i + 1); Mul %= MOD; Div %= MOD; } ans = Mul * modpow(Div, MOD - 2) % MOD; return ans; } */ /* UNION FIND class UnionFind { public: vector<SINT64> parent; UnionFind(SINT64 N) { parent = vector<SINT64>(N+10, -1); //少し多めに } SINT64 root(SINT64 A) { if (parent[A] < 0) { return A; } else { parent[A] = root(parent[A]); return parent[A]; } } SINT64 size(SINT64 A) { return parent[root(A)] * (-1); } bool judge(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A == B) { return true; //同じグループ } else { return false; //違うグループ } } void connect(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A != B) { if (size(A) < size(B)) { swap(A, B); } parent[A] += parent[B]; parent[B] = A; } } }; UnionFind uni(N); */ /* セグ木 class SegTree { private: SINT64 size; vector<SINT64> node; SINT64 jugdement(SINT64 a, SINT64 b) { SINT64 ans = 0; ans = a+b; return ans; } public: //コンストラクタ SegTree(vector<SINT64> data) { SINT64 ori_size; ori_size = data.size(); size = 1; while (size < ori_size) { size *= 2; } node.resize(2*size-1, 0); rep(i,0,ori_size) { node[size-1+i] = data[i]; } rrep(i,size-2,0) { node[i] = jugdement(node[2*i+1], node[2*i+2]); } } //データ更新 void update(SINT64 x, SINT64 val) { x += (size - 1); node[x] = val+node[x]; while(x > 0) { x = (x - 1) / 2; node[x] = jugdement(node[2*x+1], node[2*x+2]); } } //データ取得 [a,b) SINT64 getdata(SINT64 a, SINT64 b, SINT64 k = 0, SINT64 l = 0, SINT64 r = -1) { if (r < 0) { r = size; } //要求範囲外 if ((r <= a) || (b <= l)) { return 0; } //完全要求区間内 if ((a <= l) && (r <= b)) { return node[k]; } SINT64 vl = getdata(a, b, 2*k+1, l, (l+r)/2); SINT64 vr = getdata(a, b, 2*k+2, (l+r)/2, r); return jugdement(vl, vr); } //表示 void disp() { rep(i,0,size) { puts(node[size-1+i]); } cout << endl; } void alldisp() { SINT64 cnt = 0; SINT64 end = 2; while (1) { puts(node[cnt]); if (cnt == end-2) { end *= 2; cout << endl; } cnt++; if (cnt == size*2-1) { break; } } } }; SegTree seg(N); */ /* 最大フロー最小カット class Dinic { struct EDGE { SINT64 to; SINT64 cap; SINT64 rev; }; vector<vector<EDGE>> G; vector<SINT64> level; vector<SINT64> root; SINT64 N; public: Dinic(SINT64 n) { N = n; G.resize(N); level.resize(N); } void add(SINT64 a, SINT64 b, SINT64 cap) { G[a].emplace_back((EDGE){b,cap,(SINT64)G[b].size()}); G[b].emplace_back((EDGE){a,0,(SINT64)G[a].size()-1}); } void bfs(SINT64 s) { level[s] = 0; queue<SINT64> q; q.push(s); while(q.size() != 0) { SINT64 buf = q.front(); q.pop(); rep(i,0,G[buf].size()) { EDGE now = G[buf][i]; if ((now.cap > 0) && (level[now.to] == -1)) { level[now.to] = level[buf]+1; q.push(now.to); } } } } SINT64 dfs(SINT64 now, SINT64 g, SINT64 flow) { if (now == g) return flow; rep(i,root[now],G[now].size()) { EDGE buf = G[now][i]; root[now] = i; //dsf進捗更新 if ((buf.cap > 0) && (level[buf.to] > level[now])) { SINT64 mi = MIN(buf.cap,flow); SINT64 nowf = dfs(buf.to,g,mi); if (nowf > 0) { G[now][i].cap -= nowf; //順経路に容量削減 G[buf.to][buf.rev].cap += nowf; //逆経路に容量追加 return nowf; //今回探索のFLOW追加数 } } } return 0; } SINT64 act(SINT64 s, SINT64 g) { SINT64 cnt = 0; //最大FLOWカウント if (s == g) return cnt; //スタート=ゴールは例外 while(1) { level.assign(N,-1); //sからの最短距離初期化 root.assign(N,0); //dsf進捗初期化 bfs(s); if (level[g] == -1) break; //gへ到達不可 while(1) { SINT64 flow; flow = dfs(s,g,INF64); if (flow == 0) break; cnt += flow; } } return cnt; } }; */ /* ダイクストラ class Dijkstra { vector<vector<Pll>> G; vector<SINT64> dist; public: Dijkstra(SINT64 n) { G.resize(n); dist.resize(n, INF64); } void add(SINT64 a, SINT64 b, SINT64 cost) { G[a].emplace_back(Pll(b,cost)); } void clear(SINT64 n) { dist.resize(0); dist.resize(n,INF64); } void form(SINT64 s) { priority_queue<Pll, vector<Pll>, greater<Pll>> q; q.push(Pll(0,s)); //cost,位置 while(q.size() != 0) { Pll now = q.top(); q.pop(); if (dist[now.S] == INF64) { dist[now.S] = now.F; rep(i,0,G[now.S].size()) { Pll buf = G[now.S][i]; if (dist[buf.F] == INF64) { q.push(Pll(buf.S+now.F,buf.F)); } } } } } //form()で構築したsからの距離を返す SINT64 get_dist(SINT64 a) { if (dist[a] == INF64) { return -1; //到達不可 } else { return dist[a]; } } }; */ /* LCA class Lca { vector<vector<SINT64>> G; vector<vector<SINT64>> D; //ダブリング vector<SINT64> depth; SINT64 N; SINT64 LOG_N; public: Lca(SINT64 n) { N = n; LOG_N = floor(log2(N)); G.resize(N); D.resize(N); depth.resize(N,-1); } void add(SINT64 a, SINT64 b) { G[a].emplace_back(b); G[b].emplace_back(a); } void bfs(SINT64 s) { depth[s] = 0; D[s].emplace_back(-1); queue<SINT64> q; q.push(s); while(q.size() != 0) { SINT64 now = q.front(); q.pop(); rep(i,0,G[now].size()) { SINT64 next = G[now][i]; if (depth[next] == -1) { depth[next] = depth[now]+1; D[next].emplace_back(now); q.push(next); } } } } //頂点のsからのダブリング構築 void form(SINT64 s) { bfs(s); rep(i,1,LOG_N+1) { rep(j,0,N) { SINT64 buf = D[j][i-1]; if (buf == -1) { D[j].emplace_back(-1); } else { D[j].emplace_back(D[buf][i-1]); } } } } //aのx上の頂点を求める SINT64 get(SINT64 a, SINT64 x) { rrep(i,LOG_N,0) { if (((x >> i) & 1) == 1) { a = D[a][i]; if (a == -1) return -1; } } return a; } //aとbの共通祖先を求める SINT64 get_lca(SINT64 a, SINT64 b) { if (depth[a] < depth[b]) swap(a,b); SINT64 diff = depth[a] - depth[b]; a = get(a,diff); //aのx上の頂点を求める if (a == b) return a; rrep(i,LOG_N,0) { if (D[a][i] != D[b][i]) { a = D[a][i]; b = D[b][i]; } } return D[a][0]; } //aとbの共通祖先までの距離の合計を求める SINT64 get_dist(SINT64 a, SINT64 b) { SINT64 buf = get_lca(a,b); return depth[a] + depth[b] - depth[buf]*2; } }; */ /* ベルマンフォード class Bellman { struct EDGE { SINT64 from; SINT64 to; SINT64 cost; }; vector<EDGE> edges; vector<SINT64> dist; SINT64 N; public: Bellman(SINT64 n) { N = n; dist.resize(n, INF64); } void add(SINT64 from, SINT64 to, SINT64 cost) { edges.emplace_back((EDGE){from,to,cost}); } //sで構築したt迄の距離取得 SINT64 get_dist(SINT64 t) { //到達不可はINF64 return dist[t]; } //構築 //負の閉路無し : 0 //負の閉路有り : 1 //負の閉路有るが目的地gの更新は停止 : 2 SINT64 form(SINT64 s, SINT64 g) { dist[s] = 0; SINT64 cnt = 0; SINT64 check = 0; while(1) { SINT64 renew = 0; rep(i,0,edges.size()) { EDGE e = edges[i]; if (dist[e.from] != INF64) { if (dist[e.to] > dist[e.from] + e.cost) { renew = 1; dist[e.to] = dist[e.from] + e.cost; } } } if (renew == 0) return 0; //N回更新後のgの距離と 2N回更新後のgの距離を比較 if (cnt == N) check = dist[g]; if (cnt > 2*N) { if (check == dist[g]) return 2; return 1; } cnt++; } } }; */ /*コンビネーション class Comb { vector<SINT64> base; SINT64 N; public: Comb (SINT64 n) { N = n+5; base.resize(N); base[0] = 1; rep(i,1,N) { base[i] = base[i-1]*i; base[i] %= MOD; } } SINT64 get_comb(SINT64 a, SINT64 b) { SINT64 ans = 0; SINT64 aa = base[a] * modpow(base[a-b], MOD - 2) % MOD; ans = aa * modpow(base[b], MOD - 2) % MOD; return ans; } SINT64 modpow(SINT64 a, SINT64 p) { if (p == 0) return 1; if (p % 2 == 0) { SINT64 halfP = p / 2; SINT64 half = modpow(a, halfP); return half * half % MOD; } else { return a * modpow(a, p - 1) % MOD; } } }; */ /* SUFFIX ARRAY class SuffixArray { private: vector<string> array; // サフィックスアレイ vector<SINT64> lcp; // LCP vector<SINT64> sais; // SA IS string str; public: // コンストラクタ SuffixArray (string s) { str = s; vector<SINT64> Vstr; rep(i,0,str.length()) { Vstr.emplace_back(str[i]); } sais_act(Vstr, sais, 255); // SAIS実行 // lcp_act(); // 隣り合うSUFFIXの先頭から同じ長さを算出 // suffix array 文字列作成 // array.resize(str.length()); // rep(i,0,array.size()) { // array[i] = str.substr(sais[i]); // } // rep(i,0,array.size()) {put(array[i]);} // 表示用 } // LCP作成 void lcp_act(void) { lcp.resize(str.length()); vector<SINT64> buffer(str.length()); rep(i,0,str.length()) { buffer[sais[i]] = i; } SINT64 cnt = 0; rep(i,0,str.length()) { if (buffer[i] >= str.length()-1) { cnt = 0; } else { SINT64 a = buffer[i]; SINT64 b = buffer[i]+1; while(1) { if (cnt >= str.length() - sais[a]) break; if (cnt >= str.length() - sais[a]) break; if (str[sais[a]+cnt] == str[sais[b]+cnt]) { cnt++; } else { break; } } } lcp[buffer[i]] = cnt; if (cnt != 0) cnt--; } } // 引数の文字列が何個含まれるか算出 SINT64 get_cnt(string t) { SINT64 low,high; SINT64 L,R; L = -1; R = str.length(); while(R-L > 1) { SINT64 M = (R+L)/2; string buf = str.substr(sais[M]); if (buf.length() > t.length()) { buf = buf.substr(0,t.length()); } if (buf > t) {R = M;} else {L = M;} } high = R; L = -1; R = str.length(); while(R-L > 1) { SINT64 M = (R+L)/2; string buf = str.substr(sais[M]); if (buf >= t) {R = M;} else {L = M;} } low = R; return high - low; } // SAIS実行 void sais_act(vector<SINT64>& Vstr, vector<SINT64>& r_sais, SINT64 type) { Vstr.push_back(0); // 番兵追加 vector<SINT64> lms_seed; // LMS ソート前 vector<SINT64> lms_sort; // LMS ソート後 vector<SINT64> lms_long(Vstr.size(),0); // LMS 長さ vector<SINT64> lms_type(Vstr.size(),1); // 0:L 1:S 2:LMS vector<SINT64> lms_posi(Vstr.size(),-1); // LMS内での位置 SINT64 len = 0; // L S LMS判定 初期値は全てS rrep(i,Vstr.size()-2,0) { len++; if (Vstr[i] > Vstr[i+1]) { lms_type[i] = 0; // L if (lms_type[i+1] == 1) { lms_type[i+1] = 2; // LMS lms_long[i+1] = len; // LMSの長さ格納 len = 1; } } if (Vstr[i] == Vstr[i+1]) lms_type[i] = lms_type[i+1]; // 右と同じ } SINT64 cnt = 0; rep(i,0,Vstr.size()) { if (lms_type[i] == 2) lms_seed.emplace_back(i); if (lms_type[i] == 2) lms_posi[i] = cnt++; } // Induced Sort初回 vector<SINT64> bucket; // Induced Sort初回結果格納用 induced_sort(Vstr, lms_seed, bucket, lms_type, type); // lms_sortにLMSのソートを格納 rrep(i,Vstr.size()-1,0) { if ((bucket[i] != -1) && (lms_type[bucket[i]] == 2)) { lms_sort.emplace_back(bucket[i]); } } SINT64 ok = 0; // 再帰必要性判定 SINT64 rank = 1; // 再帰用文字 vector<SINT64> next(lms_sort.size(), 1); // 再帰用文字列 rrep(i,lms_sort.size()-2,0) { SINT64 A = lms_long[lms_sort[i]]; SINT64 B = lms_long[lms_sort[i+1]]; if (A == B) { SINT64 ck = 0; rep(j,0,A) { if (Vstr[lms_sort[i]+j] != Vstr[lms_sort[i+1]+j]) { ck = 1; break; } } if (ck == 0) { ok = 1; // 再帰必要 } else { rank++; } } else { rank++; } next[lms_posi[lms_sort[i]]] = rank; } if (ok == 1) { vector<SINT64> recursive; sais_act(next, recursive, rank+1); rep(i,0,recursive.size()) { lms_sort[recursive.size()-i-1] = lms_seed[recursive[i]]; } } // SORT済みLMSでInduced Sorting r_sais.resize(Vstr.size(),-1); induced_sort(Vstr, lms_sort, r_sais, lms_type, type); r_sais.erase(r_sais.begin()); // 番兵削除 } // induced_sort void induced_sort(vector<SINT64>& Vstr, vector<SINT64>& seed, vector<SINT64>& bucket_sort, vector<SINT64>& lms_type, SINT64 type) { vector<SINT64> bucket_cnt(type,0); // バケット 文字種ごとの数 vector<SINT64> bucket_st(type,0); // バケット 文字種の開始位置 vector<SINT64> bucket_end(type,0); // バケット 文字種の終了位置 vector<SINT64> bucket_pre(Vstr.size(),-1); // バケット 初回格納用 vector<SINT64> cnt1(type,0); vector<SINT64> cnt2(type,0); vector<SINT64> cnt3(type,0); bucket_sort.resize(Vstr.size(),-1); // バケットソート位置作成 rep(i,0,Vstr.size()) bucket_cnt[Vstr[i]]++; // 個数作成 rep(i,1,type) bucket_st[i] = bucket_st[i-1] + bucket_cnt[i-1]; // 開始位置 rep(i,0,type) bucket_end[i] = bucket_st[i] + bucket_cnt[i]-1; // 終了位置 // LMSをbucket_preに格納 rep(i,0,seed.size()) { SINT64 no = seed[i]; bucket_pre[bucket_end[Vstr[no]] - cnt1[Vstr[no]]] = no; cnt1[Vstr[no]]++; } // Lをbucket_sortに格納 rep(i,0,Vstr.size()) { if ((bucket_pre[i] != -1) && (bucket_pre[i] != 0)) { if (lms_type[bucket_pre[i]-1] == 0) { // -1がLの場合 SINT64 buf = Vstr[bucket_pre[i]-1]; bucket_pre [bucket_st[buf] + cnt2[buf]] = bucket_pre[i]-1; bucket_sort[bucket_st[buf] + cnt2[buf]] = bucket_pre[i]-1; cnt2[buf]++; } } } // Sをbucket_sortに格納 bucket_sort[0] = Vstr.size()-1; // 番兵追加 rrep(i,Vstr.size()-1,0) { if ((bucket_sort[i] != -1) && (bucket_sort[i] != 0)) { if (lms_type[bucket_sort[i]-1] != 0) { // -1がS(LMS)の場合 SINT64 buf = Vstr[bucket_sort[i]-1]; bucket_sort[bucket_end[buf] - cnt3[buf]] = bucket_sort[i]-1; cnt3[buf]++; } } } } }; */ /* 転倒数の数え上げ SINT64 merge_cnt(vector<SINT64> &a) { SINT64 n = a.size(); if (n <= 1) { return 0; } SINT64 cnt = 0; vector<SINT64> b(a.begin(), a.begin()+n/2); vector<SINT64> c(a.begin()+n/2, a.end()); cnt += merge_cnt(b); cnt += merge_cnt(c); SINT64 ai = 0, bi = 0, ci = 0; // merge の処理 while (ai < n) { if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) { a[ai++] = b[bi++]; } else { cnt += n / 2 - bi; a[ai++] = c[ci++]; } } return cnt; } */ /* 最長部分文字列 SINT64 LCS(string s, string t) { SINT64 n = s.size(); SINT64 m = t.size(); vector<vector<SINT64>> DP(n+1,vector<SINT64>(m+1,0)); rep(i,0,n) { rep(j,0,m) { if (s[i] == t[j]) { DP[i+1][j+1] = DP[i][j]+1; } else { DP[i+1][j+1] = MAX(DP[i+1][j],DP[i][j+1]); } } } return DP[n][m]; } */
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> typedef char SINT8; typedef short SINT16; typedef int SINT32; typedef long long SINT64; typedef double DOUBLE; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) #define rep(i, a, b) for (SINT64(i) = SINT64(a); (i) < SINT64(b); (i)++) #define rrep(i, a, b) for (SINT64(i) = SINT64(a); (i) >= SINT64(b); (i)--) #define put(a) cout << (a) << endl #define puts(a) cout << (a) << " " #define putr(a) \ rep(testIncrement, 0, a.size()) { puts(a[testIncrement]); } \ cout << endl #define putrr(a) \ rep(Incr1, 0, a.size()) { \ rep(Incr2, 0, a[Incr1].size()) { puts(a[Incr1][Incr2]); } \ cout << endl; \ } \ cout << endl; #define INF 1000000001 #define MOD 1000000007 #define INF64 1000000000000000001 #define PI (acos(-1)) #define F first #define S second #define Pii pair<SINT32, SINT32> #define Pll pair<SINT64, SINT64> #define Piii pair<SINT32, pair<SINT32, SINT32>> #define Plll pair<SINT64, pair<SINT64, SINT64>> #define Vll(a, b, c) vector<vector<SINT64>> (a)((b),vector<SINT64>((c)) #define Vlll(a, b, c, d) vector<vector<vector<SINT64>>> (a)((b),vector<vector<SINT64>>((c),vector<SINT64>((d))) using namespace std; int main() { SINT64 N; cin >> N; multiset<SINT64> mset; // mset.insert(X); //追加 SINT64 aa; cin >> aa; mset.insert(aa); //追加 rep(i, 1, N) { SINT64 a; cin >> a; mset.insert(a); auto b = mset.find(a); if (b == mset.begin()) { } else { b--; mset.erase(b); } } put(mset.size()); return 0; } // vector<vector<SINT64>> data(N,vector<SINT64>(N)); ////2次元配列 vector<vector<vector<SINT64>>> //data(N,vector<vector<SINT64>>(N,vector<SINT64>(N))); //3次元配列 // Vll(data,N,N); //2次元配列 // Vlll(data,N,N,N); //3次元配列 // sort(data.begin(),data.end()); // sort(data.begin(),data.end(),std::greater<SINT64>()); // __gcd(A,B); // reverse(data.begin(),data.end()); //関数へのvectorポインタ渡し // void dfs(SINT64 poi, SINT64 d, vector<vector<Pll>>& data) { //} /* 複数条件ソート bool sortcompare(Pll A, Pll B) { if(A.F == B.F){ return A.S > B.S; } else { return A.F < B.F; } } sort(data.begin(),data.end(),sortcompare); */ // タプル // vector<tuple<SINT64,SINT64,SINT64>> edges; // edges.emplace_back(a,b,c); // cout << get<0>(edges[i]); // cout << get<1>(edges[i]); // cout << get<2>(edges[i]); // sort(begin(edges), end(edges)); //ソート // data.emplace_back(BUF); //後ろに追加 // data.erase(std::unique(data.begin(), data.end()), data.end()); // //ソート後に使用 同じ値を消す // data.insert(data.begin() + X, 0); //X番目の要素に0を挿入 // 隣接リスト // vector<vector<SINT64>> data(N); // data[ A ].emplace_back( B ); // 両端キュー // deque<SINT64> data; // data.emplace_front(buf); //先頭挿入 // lower_boundは値がなければ最大値(.size())を返す // posi = lower_bound(data.begin(),data.end(), X) - data.begin(); // // X以上を探す posi = lower_bound(data.begin(),data.end(),make_pair(X,0)) - // data.begin(); //pair /* 文字列回転 string N; cin >> N; N = N[N.length()-1] + N.substr(0,N.length()-1); s = to_string(i); //ストリング変換 */ /* 文字列合成 string N,M; cin >> N >> M; SINT64 ans = 0; ans = stoi(N+M); */ /* 文字列変更 string s; cin >> s; rep(i,0,s.length()) { s[i] = (((s[i]-'A' + N) % 26) + 'A'); } put(s); */ /* //ワーシャルフロイド vector<vector<SINT64>> dist(N,vector<SINT64>(N,INF64)); rep(i,0,N) { dist[i][i] = 0; } rep(k,0,N) { rep(i,0,N) { rep(j,0,N) { dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]); } } } */ /* 優先度付きキュー priority_queue<SINT64, vector<SINT64>, greater<SINT64>> q; //小さいほうから取り出せる priority_queue<SINT64, vector<SINT64>> q; //大きいほうから取り出せる q.push(X); //X を挿入 q.top(); //先頭データ読み q.pop(); //先頭データ削除 */ /* キュー queue<SINT64> q; //宣言 q.push(0); //挿入 q.front(); //先頭データ読み q.pop(); //先頭データ削除 */ /* マルチセット multiset<SINT64> mset; mset.insert(X); //追加 auto it = mset.begin(); //先頭取得 auto it = mset.rbegin(); //最後尾取得 mset.erase(X); //削除(X全部) //削除 1個 auto hit(mset.find(X)); if (hit!= mset.end()) mset.erase(hit); */ /* SET コンテナ set<SINT64> data; data.insert(X); //X を挿入 data.erase(data.begin()); //先頭を削除 data.erase(--data.end()); //末尾を削除 *data.begin(); //先頭要素にアクセス *data.rbegin(); //末尾要素にアクセス //全表示 set<SINT64>::iterator it; //イテレータを用意 for(it = data.begin(); it != data.end(); it++) { cout << *it << " "; } cout << endl; //N番目を一部表示 set<SINT64>::iterator it; // イテレータを用意 it = data.begin(); rep (i,0,N) { it++; } cout << *it << endl; */ /* map map<string,SINT64> mp; for(auto it=mp.begin();it!=mp.end();it++) { mx=max(mx,it->second); } */ /* //順列全表示 //sortしてからでないと全列挙にならない sort(data.begin(),data.end()); do { cout << buf << endl; rep(i,0,R) { cout << data[i] << " "; } cout << endl; } while (next_permutation(data.begin(),data.end())); */ /* bit数数え上げ SINT64 bits64(SINT64 bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } */ // bitシフトのLONG対応 // ans += (1L<<50); /* 余弦定理 2辺 A,B その間の角度からもう1辺を求める long double yogen(long double A, long double B, long double angle) { long double ans = A*A+B*B-A*B*2*cosl((PI/180.0)*angle); ans = sqrt(ans); return ans; } */ // 桁指定表示 // ans = ans * M_PI; // cout << setprecision(15) << ans << endl; // 桁数0埋め // cout << std::setfill('0') << std::right << std::setw(2) << 5; //05 // 2次元累積和 /* vector<vector<SINT64>> data(H,vector<SINT64>(W)); vector<vector<SINT64>> rui(H+1,vector<SINT64>(W+1)); rep(i,0,H) { rep(j,0,W) { cin >> data[i][j]; } } rep(i,1,H+1) { rep(j,1,W+1) { rui[i][j] = data[i-1][j-1] + rui[i][j-1]; } } rep(i,1,H+1) { rep(j,1,W+1) { rui[i][j] += rui[i-1][j]; } } */ // 逆元 コンビネーション /* SINT64 modpow(SINT64 a, SINT64 p) { if (p == 0) return 1; if (p % 2 == 0) { //pが偶数の時 SINT64 halfP = p / 2; SINT64 half = modpow(a, halfP); //a^(p/2) をhalfとして、half*halfを計算 return half * half % MOD; } else { //pが奇数の時は、偶数にするために1減らす return a * modpow(a, p - 1) % MOD; } } SINT64 calcComb(SINT64 a, SINT64 b) { SINT64 Mul = 1; SINT64 Div = 1; SINT64 ans = 0; if (b > a - b) { return calcComb(a, a - b); } rep(i,0,b) { Mul *= (a - i); Div *= (i + 1); Mul %= MOD; Div %= MOD; } ans = Mul * modpow(Div, MOD - 2) % MOD; return ans; } */ /* UNION FIND class UnionFind { public: vector<SINT64> parent; UnionFind(SINT64 N) { parent = vector<SINT64>(N+10, -1); //少し多めに } SINT64 root(SINT64 A) { if (parent[A] < 0) { return A; } else { parent[A] = root(parent[A]); return parent[A]; } } SINT64 size(SINT64 A) { return parent[root(A)] * (-1); } bool judge(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A == B) { return true; //同じグループ } else { return false; //違うグループ } } void connect(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A != B) { if (size(A) < size(B)) { swap(A, B); } parent[A] += parent[B]; parent[B] = A; } } }; UnionFind uni(N); */ /* セグ木 class SegTree { private: SINT64 size; vector<SINT64> node; SINT64 jugdement(SINT64 a, SINT64 b) { SINT64 ans = 0; ans = a+b; return ans; } public: //コンストラクタ SegTree(vector<SINT64> data) { SINT64 ori_size; ori_size = data.size(); size = 1; while (size < ori_size) { size *= 2; } node.resize(2*size-1, 0); rep(i,0,ori_size) { node[size-1+i] = data[i]; } rrep(i,size-2,0) { node[i] = jugdement(node[2*i+1], node[2*i+2]); } } //データ更新 void update(SINT64 x, SINT64 val) { x += (size - 1); node[x] = val+node[x]; while(x > 0) { x = (x - 1) / 2; node[x] = jugdement(node[2*x+1], node[2*x+2]); } } //データ取得 [a,b) SINT64 getdata(SINT64 a, SINT64 b, SINT64 k = 0, SINT64 l = 0, SINT64 r = -1) { if (r < 0) { r = size; } //要求範囲外 if ((r <= a) || (b <= l)) { return 0; } //完全要求区間内 if ((a <= l) && (r <= b)) { return node[k]; } SINT64 vl = getdata(a, b, 2*k+1, l, (l+r)/2); SINT64 vr = getdata(a, b, 2*k+2, (l+r)/2, r); return jugdement(vl, vr); } //表示 void disp() { rep(i,0,size) { puts(node[size-1+i]); } cout << endl; } void alldisp() { SINT64 cnt = 0; SINT64 end = 2; while (1) { puts(node[cnt]); if (cnt == end-2) { end *= 2; cout << endl; } cnt++; if (cnt == size*2-1) { break; } } } }; SegTree seg(N); */ /* 最大フロー最小カット class Dinic { struct EDGE { SINT64 to; SINT64 cap; SINT64 rev; }; vector<vector<EDGE>> G; vector<SINT64> level; vector<SINT64> root; SINT64 N; public: Dinic(SINT64 n) { N = n; G.resize(N); level.resize(N); } void add(SINT64 a, SINT64 b, SINT64 cap) { G[a].emplace_back((EDGE){b,cap,(SINT64)G[b].size()}); G[b].emplace_back((EDGE){a,0,(SINT64)G[a].size()-1}); } void bfs(SINT64 s) { level[s] = 0; queue<SINT64> q; q.push(s); while(q.size() != 0) { SINT64 buf = q.front(); q.pop(); rep(i,0,G[buf].size()) { EDGE now = G[buf][i]; if ((now.cap > 0) && (level[now.to] == -1)) { level[now.to] = level[buf]+1; q.push(now.to); } } } } SINT64 dfs(SINT64 now, SINT64 g, SINT64 flow) { if (now == g) return flow; rep(i,root[now],G[now].size()) { EDGE buf = G[now][i]; root[now] = i; //dsf進捗更新 if ((buf.cap > 0) && (level[buf.to] > level[now])) { SINT64 mi = MIN(buf.cap,flow); SINT64 nowf = dfs(buf.to,g,mi); if (nowf > 0) { G[now][i].cap -= nowf; //順経路に容量削減 G[buf.to][buf.rev].cap += nowf; //逆経路に容量追加 return nowf; //今回探索のFLOW追加数 } } } return 0; } SINT64 act(SINT64 s, SINT64 g) { SINT64 cnt = 0; //最大FLOWカウント if (s == g) return cnt; //スタート=ゴールは例外 while(1) { level.assign(N,-1); //sからの最短距離初期化 root.assign(N,0); //dsf進捗初期化 bfs(s); if (level[g] == -1) break; //gへ到達不可 while(1) { SINT64 flow; flow = dfs(s,g,INF64); if (flow == 0) break; cnt += flow; } } return cnt; } }; */ /* ダイクストラ class Dijkstra { vector<vector<Pll>> G; vector<SINT64> dist; public: Dijkstra(SINT64 n) { G.resize(n); dist.resize(n, INF64); } void add(SINT64 a, SINT64 b, SINT64 cost) { G[a].emplace_back(Pll(b,cost)); } void clear(SINT64 n) { dist.resize(0); dist.resize(n,INF64); } void form(SINT64 s) { priority_queue<Pll, vector<Pll>, greater<Pll>> q; q.push(Pll(0,s)); //cost,位置 while(q.size() != 0) { Pll now = q.top(); q.pop(); if (dist[now.S] == INF64) { dist[now.S] = now.F; rep(i,0,G[now.S].size()) { Pll buf = G[now.S][i]; if (dist[buf.F] == INF64) { q.push(Pll(buf.S+now.F,buf.F)); } } } } } //form()で構築したsからの距離を返す SINT64 get_dist(SINT64 a) { if (dist[a] == INF64) { return -1; //到達不可 } else { return dist[a]; } } }; */ /* LCA class Lca { vector<vector<SINT64>> G; vector<vector<SINT64>> D; //ダブリング vector<SINT64> depth; SINT64 N; SINT64 LOG_N; public: Lca(SINT64 n) { N = n; LOG_N = floor(log2(N)); G.resize(N); D.resize(N); depth.resize(N,-1); } void add(SINT64 a, SINT64 b) { G[a].emplace_back(b); G[b].emplace_back(a); } void bfs(SINT64 s) { depth[s] = 0; D[s].emplace_back(-1); queue<SINT64> q; q.push(s); while(q.size() != 0) { SINT64 now = q.front(); q.pop(); rep(i,0,G[now].size()) { SINT64 next = G[now][i]; if (depth[next] == -1) { depth[next] = depth[now]+1; D[next].emplace_back(now); q.push(next); } } } } //頂点のsからのダブリング構築 void form(SINT64 s) { bfs(s); rep(i,1,LOG_N+1) { rep(j,0,N) { SINT64 buf = D[j][i-1]; if (buf == -1) { D[j].emplace_back(-1); } else { D[j].emplace_back(D[buf][i-1]); } } } } //aのx上の頂点を求める SINT64 get(SINT64 a, SINT64 x) { rrep(i,LOG_N,0) { if (((x >> i) & 1) == 1) { a = D[a][i]; if (a == -1) return -1; } } return a; } //aとbの共通祖先を求める SINT64 get_lca(SINT64 a, SINT64 b) { if (depth[a] < depth[b]) swap(a,b); SINT64 diff = depth[a] - depth[b]; a = get(a,diff); //aのx上の頂点を求める if (a == b) return a; rrep(i,LOG_N,0) { if (D[a][i] != D[b][i]) { a = D[a][i]; b = D[b][i]; } } return D[a][0]; } //aとbの共通祖先までの距離の合計を求める SINT64 get_dist(SINT64 a, SINT64 b) { SINT64 buf = get_lca(a,b); return depth[a] + depth[b] - depth[buf]*2; } }; */ /* ベルマンフォード class Bellman { struct EDGE { SINT64 from; SINT64 to; SINT64 cost; }; vector<EDGE> edges; vector<SINT64> dist; SINT64 N; public: Bellman(SINT64 n) { N = n; dist.resize(n, INF64); } void add(SINT64 from, SINT64 to, SINT64 cost) { edges.emplace_back((EDGE){from,to,cost}); } //sで構築したt迄の距離取得 SINT64 get_dist(SINT64 t) { //到達不可はINF64 return dist[t]; } //構築 //負の閉路無し : 0 //負の閉路有り : 1 //負の閉路有るが目的地gの更新は停止 : 2 SINT64 form(SINT64 s, SINT64 g) { dist[s] = 0; SINT64 cnt = 0; SINT64 check = 0; while(1) { SINT64 renew = 0; rep(i,0,edges.size()) { EDGE e = edges[i]; if (dist[e.from] != INF64) { if (dist[e.to] > dist[e.from] + e.cost) { renew = 1; dist[e.to] = dist[e.from] + e.cost; } } } if (renew == 0) return 0; //N回更新後のgの距離と 2N回更新後のgの距離を比較 if (cnt == N) check = dist[g]; if (cnt > 2*N) { if (check == dist[g]) return 2; return 1; } cnt++; } } }; */ /*コンビネーション class Comb { vector<SINT64> base; SINT64 N; public: Comb (SINT64 n) { N = n+5; base.resize(N); base[0] = 1; rep(i,1,N) { base[i] = base[i-1]*i; base[i] %= MOD; } } SINT64 get_comb(SINT64 a, SINT64 b) { SINT64 ans = 0; SINT64 aa = base[a] * modpow(base[a-b], MOD - 2) % MOD; ans = aa * modpow(base[b], MOD - 2) % MOD; return ans; } SINT64 modpow(SINT64 a, SINT64 p) { if (p == 0) return 1; if (p % 2 == 0) { SINT64 halfP = p / 2; SINT64 half = modpow(a, halfP); return half * half % MOD; } else { return a * modpow(a, p - 1) % MOD; } } }; */ /* SUFFIX ARRAY class SuffixArray { private: vector<string> array; // サフィックスアレイ vector<SINT64> lcp; // LCP vector<SINT64> sais; // SA IS string str; public: // コンストラクタ SuffixArray (string s) { str = s; vector<SINT64> Vstr; rep(i,0,str.length()) { Vstr.emplace_back(str[i]); } sais_act(Vstr, sais, 255); // SAIS実行 // lcp_act(); // 隣り合うSUFFIXの先頭から同じ長さを算出 // suffix array 文字列作成 // array.resize(str.length()); // rep(i,0,array.size()) { // array[i] = str.substr(sais[i]); // } // rep(i,0,array.size()) {put(array[i]);} // 表示用 } // LCP作成 void lcp_act(void) { lcp.resize(str.length()); vector<SINT64> buffer(str.length()); rep(i,0,str.length()) { buffer[sais[i]] = i; } SINT64 cnt = 0; rep(i,0,str.length()) { if (buffer[i] >= str.length()-1) { cnt = 0; } else { SINT64 a = buffer[i]; SINT64 b = buffer[i]+1; while(1) { if (cnt >= str.length() - sais[a]) break; if (cnt >= str.length() - sais[a]) break; if (str[sais[a]+cnt] == str[sais[b]+cnt]) { cnt++; } else { break; } } } lcp[buffer[i]] = cnt; if (cnt != 0) cnt--; } } // 引数の文字列が何個含まれるか算出 SINT64 get_cnt(string t) { SINT64 low,high; SINT64 L,R; L = -1; R = str.length(); while(R-L > 1) { SINT64 M = (R+L)/2; string buf = str.substr(sais[M]); if (buf.length() > t.length()) { buf = buf.substr(0,t.length()); } if (buf > t) {R = M;} else {L = M;} } high = R; L = -1; R = str.length(); while(R-L > 1) { SINT64 M = (R+L)/2; string buf = str.substr(sais[M]); if (buf >= t) {R = M;} else {L = M;} } low = R; return high - low; } // SAIS実行 void sais_act(vector<SINT64>& Vstr, vector<SINT64>& r_sais, SINT64 type) { Vstr.push_back(0); // 番兵追加 vector<SINT64> lms_seed; // LMS ソート前 vector<SINT64> lms_sort; // LMS ソート後 vector<SINT64> lms_long(Vstr.size(),0); // LMS 長さ vector<SINT64> lms_type(Vstr.size(),1); // 0:L 1:S 2:LMS vector<SINT64> lms_posi(Vstr.size(),-1); // LMS内での位置 SINT64 len = 0; // L S LMS判定 初期値は全てS rrep(i,Vstr.size()-2,0) { len++; if (Vstr[i] > Vstr[i+1]) { lms_type[i] = 0; // L if (lms_type[i+1] == 1) { lms_type[i+1] = 2; // LMS lms_long[i+1] = len; // LMSの長さ格納 len = 1; } } if (Vstr[i] == Vstr[i+1]) lms_type[i] = lms_type[i+1]; // 右と同じ } SINT64 cnt = 0; rep(i,0,Vstr.size()) { if (lms_type[i] == 2) lms_seed.emplace_back(i); if (lms_type[i] == 2) lms_posi[i] = cnt++; } // Induced Sort初回 vector<SINT64> bucket; // Induced Sort初回結果格納用 induced_sort(Vstr, lms_seed, bucket, lms_type, type); // lms_sortにLMSのソートを格納 rrep(i,Vstr.size()-1,0) { if ((bucket[i] != -1) && (lms_type[bucket[i]] == 2)) { lms_sort.emplace_back(bucket[i]); } } SINT64 ok = 0; // 再帰必要性判定 SINT64 rank = 1; // 再帰用文字 vector<SINT64> next(lms_sort.size(), 1); // 再帰用文字列 rrep(i,lms_sort.size()-2,0) { SINT64 A = lms_long[lms_sort[i]]; SINT64 B = lms_long[lms_sort[i+1]]; if (A == B) { SINT64 ck = 0; rep(j,0,A) { if (Vstr[lms_sort[i]+j] != Vstr[lms_sort[i+1]+j]) { ck = 1; break; } } if (ck == 0) { ok = 1; // 再帰必要 } else { rank++; } } else { rank++; } next[lms_posi[lms_sort[i]]] = rank; } if (ok == 1) { vector<SINT64> recursive; sais_act(next, recursive, rank+1); rep(i,0,recursive.size()) { lms_sort[recursive.size()-i-1] = lms_seed[recursive[i]]; } } // SORT済みLMSでInduced Sorting r_sais.resize(Vstr.size(),-1); induced_sort(Vstr, lms_sort, r_sais, lms_type, type); r_sais.erase(r_sais.begin()); // 番兵削除 } // induced_sort void induced_sort(vector<SINT64>& Vstr, vector<SINT64>& seed, vector<SINT64>& bucket_sort, vector<SINT64>& lms_type, SINT64 type) { vector<SINT64> bucket_cnt(type,0); // バケット 文字種ごとの数 vector<SINT64> bucket_st(type,0); // バケット 文字種の開始位置 vector<SINT64> bucket_end(type,0); // バケット 文字種の終了位置 vector<SINT64> bucket_pre(Vstr.size(),-1); // バケット 初回格納用 vector<SINT64> cnt1(type,0); vector<SINT64> cnt2(type,0); vector<SINT64> cnt3(type,0); bucket_sort.resize(Vstr.size(),-1); // バケットソート位置作成 rep(i,0,Vstr.size()) bucket_cnt[Vstr[i]]++; // 個数作成 rep(i,1,type) bucket_st[i] = bucket_st[i-1] + bucket_cnt[i-1]; // 開始位置 rep(i,0,type) bucket_end[i] = bucket_st[i] + bucket_cnt[i]-1; // 終了位置 // LMSをbucket_preに格納 rep(i,0,seed.size()) { SINT64 no = seed[i]; bucket_pre[bucket_end[Vstr[no]] - cnt1[Vstr[no]]] = no; cnt1[Vstr[no]]++; } // Lをbucket_sortに格納 rep(i,0,Vstr.size()) { if ((bucket_pre[i] != -1) && (bucket_pre[i] != 0)) { if (lms_type[bucket_pre[i]-1] == 0) { // -1がLの場合 SINT64 buf = Vstr[bucket_pre[i]-1]; bucket_pre [bucket_st[buf] + cnt2[buf]] = bucket_pre[i]-1; bucket_sort[bucket_st[buf] + cnt2[buf]] = bucket_pre[i]-1; cnt2[buf]++; } } } // Sをbucket_sortに格納 bucket_sort[0] = Vstr.size()-1; // 番兵追加 rrep(i,Vstr.size()-1,0) { if ((bucket_sort[i] != -1) && (bucket_sort[i] != 0)) { if (lms_type[bucket_sort[i]-1] != 0) { // -1がS(LMS)の場合 SINT64 buf = Vstr[bucket_sort[i]-1]; bucket_sort[bucket_end[buf] - cnt3[buf]] = bucket_sort[i]-1; cnt3[buf]++; } } } } }; */ /* 転倒数の数え上げ SINT64 merge_cnt(vector<SINT64> &a) { SINT64 n = a.size(); if (n <= 1) { return 0; } SINT64 cnt = 0; vector<SINT64> b(a.begin(), a.begin()+n/2); vector<SINT64> c(a.begin()+n/2, a.end()); cnt += merge_cnt(b); cnt += merge_cnt(c); SINT64 ai = 0, bi = 0, ci = 0; // merge の処理 while (ai < n) { if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) { a[ai++] = b[bi++]; } else { cnt += n / 2 - bi; a[ai++] = c[ci++]; } } return cnt; } */ /* 最長部分文字列 SINT64 LCS(string s, string t) { SINT64 n = s.size(); SINT64 m = t.size(); vector<vector<SINT64>> DP(n+1,vector<SINT64>(m+1,0)); rep(i,0,n) { rep(j,0,m) { if (s[i] == t[j]) { DP[i+1][j+1] = DP[i][j]+1; } else { DP[i+1][j+1] = MAX(DP[i+1][j],DP[i][j+1]); } } } return DP[n][m]; } */
[ "call.arguments.change" ]
780,890
780,891
u824905100
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, (n)-1, 0) #define all(v) v.begin(), v.end() #define endk '\n' const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; const ld eps = 1e-10; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> A(n); rep(i, n) cin >> A[i]; multiset<ll> st; rep(i, n) { auto itr = st.upper_bound(A[i] - 1); if (itr == st.begin()) { st.insert(A[i]); } else { st.erase(*(--itr)); st.insert(A[i]); } } cout << st.size() << endk; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, (n)-1, 0) #define all(v) v.begin(), v.end() #define endk '\n' const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; const ld eps = 1e-10; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> A(n); rep(i, n) cin >> A[i]; multiset<ll> st; rep(i, n) { auto itr = st.upper_bound(A[i] - 1); if (itr == st.begin()) { st.insert(A[i]); } else { st.erase(--itr); st.insert(A[i]); } } cout << st.size() << endk; return 0; }
[ "call.arguments.change" ]
780,892
780,893
u137747137
cpp
p02973
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const long long INF = 1e+18 + 1; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> T; const ll MOD = 1000000007LL; string abc = "abcdefghijklmnopqrstuvwxyz"; string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; vl dx = {-1, -1, -1, 0, 0, 1, 1, 1}; vl dy = {1, -1, 0, 1, -1, 1, 0, -1}; int main() { ll n; cin >> n; vl a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); ll dp[114514]; rep(i, n + 1) dp[i] = INF; rep(i, n) { *upper_bound(dp, dp + n, a[i]) = a[i]; } ll ans = upper_bound(dp, dp + n, INF) - dp; cout << ans << endl; }
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const long long INF = 1e+18 + 1; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> T; const ll MOD = 1000000007LL; string abc = "abcdefghijklmnopqrstuvwxyz"; string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; vl dx = {-1, -1, -1, 0, 0, 1, 1, 1}; vl dy = {1, -1, 0, 1, -1, 1, 0, -1}; int main() { ll n; cin >> n; vl a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); ll dp[114514]; rep(i, n + 1) dp[i] = INF; rep(i, n) { *upper_bound(dp, dp + n, a[i]) = a[i]; } ll ans = lower_bound(dp, dp + n, INF) - dp; cout << ans << endl; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
780,894
780,895
u614128939
cpp
p02973
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const long long INF = 1e+18 + 1; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> T; const ll MOD = 1000000007LL; string abc = "abcdefghijklmnopqrstuvwxyz"; string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; vl dx = {-1, -1, -1, 0, 0, 1, 1, 1}; vl dy = {1, -1, 0, 1, -1, 1, 0, -1}; int main() { ll n; cin >> n; vl a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); ll dp[114514]; rep(i, n + 1) dp[i] = INF; rep(i, n) { *upper_bound(dp, dp + n, a[i]) = a[i]; } ll ans = upper_bound(dp, dp + n, INF) - dp; cout << ans << endl; }
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const long long INF = 1e+18 + 1; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> T; const ll MOD = 1000000007LL; string abc = "abcdefghijklmnopqrstuvwxyz"; string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; vl dx = {-1, -1, -1, 0, 0, 1, 1, 1}; vl dy = {1, -1, 0, 1, -1, 1, 0, -1}; int main() { ll n; cin >> n; vl a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); ll dp[114514]; rep(i, n + 1) dp[i] = INF; rep(i, n) { *upper_bound(dp, dp + n, a[i]) = a[i]; } ll ans = lower_bound(dp, dp + n, INF) - dp; cout << ans << endl; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
780,894
780,896
u614128939
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { // cout << fixed << setprecision(10) << flush; int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i] *= -1; } int INF = (1 << 30); // A についての広義単調減少列の最大の長さを求めればよい // A * (-1) についての狭義単調増加列にすればよい vector<int> dp(n, 0); for (int i = 0; i < n; i++) { auto itr = lower_bound(dp.begin(), dp.end(), a[i]); int ind = distance(dp.begin(), itr); dp[ind] = a[i]; } auto itr = lower_bound(dp.begin(), dp.end(), 0); int ind = distance(dp.begin(), itr); cout << ind << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { // cout << fixed << setprecision(10) << flush; int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i] *= -1; } int INF = (1 << 30); // A についての広義単調減少列の最大の長さを求めればよい // A * (-1) についての広義単調増加列にすればよい vector<int> dp(n, INF); for (int i = 0; i < n; i++) { auto itr = upper_bound(dp.begin(), dp.end(), a[i]); int ind = distance(dp.begin(), itr); dp[ind] = a[i]; } auto itr = lower_bound(dp.begin(), dp.end(), INF); int ind = distance(dp.begin(), itr); cout << ind << endl; return 0; }
[ "call.arguments.change", "identifier.change", "call.function.change", "identifier.replace.add", "literal.replace.remove" ]
780,915
780,916
u658401995
cpp
p02973
#include <bits/stdc++.h> using namespace std; /* typedef */ typedef long long ll; typedef pair<int, int> pii; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 50; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* global variables */ /* function */ /* main */ int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i]; vector<int> L(N + 1); L[0] = a[N - 1]; int length = 1; for (int i = N - 2; i >= 0; i--) { if (L[length - 1] <= a[i]) L[length++] = a[i]; else { *lower_bound(L.begin(), L.begin() + length, a[i]) = a[i]; } } cout << length << '\n'; }
#include <bits/stdc++.h> using namespace std; /* typedef */ typedef long long ll; typedef pair<int, int> pii; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 50; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* global variables */ /* function */ /* main */ int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i]; vector<int> L(N + 1); L[0] = a[N - 1]; int length = 1; for (int i = N - 2; i >= 0; i--) { if (L[length - 1] <= a[i]) L[length++] = a[i]; else { *upper_bound(L.begin(), L.begin() + length, a[i]) = a[i]; } } cout << length << '\n'; }
[ "assignment.variable.change", "identifier.change", "call.function.change" ]
780,926
780,927
u603234915
cpp
p02973
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; deque<int> q; rep(i, n) { int a; cin >> a; int x = lower_bound(q.begin(), q.end(), a) - q.begin(); if (x == 0) q.push_front(a); else q[x] = a; } cout << q.size() << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; deque<int> q; rep(i, n) { int a; cin >> a; int x = lower_bound(q.begin(), q.end(), a) - q.begin(); if (x == 0) q.push_front(a); else q[x - 1] = a; } cout << q.size() << endl; }
[ "assignment.change" ]
780,928
780,929
u754114382
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; multiset<int> ms; for (auto a : A) { if (ms.empty() || *ms.begin() >= a) ms.insert(a); else { auto itr = ms.lower_bound(a); if (itr == ms.end() || *itr == a) itr--; ms.erase(itr); ms.insert(a); } } cout << ms.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; multiset<int> ms; for (auto a : A) { if (ms.empty() || *ms.begin() >= a) ms.insert(a); else { auto itr = ms.lower_bound(a); if (itr == ms.end() || *itr >= a) itr--; ms.erase(itr); ms.insert(a); } } cout << ms.size() << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
780,940
780,941
u175426149
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define precise(n, k) fixed << setprecision(k) << n #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define uint unsigned int #define ll long long #define ull unsigned long long #define ld long double const int MOD = int(1e9 + 7); const int oo = int(1e9 + 20); const ll lloo = (ll)(1e18 + 10); class SegmentTree { int NEUTRAL; int n; vector<int> tree; function<int(int, int)> func; public: SegmentTree(vector<int> values, function<int(int, int)> f, int neutral) { func = static_cast<function<int(int, int)>>(f); NEUTRAL = neutral; n = values.size(); tree.resize(n * 2); // Build for (int i = 0; i < n; i++) { tree[n + i] = values[i]; } for (int i = n - 1; i > 0; --i) { tree[i] = func(tree[i << 1], tree[i << 1 | 1]); } } void update(int index, int value) { tree[index + n] = value; index = index + n; for (int i = index; i > 1; i >>= 1) { tree[i >> 1] = func(tree[i], tree[i ^ 1]); } } int query(int l, int r) { int ans = NEUTRAL; for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l & 1) { ans = func(ans, tree[l++]); } if (r & 1) { ans = func(ans, tree[--r]); } } return ans; } }; int myMin(int x, int y) { return min(x, y); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; n++; vector<int> val(n); for (int i = 1; i < n; ++i) { cin >> val[i]; } SegmentTree st(val, myMin, -oo); vector<bool> visited(n, false); int colors = 0; int last; for (int i = 1; i < n; ++i) { if (!visited[i]) { colors++; last = val[i]; visited[i] = true; st.update(i, -oo); if (st.query(i + 1, n) <= last) continue; for (int j = i + 1; j < n; ++j) { if (!visited[j] && last < val[j]) { last = val[j]; visited[j] = true; st.update(j, -oo); if (st.query(j + 1, n) <= last) break; } } } } cout << colors << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define precise(n, k) fixed << setprecision(k) << n #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define uint unsigned int #define ll long long #define ull unsigned long long #define ld long double const int MOD = int(1e9 + 7); const int oo = int(1e9 + 20); const ll lloo = (ll)(1e18 + 10); class SegmentTree { int NEUTRAL; int n; vector<int> tree; function<int(int, int)> func; public: SegmentTree(vector<int> values, function<int(int, int)> f, int neutral) { func = static_cast<function<int(int, int)>>(f); NEUTRAL = neutral; n = values.size(); tree.resize(n * 2); // Build for (int i = 0; i < n; i++) { tree[n + i] = values[i]; } for (int i = n - 1; i > 0; --i) { tree[i] = func(tree[i << 1], tree[i << 1 | 1]); } } void update(int index, int value) { tree[index + n] = value; index = index + n; for (int i = index; i > 1; i >>= 1) { tree[i >> 1] = func(tree[i], tree[i ^ 1]); } } int query(int l, int r) { int ans = NEUTRAL; for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l & 1) { ans = func(ans, tree[l++]); } if (r & 1) { ans = func(ans, tree[--r]); } } return ans; } }; int myMax(int x, int y) { return max(x, y); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; n++; vector<int> val(n); for (int i = 1; i < n; ++i) { cin >> val[i]; } SegmentTree st(val, myMax, -oo); vector<bool> visited(n, false); int colors = 0; int last; for (int i = 1; i < n; ++i) { if (!visited[i]) { colors++; last = val[i]; visited[i] = true; st.update(i, -oo); if (st.query(i + 1, n) <= last) continue; for (int j = i + 1; j < n; ++j) { if (!visited[j] && last < val[j]) { last = val[j]; visited[j] = true; st.update(j, -oo); if (st.query(j + 1, n) <= last) break; } } } } cout << colors << endl; return 0; }
[ "identifier.change", "misc.opposites", "call.function.change", "function.return_value.change", "call.arguments.change" ]
780,944
780,945
u192061265
cpp
p02973
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse4") #include "bits/stdc++.h" using namespace std; typedef long long ll; #define int ll #define all(x) x.begin(), x.end() #define trav(i, a) for (auto &i : a) inline int in() { int x; scanf("%lld", &x); return x; } int32_t main() { int n = in(); vector<int> a(n); for (int i = 0; i < n; i++) a[i] = in(); multiset<int> s; reverse(all(a)); s.insert(a[0]); int x; for (int i = 1; i < n; i++) { x = a[i]; auto it = s.upper_bound(x); if (it == s.end()) s.insert(x); else { s.insert(x); s.erase(*it); } } cout << s.size(); }
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse4") #include "bits/stdc++.h" using namespace std; typedef long long ll; #define int ll #define all(x) x.begin(), x.end() #define trav(i, a) for (auto &i : a) inline int in() { int x; scanf("%lld", &x); return x; } int32_t main() { int n = in(); vector<int> a(n); for (int i = 0; i < n; i++) a[i] = in(); multiset<int> s; reverse(all(a)); s.insert(a[0]); int x; for (int i = 1; i < n; i++) { x = a[i]; auto it = s.upper_bound(x); if (it == s.end()) s.insert(x); else { s.insert(x); s.erase(it); } } cout << s.size(); }
[ "call.arguments.change" ]
780,946
780,947
u875407613
cpp
p02973
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; // ■■■■■■■■■■■■■■■■headerここまで■■■■■■■■■■■■■■■■ int main(void) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> arr(n); int length = 0; arr[0] = a[0]; for (int i = 1; i < n; i++) { if (arr[length] >= a[i]) { length++; arr[length] = a[i]; } else { for (int j = 0; j < length; j++) { if (arr[j] < a[i]) { arr[j] = a[i]; break; } } } } cout << length + 1 << endl; return 0; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; // ■■■■■■■■■■■■■■■■headerここまで■■■■■■■■■■■■■■■■ int main(void) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> arr(n); int length = 0; arr[0] = a[0]; for (int i = 1; i < n; i++) { if (arr[length] >= a[i]) { length++; arr[length] = a[i]; } else { for (int j = 0; j <= length; j++) { if (arr[j] < a[i]) { arr[j] = a[i]; break; } } } } cout << length + 1 << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
780,952
780,953
u268551819
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(), (x).end() using vl = vector<ll>; using vvl = vector<vector<ll>>; const ll MOD = 1000000007; const ll MOD9 = 998244353; const int inf = 1e9 + 10; const ll INF = 4e18; const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1}; using Graph = vector<vector<int>>; const double pi = acos(-1); template <int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; vector<bool> seen, finished; int pos = -1; int ca = 0; int f = 0; void dfs(const Graph &G, int v, int p) { seen[v] = true; for (auto nv : G[v]) { if (nv == p) continue; if (finished[nv]) continue; if (seen[nv] && !finished[nv]) { pos = nv; f++; return; } dfs(G, nv, v); // サイクル検出したならば真っ直ぐに抜けていく if (pos != -1) { return; } } finished[v] = true; } mint calc(long long N, long long K) { mint res = 1; for (long long n = 0; n < K; ++n) { res *= (N - n); res /= (n + 1); } return res; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; int main() { ll n; cin >> n; ll a[n] = {}; rep(i, n) cin >> a[i]; ll c = 0; map<ll, ll> d; d[a[0]]++; repl(i, 1, n) { auto k = d.begin(); ll j = k->first; // cout << j << endl; if (j >= a[i]) { d[a[i]]++; } else { auto s = d.upper_bound(a[i]); // cout << i << " " << " " << a[i] << " " << s->fi << endl; if (d[s->fi] == 1) d.erase(s->fi); else { d[s->fi]--; } d[a[i]]++; } } for (auto p : d) { if (p.se >= 0) { // cout << p.fi <<" " << p.se << endl; c += p.se; } } cout << c << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(), (x).end() using vl = vector<ll>; using vvl = vector<vector<ll>>; const ll MOD = 1000000007; const ll MOD9 = 998244353; const int inf = 1e9 + 10; const ll INF = 4e18; const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1}; using Graph = vector<vector<int>>; const double pi = acos(-1); template <int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; vector<bool> seen, finished; int pos = -1; int ca = 0; int f = 0; void dfs(const Graph &G, int v, int p) { seen[v] = true; for (auto nv : G[v]) { if (nv == p) continue; if (finished[nv]) continue; if (seen[nv] && !finished[nv]) { pos = nv; f++; return; } dfs(G, nv, v); // サイクル検出したならば真っ直ぐに抜けていく if (pos != -1) { return; } } finished[v] = true; } mint calc(long long N, long long K) { mint res = 1; for (long long n = 0; n < K; ++n) { res *= (N - n); res /= (n + 1); } return res; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; int main() { ll n; cin >> n; ll a[n] = {}; rep(i, n) cin >> a[i]; ll c = 0; map<ll, ll> d; d[a[0]]++; repl(i, 1, n) { auto k = d.begin(); ll j = k->first; // cout << j << endl; if (j >= a[i]) { d[a[i]]++; } else { auto s = d.lower_bound(a[i]); s--; // cout << i << " " << " " << a[i] << " " << s->fi << endl; if (d[s->fi] == 1) d.erase(s->fi); else { d[s->fi]--; } d[a[i]]++; } } for (auto p : d) { if (p.se >= 0) { // cout << p.fi <<" " << p.se << endl; c += p.se; } } cout << c << endl; }
[ "call.function.change", "expression.unary.arithmetic.add" ]
780,954
780,955
u722640678
cpp
p02973
#include <algorithm> #include <chrono> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #endif #define FOR(i, a, b) for (ll i = a; i < b; i++) #define REP(i, a, b) for (ll i = a; i > b; i--) #define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定 #define ct(a) cout << a << endl #define rep(i, n) for (int i = 0; i < (n); i++) #define repl(i, l, r) for (int i = (1); i < (r); i++) #define per(i, n) for (int i = ((n)-1); i >= 0; i--) static const double pi = 3.141592653589793; using namespace std; typedef long long ll; const ll MOD = 998244353; const ll INF = (1LL << 31) - 1; const ll mod = 1e9 + 7; ll N, ans; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cin >> N; multiset<ll> st; st.insert(1e9 + 1); FOR(i, 0, N) { ll A; cin >> A; if (*st.begin() >= A) { //すべてAより大きかったら ans++; } else { // Aより小さいものが存在したら auto ite = st.lower_bound(A); ite--; st.erase(*ite); } st.insert(A); } cout << ans << endl; }
#include <algorithm> #include <chrono> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #endif #define FOR(i, a, b) for (ll i = a; i < b; i++) #define REP(i, a, b) for (ll i = a; i > b; i--) #define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定 #define ct(a) cout << a << endl #define rep(i, n) for (int i = 0; i < (n); i++) #define repl(i, l, r) for (int i = (1); i < (r); i++) #define per(i, n) for (int i = ((n)-1); i >= 0; i--) static const double pi = 3.141592653589793; using namespace std; typedef long long ll; const ll MOD = 998244353; const ll INF = (1LL << 31) - 1; const ll mod = 1e9 + 7; ll N, ans; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cin >> N; multiset<ll> st; st.insert(1e9 + 1); FOR(i, 0, N) { ll A; cin >> A; if (*st.begin() >= A) { //すべてAより大きかったら ans++; } else { // Aより小さいものが存在したら auto ite = st.lower_bound(A); ite--; st.erase(ite); } st.insert(A); } cout << ans << endl; }
[ "call.arguments.change" ]
780,958
780,959
u243196226
cpp
p02973
#include <algorithm> #include <chrono> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #endif #define FOR(i, a, b) for (ll i = a; i < b; i++) #define REP(i, a, b) for (ll i = a; i > b; i--) #define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定 #define ct(a) cout << a << endl #define rep(i, n) for (int i = 0; i < (n); i++) #define repl(i, l, r) for (int i = (1); i < (r); i++) #define per(i, n) for (int i = ((n)-1); i >= 0; i--) static const double pi = 3.141592653589793; using namespace std; typedef long long ll; const ll MOD = 998244353; const ll INF = (1LL << 31) - 1; const ll mod = 1e9 + 7; ll N, ans; multiset<ll> st; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cin >> N; // st.insert(ll(1e9+1)); FOR(i, 0, N) { ll A; cin >> A; auto ite = st.lower_bound(A); if (st.begin() != ite) { //すべてAより大きかったら ite--; st.erase(*ite); } st.insert(A); } cout << st.size() << endl; // cout << ans << endl; }
#include <algorithm> #include <chrono> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #endif #define FOR(i, a, b) for (ll i = a; i < b; i++) #define REP(i, a, b) for (ll i = a; i > b; i--) #define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定 #define ct(a) cout << a << endl #define rep(i, n) for (int i = 0; i < (n); i++) #define repl(i, l, r) for (int i = (1); i < (r); i++) #define per(i, n) for (int i = ((n)-1); i >= 0; i--) static const double pi = 3.141592653589793; using namespace std; typedef long long ll; const ll MOD = 998244353; const ll INF = (1LL << 31) - 1; const ll mod = 1e9 + 7; ll N, ans; multiset<ll> st; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cin >> N; // st.insert(ll(1e9+1)); FOR(i, 0, N) { ll A; cin >> A; auto ite = st.lower_bound(A); if (st.begin() != ite) { //すべてAより大きかったら ite--; st.erase(ite); } st.insert(A); } cout << st.size() << endl; // cout << ans << endl; }
[ "call.arguments.change" ]
780,960
780,961
u243196226
cpp
p02973
#include <iostream> #include <set> #include <vector> signed main() { int n; std::cin >> n; std::vector<int> a(n); for (auto &ai : a) std::cin >> ai; std::multiset<int> s; for (auto ai : a) { auto itr = s.upper_bound(ai); if (itr == std::begin(s)) { s.emplace(ai); continue; } --itr; s.erase(itr); s.emplace(ai); } std::cout << std::size(s) << std::endl; }
#include <iostream> #include <set> #include <vector> signed main() { int n; std::cin >> n; std::vector<int> a(n); for (auto &ai : a) std::cin >> ai; std::multiset<int> s; for (auto ai : a) { auto itr = s.lower_bound(ai); if (itr == std::begin(s)) { s.emplace(ai); continue; } --itr; s.erase(itr); s.emplace(ai); } std::cout << std::size(s) << std::endl; }
[ "call.function.change" ]
780,962
780,963
u423624748
cpp
p02973
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> v; rep(i, n) { int x; cin >> x; auto it = lower_bound(v.begin(), v.end(), x); if (it == v.begin()) { v.insert(v.begin(), x); } else { *it = x; } } cout << v.size() << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> v; rep(i, n) { int x; cin >> x; auto it = lower_bound(v.begin(), v.end(), x); if (it == v.begin()) { v.insert(v.begin(), x); } else { it--; *it = x; } /*rep(j, v.size()){ cout << v[j] << " "; } cout << endl;*/ } cout << v.size() << endl; return 0; }
[ "expression.unary.arithmetic.add" ]
780,964
780,965
u489302942
cpp
p02973
/*Function Template*/ #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pint; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); i++) #define Rep(i, n) for (ll i = 1; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define PI 3.14159265358979323846 ll fac[MAX], finv[MAX], inv[MAX]; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } bool palindrome(string s) { bool flag = true; rep(i, s.size()) if (s[i] != s[s.size() - 1 - i]) flag = false; return flag; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (ll i = s - 1; i >= 0; i--) m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10; return m; } ll Svec(vector<ll> v) { ll n = 0; for (ll i = 0; i < v.size(); i++) n += v[i]; return n; } ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll LCM(ll a, ll b) { return a / GCD(a, b) * b; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } void runlength(string s, vector<pair<char, ll>> &p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); } for (ll i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) { x++; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } string Toupper(string s) { string ans = ""; rep(i, s.size()) { if ('a' <= s[i] && s[i] <= 'z') ans += (char)s[i] - 32; else ans += s[i]; } return ans; } string Tolower(string s) { string ans = ""; rep(i, s.size()) { if ('A' <= s[i] && s[i] <= 'Z') ans += (char)s[i] + 32; else ans += s[i]; } return ans; } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } vector<pint> prime_factorize(ll n) { vector<pint> ans; for (ll p = 2; p <= sqrt(n); p++) { if (n % p != 0) continue; ll cnt = 0; while (n % p == 0) { n /= p; cnt++; } ans.push_back(make_pair(p, cnt)); } if (n != 1) ans.push_back(make_pair(n, 1)); return ans; } /*bool cmp(pint a, pint b) { return a.second < b.second; }*/ /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n; cin >> n; vector<ll> v(n), ans(n, 1e10); rep(i, n) cin >> v[i]; reverse(ALL(v)); rep(i, n) * lower_bound(ALL(ans), v[i]) = v[i]; cout << lower_bound(ALL(ans), 1e10) - ans.begin() << endl; }
/*Function Template*/ #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pint; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); i++) #define Rep(i, n) for (ll i = 1; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define PI 3.14159265358979323846 ll fac[MAX], finv[MAX], inv[MAX]; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } bool palindrome(string s) { bool flag = true; rep(i, s.size()) if (s[i] != s[s.size() - 1 - i]) flag = false; return flag; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (ll i = s - 1; i >= 0; i--) m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10; return m; } ll Svec(vector<ll> v) { ll n = 0; for (ll i = 0; i < v.size(); i++) n += v[i]; return n; } ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll LCM(ll a, ll b) { return a / GCD(a, b) * b; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } void runlength(string s, vector<pair<char, ll>> &p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); } for (ll i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) { x++; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } string Toupper(string s) { string ans = ""; rep(i, s.size()) { if ('a' <= s[i] && s[i] <= 'z') ans += (char)s[i] - 32; else ans += s[i]; } return ans; } string Tolower(string s) { string ans = ""; rep(i, s.size()) { if ('A' <= s[i] && s[i] <= 'Z') ans += (char)s[i] + 32; else ans += s[i]; } return ans; } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } vector<pint> prime_factorize(ll n) { vector<pint> ans; for (ll p = 2; p <= sqrt(n); p++) { if (n % p != 0) continue; ll cnt = 0; while (n % p == 0) { n /= p; cnt++; } ans.push_back(make_pair(p, cnt)); } if (n != 1) ans.push_back(make_pair(n, 1)); return ans; } /*bool cmp(pint a, pint b) { return a.second < b.second; }*/ /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n; cin >> n; vector<ll> v(n), ans(n, 1e10); rep(i, n) cin >> v[i]; reverse(ALL(v)); rep(i, n) * upper_bound(ALL(ans), v[i]) = v[i]; cout << lower_bound(ALL(ans), 1e10) - ans.begin() << endl; }
[ "assignment.variable.change", "identifier.change", "call.function.change", "expression.operation.binary.change" ]
780,966
780,967
u264265458
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int n; cin >> n; int a[n]; rep(i, n) cin >> a[i]; deque<int> r; rep(i, n) { int idx = lower_bound(r.begin(), r.end(), a[i]) - r.begin(); if (idx == 0) { r.push_front(a[i]); } else { r[idx] = a[i]; } } cout << r.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int n; cin >> n; int a[n]; rep(i, n) cin >> a[i]; deque<int> r; rep(i, n) { int idx = lower_bound(r.begin(), r.end(), a[i]) - r.begin(); --idx; if (idx < 0) { r.push_front(a[i]); } else { r[idx] = a[i]; } } cout << r.size() << endl; return 0; }
[ "expression.unary.arithmetic.add", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
780,972
780,973
u075775814
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<vector<int>> v; multiset<int> s; vector<int> id(n); rep(i, n) { auto it = s.lower_bound(a[i]); if (it == s.begin()) { id[a[i]] = v.size(); v.push_back(vector<int>{a[i]}); s.insert(a[i]); } else { --it; id[a[i]] = id[*it]; v[id[a[i]]].push_back(a[i]); s.erase(s.find(*it)); s.insert(a[i]); } } int ans = v.size(); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<vector<int>> v; multiset<int> s; map<int, int> id; rep(i, n) { auto it = s.lower_bound(a[i]); if (it == s.begin()) { id[a[i]] = v.size(); v.push_back(vector<int>{a[i]}); s.insert(a[i]); } else { --it; id[a[i]] = id[*it]; v[id[a[i]]].push_back(a[i]); s.erase(s.find(*it)); s.insert(a[i]); } } int ans = v.size(); cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
780,974
780,975
u075775814
cpp
p02973
/////////////////////////////////////////////////////////////////////////////// #include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <typeinfo> #include <unistd.h> #include <unordered_map> #include <vector> using namespace std; /////////////////////////////////////////////////////////////////////////////// #define pb push_back #define V vector #define M unordered_map #define rep(i, n) for (ll i = 0LL; i < n; ++i) #define srep(i, s, n) for (ll i = s; i < n; ++i) #define rrep(i, n) for (ll i = n - 1LL; i >= 0LL; --i) #define ALL(a) (a).begin(), (a).end() #define CIN(x) \ do { \ assert(!cin.eof()); \ cin >> x; \ assert(!cin.fail()); \ } while (0); typedef long long ll; typedef unsigned long long ull; typedef tuple<ll, ll> t2; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; struct UnionFind { ull *parent, *count, *rank; UnionFind(ull n) { parent = new ull[n + 1]; count = new ull[n + 1]; rank = new ull[n + 1]; for (ull i = 0ULL; i < n + 1; ++i) { parent[i] = i; count[i] = 1; rank[i] = 0; } } ull root(ull i) { if (parent[i] == i) return i; parent[i] = root(parent[i]); return parent[i]; } void unite(ull i, ull j) { ull rooti = root(i); ull rootj = root(j); if (rooti == rootj) return; if (rank[rootj] < rank[rooti]) { parent[i] = parent[j] = parent[rootj] = rooti; count[rooti] += count[rootj]; } else { parent[i] = parent[j] = parent[rooti] = rootj; count[rootj] += count[rooti]; if (rank[rootj] == rank[rooti]) rank[rootj]++; } } bool same(ull i, ull j) { return root(i) == root(j); } }; struct BIT { ll *tree; ll size; BIT(ll n, ll init) { tree = new ll[n + 1]; size = n; memset(tree, 0, sizeof(ll) * (n + 1)); this->init(init); } void init(ll init) { rep(i0, size) { ll idx = i0 + 1LL; while (idx <= size) { tree[idx] += init; idx += (idx & (-idx)); } } } // idx is 1 origin void add(ll idx, ll x) { assert(idx > 0LL); while (idx <= size) { tree[idx] += x; idx += (idx & (-idx)); } } // idx is 1 origin ll sum(ll idx) { assert(idx > 0LL); ll ret = 0LL; while (idx > 0LL) { ret += tree[idx]; idx -= (idx & (-idx)); } return ret; } }; struct MaxFlow { V<ll> links[1005]; ll capacities[1005][1005]; ll nodes; MaxFlow(ll nodes) { // i == 0 --> S // i == nodes+1 --> T rep(i, nodes + 2LL) links[i].clear(); memset(capacities, 0, sizeof(capacities)); this->nodes = nodes; } void add_path(ll a, ll b, ll capacity) { links[a].pb(b); links[b].pb(a); capacities[a][b] = capacity; capacities[b][a] = 0LL; } ll solve(void) { deque<V<ll>> q; ll ret = 0LL; for (;; q.clear()) { V<ll> start; start.pb(0); q.push_front(start); bool checked[nodes + 2]; memset(checked, 0, sizeof(checked)); V<ll> found; for (; !(q.empty());) { V<ll> path = q.front(); q.pop_front(); ll last = path[path.size() - 1]; if (checked[last]) continue; if (last == nodes + 1) { found = path; break; } checked[last] = true; for (auto next : (links[last])) { if (capacities[last][next] == 0) continue; V<ll> newpath(path); newpath.pb(next); q.push_front(newpath); } } if (found.size() == 0) { break; } else { ll flowcount = capacities[found[0]][found[1]]; rep(i, found.size() - 1) { ll src = found[i]; ll dst = found[i + 1]; flowcount = min(flowcount, capacities[src][dst]); } rep(i, found.size() - 1) { ll src = found[i]; ll dst = found[i + 1]; capacities[src][dst] -= flowcount; capacities[dst][src] += flowcount; } ret += flowcount; } } return ret; } }; template <typename T> struct SegmentTree { T *nodes; t2 *ranges; // [start, end) ll nodecount; ll itemcount; T unit; T (*op)(T, T); SegmentTree(ll itemcount, T unit, T op(T, T)) { ll orig_itemcount = itemcount; this->itemcount = 1LL; while (this->itemcount < orig_itemcount) this->itemcount *= 2LL; nodecount = this->itemcount * 2 - 1; nodes = new T[nodecount]; ranges = new t2[nodecount]; this->unit = unit; this->op = op; ll start = 0LL; ll end = this->itemcount; ll len = this->itemcount; rep(i, nodecount) { nodes[i] = unit; ranges[i] = t2(start, end); if (end >= this->itemcount) { len /= 2LL; start = 0LL; end = len; } else { start = end; end = start + len; } } } void update(ll k, T v) { ll idx = k + itemcount - 1LL; nodes[idx] = v; idx = (idx - 1LL) / 2LL; for (; idx >= 0; idx = (idx - 1LL) / 2LL) { nodes[idx] = op(nodes[idx * 2LL + 1LL], nodes[idx * 2LL + 2LL]); if (!idx) break; } } T query(ll start, ll end) const { return _query(start, end, 0LL); } T _query(ll start, ll end, ll idx) const { ll rstart = get<0>(ranges[idx]); ll rend = get<1>(ranges[idx]); if (start <= rstart && rend <= end) { return nodes[idx]; } if (rend <= start || end <= rstart) { return unit; } T left = _query(start, end, idx * 2LL + 1LL); T right = _query(start, end, idx * 2LL + 2LL); return op(left, right); } }; void llin(ll &a) { CIN(a); } void llinl1(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a; CIN(a); v.push_back(a); } } void llinl2(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a, b; CIN(a >> b); v.push_back(t2(a, b)); } } void llinl3(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a, b, c; CIN(a >> b >> c); v.push_back(t3(a, b, c)); } } void llinl4(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a, b, c, d; CIN(a >> b >> c >> d); v.push_back(t4(a, b, c, d)); } } void llina(auto &v, ll count) { llinl1(v, count); } template <typename T> T min(const V<T> v) { T ret = v[0]; for (auto i : v) ret = min(ret, i); return ret; } template <typename T> T max(const V<T> v) { T ret = v[0]; for (auto i : v) ret = max(ret, i); return ret; } ll absll(ll x) { if (x < 0) return -x; return x; } ll mod_mlt(ll x, ll y, ll mod) { ll ret = 0LL; x %= mod; while (y) { if (y & 1LL) { ret += x; ret %= mod; } y >>= 1; x <<= 1; x %= mod; } return ret; } ll mod_pow(ll base, ll exp, ll mod) { ll ret = 1LL; for (; exp;) { if (exp & 1LL) { ret *= base; ret %= mod; } base = (base * base) % mod; exp >>= 1; } return ret; } ll mod_inv(ll x, ll mod) { // available only when mod is prime return mod_pow(x, mod - 2LL, mod); } ll gcm(ll x, ll y) { while (y != 0) { ll z = x % y; x = y; y = z; } return x; } template <typename T> void sort(V<T> &v) { sort(v.begin(), v.end()); } template <typename T> void sort_reverse(V<T> &v) { sort(v.begin(), v.end(), greater<T>()); } void get_divisors(V<ll> &retlist, ll x) { for (ll i = 1LL; i < sqrt(x) + 3LL; ++i) { if (x % i == 0LL) { retlist.push_back(i); retlist.push_back(x / i); } } } void get_factors(V<ll> &retlist, ll x) { for (ll i = 2LL; i < (ll)(sqrt(x)) + 3LL; ++i) { while (x % i == 0LL) { retlist.pb(i); x /= i; } } retlist.pb(x); } bool is_prime(ll x) { V<ll> factors, factors2; get_factors(factors, x); for (auto factor : factors) { if (factor > 1) factors2.pb(factor); } return factors2.size() == 1 && x == factors2[0]; } template <typename T> void intersection(const set<T> &a, const set<T> &b, set<T> &result) { set_intersection(ALL(a), ALL(b), inserter(result, result.end())); } ull combination(ll x, ll y) { if (y > x / 2LL) y = x - y; ull ret = 1LL; for (ll i = 0LL; i < y; ++i) { ret *= x--; ret /= (i + 1LL); } return ret; } ull mod_combination(ll x, ll y, ll mod) { if (y > x / 2LL) y = x - y; ll ret = 1; for (ll i = 0LL; i < y; ++i) { ret = (ret * x--) % mod; ret = (ret * mod_inv(i + 1LL, mod)) % mod; } return ret; } void make_linklist(const V<t2> &srclist, V<ll> dstlist[]) { for (auto src : srclist) { ll a = get<0>(src); ll b = get<1>(src); dstlist[a].pb(b); dstlist[b].pb(a); } } void make_parent(const V<ll> linklist[], ll root, ll n, ll parent[], ll level[]) { queue<ll> q; bool checked[n + 1]; memset(checked, 0, sizeof(checked)); q.push(root); checked[root] = true; parent[root] = root; level[root] = 0LL; for (; !(q.empty());) { ll now = q.front(); q.pop(); for (auto next : linklist[now]) { if (checked[next]) continue; q.push(next); checked[next] = true; parent[next] = now; level[next] = level[now] + 1LL; } } } #define POW_ANCESTOR_MAXSIZE 20 // preprocess for get_common_ancestor() void make_pow_ancestor(const ll parent[], ll n, ll (*pow_ancestor)[POW_ANCESTOR_MAXSIZE]) { rep(i, n) pow_ancestor[i + 1][0] = parent[i + 1]; for (int pow2 = 1; pow(2, pow2) <= n; ++pow2) { rep(i0, n) { int i = i0 + 1; ll prev = pow_ancestor[i][pow2 - 1]; pow_ancestor[i][pow2] = pow_ancestor[prev][pow2 - 1]; } } } ll get_common_ancestor(ll n, ll x, ll y, const ll (*pow_ancestor)[POW_ANCESTOR_MAXSIZE], const ll level[]) { if (level[x] < level[y]) { ll diff = level[y] - level[x]; for (; diff;) { ll bit = diff & -diff; y = pow_ancestor[y][(int)log2(bit)]; diff -= bit; } } else { ll diff = level[x] - level[y]; for (; diff;) { ll bit = diff & -diff; x = pow_ancestor[x][(int)log2(bit)]; diff -= bit; } } if (x == y) return x; rrep(i, (int)log2(n) + 1) { if (pow_ancestor[x][i] != pow_ancestor[y][i]) { x = pow_ancestor[x][i]; y = pow_ancestor[y][i]; } } return pow_ancestor[x][0]; } void debug_print(auto x) { cout << x << endl; } void debug_print(const t2 &x) { ll x1 = get<0>(x); ll x2 = get<1>(x); cout << "-- " << x1 << " -- " << x2 << endl; } void debug_print(const t3 &x) { ll x1 = get<0>(x); ll x2 = get<1>(x); ll x3 = get<2>(x); cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << endl; } void debug_print(const t4 &x) { ll x1 = get<0>(x); ll x2 = get<1>(x); ll x3 = get<2>(x); ll x4 = get<3>(x); cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << " -- " << x4 << endl; } template <typename T> void debug_print(T xarray[], ll n) { rep(i, n) debug_print(xarray[i]); } template <typename T> void debug_print(const V<T> &xlist) { for (auto x : xlist) { cout << "-- "; debug_print(x); } } template <typename T> void debug_print(const set<T> &xset) { for (auto x : xset) { cout << "-- "; debug_print(x); } } template <typename S, typename T> void debug_print(const M<S, T> &xlist) { for (auto x : xlist) { S k = x.first; T v = x.second; cout << "====" << endl; cout << "K="; debug_print(k); cout << "V="; debug_print(v); } } int _main(); int main() { cout << setprecision(12); return _main(); } /////////////////////////////////////////////////////////////////////////////// int _main() { ll n; llin(n); V<ll> alist; llinl1(alist, n); V<ll> floors; floors.pb(alist[0]); ll ans = 1LL; srep(i, 1, n) { int left = 0; int right = floors.size(); int tmp = (left + right) / 2; int idx = n + 5; for (; left <= right; tmp = (left + right) / 2) { if (floors[tmp] < alist[i]) { idx = min(idx, tmp); right = idx - 1; } else { left = idx + 1; } } if (idx > n) { ans++; floors.pb(alist[i]); } else { floors[idx] = alist[i]; } } cout << ans; return 0; } ///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// #include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <typeinfo> #include <unistd.h> #include <unordered_map> #include <vector> using namespace std; /////////////////////////////////////////////////////////////////////////////// #define pb push_back #define V vector #define M unordered_map #define rep(i, n) for (ll i = 0LL; i < n; ++i) #define srep(i, s, n) for (ll i = s; i < n; ++i) #define rrep(i, n) for (ll i = n - 1LL; i >= 0LL; --i) #define ALL(a) (a).begin(), (a).end() #define CIN(x) \ do { \ assert(!cin.eof()); \ cin >> x; \ assert(!cin.fail()); \ } while (0); typedef long long ll; typedef unsigned long long ull; typedef tuple<ll, ll> t2; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; struct UnionFind { ull *parent, *count, *rank; UnionFind(ull n) { parent = new ull[n + 1]; count = new ull[n + 1]; rank = new ull[n + 1]; for (ull i = 0ULL; i < n + 1; ++i) { parent[i] = i; count[i] = 1; rank[i] = 0; } } ull root(ull i) { if (parent[i] == i) return i; parent[i] = root(parent[i]); return parent[i]; } void unite(ull i, ull j) { ull rooti = root(i); ull rootj = root(j); if (rooti == rootj) return; if (rank[rootj] < rank[rooti]) { parent[i] = parent[j] = parent[rootj] = rooti; count[rooti] += count[rootj]; } else { parent[i] = parent[j] = parent[rooti] = rootj; count[rootj] += count[rooti]; if (rank[rootj] == rank[rooti]) rank[rootj]++; } } bool same(ull i, ull j) { return root(i) == root(j); } }; struct BIT { ll *tree; ll size; BIT(ll n, ll init) { tree = new ll[n + 1]; size = n; memset(tree, 0, sizeof(ll) * (n + 1)); this->init(init); } void init(ll init) { rep(i0, size) { ll idx = i0 + 1LL; while (idx <= size) { tree[idx] += init; idx += (idx & (-idx)); } } } // idx is 1 origin void add(ll idx, ll x) { assert(idx > 0LL); while (idx <= size) { tree[idx] += x; idx += (idx & (-idx)); } } // idx is 1 origin ll sum(ll idx) { assert(idx > 0LL); ll ret = 0LL; while (idx > 0LL) { ret += tree[idx]; idx -= (idx & (-idx)); } return ret; } }; struct MaxFlow { V<ll> links[1005]; ll capacities[1005][1005]; ll nodes; MaxFlow(ll nodes) { // i == 0 --> S // i == nodes+1 --> T rep(i, nodes + 2LL) links[i].clear(); memset(capacities, 0, sizeof(capacities)); this->nodes = nodes; } void add_path(ll a, ll b, ll capacity) { links[a].pb(b); links[b].pb(a); capacities[a][b] = capacity; capacities[b][a] = 0LL; } ll solve(void) { deque<V<ll>> q; ll ret = 0LL; for (;; q.clear()) { V<ll> start; start.pb(0); q.push_front(start); bool checked[nodes + 2]; memset(checked, 0, sizeof(checked)); V<ll> found; for (; !(q.empty());) { V<ll> path = q.front(); q.pop_front(); ll last = path[path.size() - 1]; if (checked[last]) continue; if (last == nodes + 1) { found = path; break; } checked[last] = true; for (auto next : (links[last])) { if (capacities[last][next] == 0) continue; V<ll> newpath(path); newpath.pb(next); q.push_front(newpath); } } if (found.size() == 0) { break; } else { ll flowcount = capacities[found[0]][found[1]]; rep(i, found.size() - 1) { ll src = found[i]; ll dst = found[i + 1]; flowcount = min(flowcount, capacities[src][dst]); } rep(i, found.size() - 1) { ll src = found[i]; ll dst = found[i + 1]; capacities[src][dst] -= flowcount; capacities[dst][src] += flowcount; } ret += flowcount; } } return ret; } }; template <typename T> struct SegmentTree { T *nodes; t2 *ranges; // [start, end) ll nodecount; ll itemcount; T unit; T (*op)(T, T); SegmentTree(ll itemcount, T unit, T op(T, T)) { ll orig_itemcount = itemcount; this->itemcount = 1LL; while (this->itemcount < orig_itemcount) this->itemcount *= 2LL; nodecount = this->itemcount * 2 - 1; nodes = new T[nodecount]; ranges = new t2[nodecount]; this->unit = unit; this->op = op; ll start = 0LL; ll end = this->itemcount; ll len = this->itemcount; rep(i, nodecount) { nodes[i] = unit; ranges[i] = t2(start, end); if (end >= this->itemcount) { len /= 2LL; start = 0LL; end = len; } else { start = end; end = start + len; } } } void update(ll k, T v) { ll idx = k + itemcount - 1LL; nodes[idx] = v; idx = (idx - 1LL) / 2LL; for (; idx >= 0; idx = (idx - 1LL) / 2LL) { nodes[idx] = op(nodes[idx * 2LL + 1LL], nodes[idx * 2LL + 2LL]); if (!idx) break; } } T query(ll start, ll end) const { return _query(start, end, 0LL); } T _query(ll start, ll end, ll idx) const { ll rstart = get<0>(ranges[idx]); ll rend = get<1>(ranges[idx]); if (start <= rstart && rend <= end) { return nodes[idx]; } if (rend <= start || end <= rstart) { return unit; } T left = _query(start, end, idx * 2LL + 1LL); T right = _query(start, end, idx * 2LL + 2LL); return op(left, right); } }; void llin(ll &a) { CIN(a); } void llinl1(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a; CIN(a); v.push_back(a); } } void llinl2(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a, b; CIN(a >> b); v.push_back(t2(a, b)); } } void llinl3(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a, b, c; CIN(a >> b >> c); v.push_back(t3(a, b, c)); } } void llinl4(auto &v, ll count) { for (ll i = 0LL; i < count; ++i) { ll a, b, c, d; CIN(a >> b >> c >> d); v.push_back(t4(a, b, c, d)); } } void llina(auto &v, ll count) { llinl1(v, count); } template <typename T> T min(const V<T> v) { T ret = v[0]; for (auto i : v) ret = min(ret, i); return ret; } template <typename T> T max(const V<T> v) { T ret = v[0]; for (auto i : v) ret = max(ret, i); return ret; } ll absll(ll x) { if (x < 0) return -x; return x; } ll mod_mlt(ll x, ll y, ll mod) { ll ret = 0LL; x %= mod; while (y) { if (y & 1LL) { ret += x; ret %= mod; } y >>= 1; x <<= 1; x %= mod; } return ret; } ll mod_pow(ll base, ll exp, ll mod) { ll ret = 1LL; for (; exp;) { if (exp & 1LL) { ret *= base; ret %= mod; } base = (base * base) % mod; exp >>= 1; } return ret; } ll mod_inv(ll x, ll mod) { // available only when mod is prime return mod_pow(x, mod - 2LL, mod); } ll gcm(ll x, ll y) { while (y != 0) { ll z = x % y; x = y; y = z; } return x; } template <typename T> void sort(V<T> &v) { sort(v.begin(), v.end()); } template <typename T> void sort_reverse(V<T> &v) { sort(v.begin(), v.end(), greater<T>()); } void get_divisors(V<ll> &retlist, ll x) { for (ll i = 1LL; i < sqrt(x) + 3LL; ++i) { if (x % i == 0LL) { retlist.push_back(i); retlist.push_back(x / i); } } } void get_factors(V<ll> &retlist, ll x) { for (ll i = 2LL; i < (ll)(sqrt(x)) + 3LL; ++i) { while (x % i == 0LL) { retlist.pb(i); x /= i; } } retlist.pb(x); } bool is_prime(ll x) { V<ll> factors, factors2; get_factors(factors, x); for (auto factor : factors) { if (factor > 1) factors2.pb(factor); } return factors2.size() == 1 && x == factors2[0]; } template <typename T> void intersection(const set<T> &a, const set<T> &b, set<T> &result) { set_intersection(ALL(a), ALL(b), inserter(result, result.end())); } ull combination(ll x, ll y) { if (y > x / 2LL) y = x - y; ull ret = 1LL; for (ll i = 0LL; i < y; ++i) { ret *= x--; ret /= (i + 1LL); } return ret; } ull mod_combination(ll x, ll y, ll mod) { if (y > x / 2LL) y = x - y; ll ret = 1; for (ll i = 0LL; i < y; ++i) { ret = (ret * x--) % mod; ret = (ret * mod_inv(i + 1LL, mod)) % mod; } return ret; } void make_linklist(const V<t2> &srclist, V<ll> dstlist[]) { for (auto src : srclist) { ll a = get<0>(src); ll b = get<1>(src); dstlist[a].pb(b); dstlist[b].pb(a); } } void make_parent(const V<ll> linklist[], ll root, ll n, ll parent[], ll level[]) { queue<ll> q; bool checked[n + 1]; memset(checked, 0, sizeof(checked)); q.push(root); checked[root] = true; parent[root] = root; level[root] = 0LL; for (; !(q.empty());) { ll now = q.front(); q.pop(); for (auto next : linklist[now]) { if (checked[next]) continue; q.push(next); checked[next] = true; parent[next] = now; level[next] = level[now] + 1LL; } } } #define POW_ANCESTOR_MAXSIZE 20 // preprocess for get_common_ancestor() void make_pow_ancestor(const ll parent[], ll n, ll (*pow_ancestor)[POW_ANCESTOR_MAXSIZE]) { rep(i, n) pow_ancestor[i + 1][0] = parent[i + 1]; for (int pow2 = 1; pow(2, pow2) <= n; ++pow2) { rep(i0, n) { int i = i0 + 1; ll prev = pow_ancestor[i][pow2 - 1]; pow_ancestor[i][pow2] = pow_ancestor[prev][pow2 - 1]; } } } ll get_common_ancestor(ll n, ll x, ll y, const ll (*pow_ancestor)[POW_ANCESTOR_MAXSIZE], const ll level[]) { if (level[x] < level[y]) { ll diff = level[y] - level[x]; for (; diff;) { ll bit = diff & -diff; y = pow_ancestor[y][(int)log2(bit)]; diff -= bit; } } else { ll diff = level[x] - level[y]; for (; diff;) { ll bit = diff & -diff; x = pow_ancestor[x][(int)log2(bit)]; diff -= bit; } } if (x == y) return x; rrep(i, (int)log2(n) + 1) { if (pow_ancestor[x][i] != pow_ancestor[y][i]) { x = pow_ancestor[x][i]; y = pow_ancestor[y][i]; } } return pow_ancestor[x][0]; } void debug_print(auto x) { cout << x << endl; } void debug_print(const t2 &x) { ll x1 = get<0>(x); ll x2 = get<1>(x); cout << "-- " << x1 << " -- " << x2 << endl; } void debug_print(const t3 &x) { ll x1 = get<0>(x); ll x2 = get<1>(x); ll x3 = get<2>(x); cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << endl; } void debug_print(const t4 &x) { ll x1 = get<0>(x); ll x2 = get<1>(x); ll x3 = get<2>(x); ll x4 = get<3>(x); cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << " -- " << x4 << endl; } template <typename T> void debug_print(T xarray[], ll n) { rep(i, n) debug_print(xarray[i]); } template <typename T> void debug_print(const V<T> &xlist) { for (auto x : xlist) { cout << "-- "; debug_print(x); } } template <typename T> void debug_print(const set<T> &xset) { for (auto x : xset) { cout << "-- "; debug_print(x); } } template <typename S, typename T> void debug_print(const M<S, T> &xlist) { for (auto x : xlist) { S k = x.first; T v = x.second; cout << "====" << endl; cout << "K="; debug_print(k); cout << "V="; debug_print(v); } } int _main(); int main() { cout << setprecision(12); return _main(); } /////////////////////////////////////////////////////////////////////////////// int _main() { ll n; llin(n); V<ll> alist; llinl1(alist, n); V<ll> floors; floors.pb(alist[0]); ll ans = 1LL; srep(i, 1, n) { int left = 0; int right = floors.size() - 1; int tmp = (left + right) / 2; int idx = n + 5; for (; left <= right; tmp = (left + right) / 2) { if (floors[tmp] < alist[i]) { idx = min(idx, tmp); right = tmp - 1; } else { left = tmp + 1; } } if (idx > n) { ans++; floors.pb(alist[i]); } else { floors[idx] = alist[i]; } } cout << ans; return 0; } ///////////////////////////////////////////////////////////////////////////////
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
780,983
780,984
u167931717
cpp
p02973
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> using namespace std; typedef long long ll; ll mod = 1e9 + 7; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { int n; cin >> n; deque<int> d; rep(i, n) { int a; cin >> a; int idx = lower_bound(d.begin(), d.end(), a) - d.begin(); if (idx <= 0) { d.push_front(a); } else { d[idx] = a; } } cout << (int)d.size() << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> using namespace std; typedef long long ll; ll mod = 1e9 + 7; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { int n; cin >> n; deque<int> d; rep(i, n) { int a; cin >> a; int idx = lower_bound(d.begin(), d.end(), a) - d.begin() - 1; // cout << i << " " << idx << endl; if (idx < 0) { d.push_front(a); } else { d[idx] = a; } } cout << (int)d.size() << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
780,985
780,986
u596311864
cpp
p02973
#include <bits/stdc++.h> #include <cstdint> #include <vector> #define FOR(i, l, r) for (int i = (l); i < (r); ++i) #define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, n - 1, 0) #define int long long using namespace std; const int MX = 1e6; const int inf = 1e9; const int mod = 998244353; using ll = long long; using P = pair<ll, ll>; double PI = acos(-1); signed main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; deque<int> d; rep(i, n) { int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin(); if (p == 0) { d.push_front(a[i]); } else { d[p] = a[i]; } } cout << d.size() << endl; return 0; }
#include <bits/stdc++.h> #include <cstdint> #include <vector> #define FOR(i, l, r) for (int i = (l); i < (r); ++i) #define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, n - 1, 0) #define int long long using namespace std; const int MX = 1e6; const int inf = 1e9; const int mod = 998244353; using ll = long long; using P = pair<ll, ll>; double PI = acos(-1); signed main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; deque<int> d; rep(i, n) { int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin(); if (p == 0) { d.push_front(a[i]); } else { d[p - 1] = a[i]; } } cout << d.size() << endl; return 0; }
[ "assignment.change" ]
780,987
780,988
u762160119
cpp
p02973
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 5; multiset<int> st; multiset<int>::iterator it; int n, A[M]; int main() { scanf("%d", &n); for (int i = 1, res; i <= n; i++) { scanf("%d", &A[i]); } for (int i = n; i >= 1; i--) { it = st.upper_bound(A[i]); if (it != st.end()) st.erase(*it); st.insert(A[i]); } printf("%d\n", st.size()); return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 5; multiset<int> st; multiset<int>::iterator it; int n, A[M]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (int i = n; i >= 1; i--) { it = st.upper_bound(A[i]); if (it != st.end()) st.erase(it); st.insert(A[i]); } printf("%d\n", st.size()); return 0; }
[ "control_flow.loop.for.initializer.change", "variable_declaration.remove", "call.arguments.change" ]
780,993
780,994
u941446746
cpp
p02973
#include <bits/stdc++.h> #define ll long long #define INF 1999122700 using namespace std; int n; int a[200004], f[200004]; map<int, int> mert; bool check(int len, int x) { return (mert[len - 1] >= x); } int main() { mert.clear(); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); f[1] = 1; mert[0] = INF; mert[1] = a[1]; int res = 1; for (int i = 2; i <= n; i++) { int mid, L = 1, R = i, ans = 1; while (L <= R) { mid = (L + R) >> 1; if (check(mid, a[i])) { ans = mid; L = mid + 1; } else R = mid - 1; } if (!mert.count(ans)) mert[ans] = a[i]; else mert[ans] = max(mert[ans], a[i]); f[i] = ans; res = max(res, ans); } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> #define ll long long #define INF 1999122700 using namespace std; int n; int a[200004], f[200004]; map<int, int> mert; bool check(int len, int x) { return (mert[len - 1] >= x); } int main() { mert.clear(); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); f[1] = 1; mert[0] = INF; mert[1] = a[1]; int res = 1; for (int i = 2; i <= n; i++) { int mid, L = 1, R = res + 1, ans = 1; while (L <= R) { mid = (L + R) >> 1; if (check(mid, a[i])) { ans = mid; L = mid + 1; } else R = mid - 1; } if (!mert.count(ans)) mert[ans] = a[i]; else mert[ans] = max(mert[ans], a[i]); f[i] = ans; res = max(res, ans); } printf("%d\n", res); return 0; }
[ "assignment.change" ]
780,999
781,000
u628253919
cpp
p02973
#include <bits/stdc++.h> #define ll long long #define INF 1999122700 using namespace std; int n; int a[200004], f[200004]; map<int, int> mert; bool check(int len, int x) { return (mert[len - 1] >= x); } int main() { mert.clear(); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); f[1] = 1; mert[0] = INF; mert[1] = a[1]; int res = 0; for (int i = 2; i <= n; i++) { int mid, L = 1, R = i, ans = 1; while (L <= R) { mid = (L + R) >> 1; if (check(mid, a[i])) { ans = mid; L = mid + 1; } else R = mid - 1; } if (!mert.count(ans)) mert[ans] = a[i]; else mert[ans] = max(mert[ans], a[i]); f[i] = ans; res = max(res, ans); } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> #define ll long long #define INF 1999122700 using namespace std; int n; int a[200004], f[200004]; map<int, int> mert; bool check(int len, int x) { return (mert[len - 1] >= x); } int main() { mert.clear(); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); f[1] = 1; mert[0] = INF; mert[1] = a[1]; int res = 1; for (int i = 2; i <= n; i++) { int mid, L = 1, R = res + 1, ans = 1; while (L <= R) { mid = (L + R) >> 1; if (check(mid, a[i])) { ans = mid; L = mid + 1; } else R = mid - 1; } if (!mert.count(ans)) mert[ans] = a[i]; else mert[ans] = max(mert[ans], a[i]); f[i] = ans; res = max(res, ans); } printf("%d\n", res); return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
781,001
781,000
u628253919
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; multiset<int> m; m.insert(arr[0]); // cout << *m.begin() ; for (int i = 1; i < n; i++) { if (arr[i] > *m.begin()) { auto it = m.upper_bound(arr[i]); it--; m.erase(it); m.insert(arr[i]); } else m.insert(arr[i]); } cout << m.size(); }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; multiset<int> m; m.insert(arr[0]); // cout << *m.begin() ; for (int i = 1; i < n; i++) { if (arr[i] > *m.begin()) { auto it = m.lower_bound(arr[i]); it--; m.erase(it); m.insert(arr[i]); } else m.insert(arr[i]); } cout << m.size(); }
[ "call.function.change" ]
781,002
781,003
u506112954
cpp
p02973
#include <bits/stdc++.h> #define ll long long using namespace std; int n, a[(int)1e5 + 10]; int cnt, que[(int)1e5 + 10]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int i, j, num[2] = {0, 0}; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; cnt = 0, que[0] = -100000; for (i = n - 1; i > -1; i--) { if (a[i] >= que[cnt]) que[++cnt] = a[i]; else { int l = 1, r = cnt, mid; while (l <= r) { mid = (l + r) >> 1; if (a[i] > que[mid]) l = mid + 1; else r = mid - 1; } que[l] = a[i]; } } printf("%d\n", cnt); return 0; } /* 5 0 4 3 2 1 5 2 1 4 5 3 */
#include <bits/stdc++.h> #define ll long long using namespace std; int n, a[(int)1e5 + 10]; int cnt, que[(int)1e5 + 10]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int i, j, num[2] = {0, 0}; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; cnt = 0, que[0] = -100000; for (i = n - 1; i > -1; i--) { if (a[i] >= que[cnt]) que[++cnt] = a[i]; else { int l = 1, r = cnt, mid; while (l <= r) { mid = (l + r) >> 1; if (a[i] >= que[mid]) l = mid + 1; else r = mid - 1; } que[l] = a[i]; } } printf("%d\n", cnt); return 0; } /* 5 2 1 4 3 0 5 2 1 4 5 3 */
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
781,004
781,005
u006421797
cpp
p02973
#include <bits/stdc++.h> #define ll long long using namespace std; int n, a[(int)1e5 + 10]; int cnt, que[(int)1e5 + 10]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int i, j, num[2] = {0, 0}; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; cnt = 0, que[0] = -100000; for (i = n - 1; i > -1; i--) { if (a[i] > que[cnt]) que[++cnt] = a[i]; else { int l = 1, r = cnt, mid; while (l <= r) { mid = (l + r) >> 1; if (a[i] > que[mid]) l = mid + 1; else r = mid - 1; } que[l] = a[i]; } } printf("%d\n", cnt); return 0; } /* 5 0 4 3 2 1 5 2 1 4 5 3 */
#include <bits/stdc++.h> #define ll long long using namespace std; int n, a[(int)1e5 + 10]; int cnt, que[(int)1e5 + 10]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int i, j, num[2] = {0, 0}; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; cnt = 0, que[0] = -100000; for (i = n - 1; i > -1; i--) { if (a[i] >= que[cnt]) que[++cnt] = a[i]; else { int l = 1, r = cnt, mid; while (l <= r) { mid = (l + r) >> 1; if (a[i] >= que[mid]) l = mid + 1; else r = mid - 1; } que[l] = a[i]; } } printf("%d\n", cnt); return 0; } /* 5 2 1 4 3 0 5 2 1 4 5 3 */
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
781,006
781,005
u006421797
cpp
p02973
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N; int main() { cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; multiset<int> set; for (int i = 0; i < N; i++) { if (set.lower_bound(A[i]) != set.begin()) { int num = *prev(set.lower_bound(A[i])); set.erase(num); } set.insert(A[i]); } cout << set.size() << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N; int main() { cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; multiset<int> set; for (int i = 0; i < N; i++) { if (set.lower_bound(A[i]) != set.begin()) { auto num = prev(set.lower_bound(A[i])); set.erase(num); } set.insert(A[i]); } cout << set.size() << endl; return 0; }
[]
781,010
781,011
u134381136
cpp
p02973
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<long> group; for (int i = 0; i < n; i++) { long a; cin >> a; if (group.size() == 0 || group[0] > a) { // cout << "Insert top " << a << endl; group.insert(group.begin(), a); } else { auto pos = lower_bound(group.begin(), group.end(), a); --pos; // cout << "Update " << *pos << " to " << a << endl; *pos = a; } } cout << group.size() << endl; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<long> group; for (int i = 0; i < n; i++) { long a; cin >> a; if (group.size() == 0 || group[0] >= a) { // cout << "Insert top " << a << endl; group.insert(group.begin(), a); } else { auto pos = lower_bound(group.begin(), group.end(), a); --pos; // cout << "Update " << *pos << " to " << a << endl; *pos = a; } } cout << group.size() << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
781,012
781,013
u199912250
cpp
p02973
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> group; for (int i = 0; i < n; i++) { int a; cin >> a; if (group.size() == 0 || group[0] > a) { // cout << "Insert top " << a << endl; group.insert(group.begin(), a); } else { auto pos = lower_bound(group.begin(), group.end(), a); --pos; // cout << "Update " << *pos << " to " << a << endl; *pos = a; } } cout << group.size() << endl; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<long> group; for (int i = 0; i < n; i++) { long a; cin >> a; if (group.size() == 0 || group[0] >= a) { // cout << "Insert top " << a << endl; group.insert(group.begin(), a); } else { auto pos = lower_bound(group.begin(), group.end(), a); --pos; // cout << "Update " << *pos << " to " << a << endl; *pos = a; } } cout << group.size() << endl; }
[ "variable_declaration.type.primitive.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
781,014
781,013
u199912250
cpp
p02973
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // #include "prettyprint.hpp" int main() { int N; cin >> N; long A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } multiset<long, less<long>> bst; bst.insert(A[0]); for (int i = 1; i < N; i++) { if (A[i] <= *bst.begin()) { bst.insert(A[i]); } else { set<long>::iterator it = bst.lower_bound(A[i]); it--; // cout << *it << endl; // cout << "low of " << A[i] << " : " << *it << endl; bst.erase(*it); bst.insert(A[i]); } // cout << bst << endl; } cout << bst.size() << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // #include "prettyprint.hpp" int main() { int N; cin >> N; long A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } multiset<long, less<long>> bst; bst.insert(A[0]); for (int i = 1; i < N; i++) { if (A[i] <= *bst.begin()) { bst.insert(A[i]); } else { set<long>::iterator it = bst.lower_bound(A[i]); it--; // cout << *it << endl; // cout << "low of " << A[i] << " : " << *it << endl; bst.erase(it); bst.insert(A[i]); } // cout << bst << endl; } cout << bst.size() << endl; return 0; }
[ "call.arguments.change" ]
781,021
781,022
u439911726
cpp
p02973
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) cin >> A[i]; multiset<int> S; int res = 0; for (int i = 0; i < N; ++i) { auto itr = S.lower_bound(A[i]); if (S.empty() || itr == S.begin()) { ++res; S.insert(A[i]); } else { S.erase(*(--itr)); S.insert(A[i]); } } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) cin >> A[i]; multiset<int> S; int res = 0; for (int i = 0; i < N; ++i) { auto itr = S.lower_bound(A[i]); if (S.empty() || itr == S.begin()) { ++res; S.insert(A[i]); } else { S.erase(--itr); S.insert(A[i]); } } cout << res << endl; }
[ "call.arguments.change" ]
781,023
781,024
u645369394
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define REP(i, n) for (ll i = 0; i < n; i++) #define FOR(i, n1, n2) for (ll i = n1; i < n2; i++) #define bFOR(i, n1, n2) for (ll i = n1; i >= n2; i--) #define speed_up \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; typedef pair<ll, ll> Pi; const int INF = (ll)(1LL << 30) - 1; const double INFd = 100000000000.0; const ll INFl = (ll)9223372036854775807; const int MAX = 10000; const ll MOD = (ll)1e9 + 7; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int dx[4] = {0, -1, 0, 1}, dy[4] = {-1, 0, 1, 0}; int mdx[8] = {0, 1, 0, -1, 1, 1, -1, -1}, mdy[8] = {-1, 0, 1, 0, 1, -1, 1, -1}; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } ll n; ll a[100100]; multiset<ll> s1; ll ans = 1; int main() { cin >> n; REP(i, n) { cin >> a[i]; } s1.insert(a[0]); for (ll i = 1; i < n; i++) { auto it = s1.lower_bound(a[i]); if (it == s1.begin()) { s1.insert(a[i]); ans++; } else { s1.erase(*(--it)); s1.insert(a[i]); } // cout<<ans<<endl } cout << s1.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define REP(i, n) for (ll i = 0; i < n; i++) #define FOR(i, n1, n2) for (ll i = n1; i < n2; i++) #define bFOR(i, n1, n2) for (ll i = n1; i >= n2; i--) #define speed_up \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; typedef pair<ll, ll> Pi; const int INF = (ll)(1LL << 30) - 1; const double INFd = 100000000000.0; const ll INFl = (ll)9223372036854775807; const int MAX = 10000; const ll MOD = (ll)1e9 + 7; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int dx[4] = {0, -1, 0, 1}, dy[4] = {-1, 0, 1, 0}; int mdx[8] = {0, 1, 0, -1, 1, 1, -1, -1}, mdy[8] = {-1, 0, 1, 0, 1, -1, 1, -1}; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } ll n; ll a[100100]; multiset<ll> s1; ll ans = 1; int main() { cin >> n; REP(i, n) { cin >> a[i]; } s1.insert(a[0]); for (ll i = 1; i < n; i++) { auto it = s1.lower_bound(a[i]); if (it == s1.begin()) { s1.insert(a[i]); ans++; } else { s1.erase(--it); s1.insert(a[i]); } // cout<<ans<<endl } cout << s1.size() << endl; return 0; }
[ "call.arguments.change" ]
781,025
781,026
u055303078
cpp
p02973
#include "bits/stdc++.h" using namespace std; int main() { int n; scanf("%d", &n); set<int> st; int result = 0; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); auto it = st.lower_bound(x); if (it == st.begin()) { result++; } else { it--; st.erase(it); } st.insert(x); } cout << result << endl; }
#include "bits/stdc++.h" using namespace std; int main() { int n; scanf("%d", &n); multiset<int> st; int result = 0; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); auto it = st.lower_bound(x); if (it == st.begin()) { result++; } else { it--; st.erase(it); } st.insert(x); } cout << result << endl; }
[ "variable_declaration.type.change" ]
781,027
781,028
u753391427
cpp
p02973
#include <bits/stdc++.h> using namespace std; const int maxn = (1e5 + 10); int n, a[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> v; int cnt = 0; for (int i = 0; i < n; i++) { if (v.size() == 0) { ++cnt; v.push_back(a[i]); continue; } if (a[i] <= v[0]) { ++cnt; v.insert(v.begin(), a[i]); continue; } int tmp = upper_bound(v.begin(), v.end(), a[i]) - v.begin(); --tmp; v.erase(v.begin() + tmp); v.insert(v.begin() + tmp, a[i]); } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = (1e5 + 10); int n, a[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> v; int cnt = 0; for (int i = 0; i < n; i++) { if (v.size() == 0) { ++cnt; v.push_back(a[i]); continue; } if (a[i] <= v[0]) { ++cnt; v.insert(v.begin(), a[i]); continue; } int tmp = lower_bound(v.begin(), v.end(), a[i]) - v.begin(); --tmp; v.erase(v.begin() + tmp); v.insert(v.begin() + tmp, a[i]); } cout << cnt << endl; return 0; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
781,029
781,030
u954081460
cpp
p02973
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; using ld = long double; const ll mod = 1000000007; const ll inf = 1e18; #define REP(i, n) for (ll i = 0; i < (n); ++i) #define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i) #define all(x) (x).begin(), (x).end() ll power(ll base, ll exponent) { if (exponent % 2) { return power(base, exponent - 1) * base % mod; } else if (exponent) { ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; } else { return 1; } } ll inverse(ll x) { return power(x, mod - 2); } ll gcd(ll a, ll b) { if (a < b) gcd(b, a); ll r; while (r = a % b) { a = b; b = r; } return b; } template <typename T> ll sum(T begin, T end) { return accumulate(begin, end, 0ll); } struct combination { vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1) { fact[0] = 1; for (int i = 1; i <= sz; i++) { fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for (int i = sz - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const { if (q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } }; int bsearch(const vector<ll> &a, ll x) { int lft = 0; int rgt = a.size(); while (rgt - lft > 1) { int mid = (lft + rgt) / 2; if (a[mid] < x) { lft = mid; } else { rgt = mid; } } return lft; } template <class VAL> struct RBST { VAL SUM_UNITY = 0; // to be set unsigned int randInt() { static unsigned int tx = 123456789, ty = 362436069, tz = 521288629, tw = 88675123; unsigned int tt = (tx ^ (tx << 11)); tx = ty; ty = tz; tz = tw; return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8))); } struct NODE { NODE *left, *right; VAL val; // the value of the node int size; // the size of the subtree VAL sum; // the value-sum of the subtree NODE() : val(SUM_UNITY), size(1), sum(SUM_UNITY) { left = right = NULL; } NODE(VAL v) : val(v), size(1), sum(v) { left = right = NULL; } /* additional update */ inline void update() {} /* additional lazy-propagation */ inline void push() { /* ex: reverse */ /* if (this->rev) { swap(this->left, this->right); if (this->left) this->left->rev ^= true; if (this->right) this->right->rev ^= true; this->rev = false; } */ } }; /////////////////////// // root /////////////////////// NODE *root; RBST() : root(NULL) {} RBST(NODE *node) : root(node) {} /////////////////////// // basic operations /////////////////////// /* size */ inline int size(NODE *node) { return !node ? 0 : node->size; } inline int size() { return this->size(this->root); } /* sum */ inline VAL sum(NODE *node) { return !node ? SUM_UNITY : node->sum; } inline VAL sum() { return this->sum(this->root); } /* update, push */ inline NODE *update(NODE *node) { node->size = size(node->left) + size(node->right) + 1; node->sum = sum(node->left) + sum(node->right) + node->val; node->update(); return node; } inline void push(NODE *node) { if (!node) return; node->push(); } /* lower_bound */ inline int lowerBound(NODE *node, VAL val) { push(node); if (!node) return 0; if (val <= node->val) return lowerBound(node->left, val); else return size(node->left) + lowerBound(node->right, val) + 1; } inline int lowerBound(VAL val) { return this->lowerBound(this->root, val); } /* upper_bound */ inline int upperBound(NODE *node, VAL val) { push(node); if (!node) return 0; if (val >= node->val) return size(node->left) + upperBound(node->right, val) + 1; else return upperBound(node->left, val); } inline int upperBound(VAL val) { return this->upperBound(this->root, val); } // pytran inline int upperBoundVal(NODE *node, VAL val) { push(node); if (!node) return 0; if (val >= node->val) return size(node->left) + upperBound(node->right, val) + 1; else return upperBound(node->left, val); } /* count */ inline int count(VAL val) { return upperBound(val) - lowerBound(val); } /* get --- k: 0-index */ inline VAL get(NODE *node, int k) { push(node); if (!node) return -1; if (k == size(node->left)) return node->val; if (k < size(node->left)) return get(node->left, k); else return get(node->right, k - size(node->left) - 1); } inline VAL get(int k) { return get(this->root, k); } /////////////////////// // merge-split /////////////////////// NODE *merge(NODE *left, NODE *right) { push(left); push(right); if (!left || !right) { if (left) return left; else return right; } if (randInt() % (left->size + right->size) < left->size) { left->right = merge(left->right, right); return update(left); } else { right->left = merge(left, right->left); return update(right); } } void merge(RBST add) { this->root = this->merge(this->root, add.root); } pair<NODE *, NODE *> split(NODE *node, int k) { // [0, k), [k, n) push(node); if (!node) return make_pair(node, node); if (k <= size(node->left)) { pair<NODE *, NODE *> sub = split(node->left, k); node->left = sub.second; return make_pair(sub.first, update(node)); } else { pair<NODE *, NODE *> sub = split(node->right, k - size(node->left) - 1); node->right = sub.first; return make_pair(update(node), sub.second); } } RBST split(int k) { pair<NODE *, NODE *> sub = split(this->root, k); this->root = sub.first; return RBST(sub.second); } /////////////////////// // insert-erase /////////////////////// void insert(const VAL val) { pair<NODE *, NODE *> sub = this->split(this->root, this->lowerBound(val)); this->root = this->merge(this->merge(sub.first, new NODE(val)), sub.second); } void erase(const VAL val) { if (!this->count(val)) return; pair<NODE *, NODE *> sub = this->split(this->root, this->lowerBound(val)); this->root = this->merge(sub.first, this->split(sub.second, 1).second); } /////////////////////// // debug /////////////////////// void print(NODE *node) { if (!node) return; push(node); print(node->left); cout << node->val << " "; print(node->right); } void print() { cout << "{"; print(this->root); cout << "}" << endl; } }; signed main() { ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n); RBST<ll> b; map<ll, ll> c; REP(i, n) cin >> a[i]; // REP(i, n) b.insert(a[i]); // REP(i, 10) { // cout << i << ":" << b.upperBound(i) << endl; // } // cout << "---" << endl; // REP(i, 3) { // cout << i << ":" << b.get((int)i) << endl; // } for (int i = n; i >= 0; i--) { int index = b.upperBound(a[i]); if (index == b.size()) { b.insert(a[i]); c[a[i]]++; continue; } ll val = b.get(index); if (val == a[i]) { c[a[i]]++; continue; } b.erase(val); c[val]--; b.insert(a[i]); c[a[i]]++; } // b.print(); ll ans = 0; for (const auto &i : c) ans += i.second; cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; using ld = long double; const ll mod = 1000000007; const ll inf = 1e18; #define REP(i, n) for (ll i = 0; i < (n); ++i) #define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i) #define all(x) (x).begin(), (x).end() ll power(ll base, ll exponent) { if (exponent % 2) { return power(base, exponent - 1) * base % mod; } else if (exponent) { ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; } else { return 1; } } ll inverse(ll x) { return power(x, mod - 2); } ll gcd(ll a, ll b) { if (a < b) gcd(b, a); ll r; while (r = a % b) { a = b; b = r; } return b; } template <typename T> ll sum(T begin, T end) { return accumulate(begin, end, 0ll); } struct combination { vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1) { fact[0] = 1; for (int i = 1; i <= sz; i++) { fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for (int i = sz - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const { if (q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } }; int bsearch(const vector<ll> &a, ll x) { int lft = 0; int rgt = a.size(); while (rgt - lft > 1) { int mid = (lft + rgt) / 2; if (a[mid] < x) { lft = mid; } else { rgt = mid; } } return lft; } template <class VAL> struct RBST { VAL SUM_UNITY = 0; // to be set unsigned int randInt() { static unsigned int tx = 123456789, ty = 362436069, tz = 521288629, tw = 88675123; unsigned int tt = (tx ^ (tx << 11)); tx = ty; ty = tz; tz = tw; return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8))); } struct NODE { NODE *left, *right; VAL val; // the value of the node int size; // the size of the subtree VAL sum; // the value-sum of the subtree NODE() : val(SUM_UNITY), size(1), sum(SUM_UNITY) { left = right = NULL; } NODE(VAL v) : val(v), size(1), sum(v) { left = right = NULL; } /* additional update */ inline void update() {} /* additional lazy-propagation */ inline void push() { /* ex: reverse */ /* if (this->rev) { swap(this->left, this->right); if (this->left) this->left->rev ^= true; if (this->right) this->right->rev ^= true; this->rev = false; } */ } }; /////////////////////// // root /////////////////////// NODE *root; RBST() : root(NULL) {} RBST(NODE *node) : root(node) {} /////////////////////// // basic operations /////////////////////// /* size */ inline int size(NODE *node) { return !node ? 0 : node->size; } inline int size() { return this->size(this->root); } /* sum */ inline VAL sum(NODE *node) { return !node ? SUM_UNITY : node->sum; } inline VAL sum() { return this->sum(this->root); } /* update, push */ inline NODE *update(NODE *node) { node->size = size(node->left) + size(node->right) + 1; node->sum = sum(node->left) + sum(node->right) + node->val; node->update(); return node; } inline void push(NODE *node) { if (!node) return; node->push(); } /* lower_bound */ inline int lowerBound(NODE *node, VAL val) { push(node); if (!node) return 0; if (val <= node->val) return lowerBound(node->left, val); else return size(node->left) + lowerBound(node->right, val) + 1; } inline int lowerBound(VAL val) { return this->lowerBound(this->root, val); } /* upper_bound */ inline int upperBound(NODE *node, VAL val) { push(node); if (!node) return 0; if (val >= node->val) return size(node->left) + upperBound(node->right, val) + 1; else return upperBound(node->left, val); } inline int upperBound(VAL val) { return this->upperBound(this->root, val); } // pytran inline int upperBoundVal(NODE *node, VAL val) { push(node); if (!node) return 0; if (val >= node->val) return size(node->left) + upperBound(node->right, val) + 1; else return upperBound(node->left, val); } /* count */ inline int count(VAL val) { return upperBound(val) - lowerBound(val); } /* get --- k: 0-index */ inline VAL get(NODE *node, int k) { push(node); if (!node) return -1; if (k == size(node->left)) return node->val; if (k < size(node->left)) return get(node->left, k); else return get(node->right, k - size(node->left) - 1); } inline VAL get(int k) { return get(this->root, k); } /////////////////////// // merge-split /////////////////////// NODE *merge(NODE *left, NODE *right) { push(left); push(right); if (!left || !right) { if (left) return left; else return right; } if (randInt() % (left->size + right->size) < left->size) { left->right = merge(left->right, right); return update(left); } else { right->left = merge(left, right->left); return update(right); } } void merge(RBST add) { this->root = this->merge(this->root, add.root); } pair<NODE *, NODE *> split(NODE *node, int k) { // [0, k), [k, n) push(node); if (!node) return make_pair(node, node); if (k <= size(node->left)) { pair<NODE *, NODE *> sub = split(node->left, k); node->left = sub.second; return make_pair(sub.first, update(node)); } else { pair<NODE *, NODE *> sub = split(node->right, k - size(node->left) - 1); node->right = sub.first; return make_pair(update(node), sub.second); } } RBST split(int k) { pair<NODE *, NODE *> sub = split(this->root, k); this->root = sub.first; return RBST(sub.second); } /////////////////////// // insert-erase /////////////////////// void insert(const VAL val) { pair<NODE *, NODE *> sub = this->split(this->root, this->lowerBound(val)); this->root = this->merge(this->merge(sub.first, new NODE(val)), sub.second); } void erase(const VAL val) { if (!this->count(val)) return; pair<NODE *, NODE *> sub = this->split(this->root, this->lowerBound(val)); this->root = this->merge(sub.first, this->split(sub.second, 1).second); } /////////////////////// // debug /////////////////////// void print(NODE *node) { if (!node) return; push(node); print(node->left); cout << node->val << " "; print(node->right); } void print() { cout << "{"; print(this->root); cout << "}" << endl; } }; signed main() { ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n); RBST<ll> b; map<ll, ll> c; REP(i, n) cin >> a[i]; // REP(i, n) b.insert(a[i]); // REP(i, 10) { // cout << i << ":" << b.upperBound(i) << endl; // } // cout << "---" << endl; // REP(i, 3) { // cout << i << ":" << b.get((int)i) << endl; // } for (int i = n - 1; i >= 0; i--) { int index = b.upperBound(a[i]); if (index == b.size()) { b.insert(a[i]); c[a[i]]++; continue; } ll val = b.get(index); if (val == a[i]) { c[a[i]]++; continue; } b.erase(val); c[val]--; b.insert(a[i]); c[a[i]]++; } // b.print(); ll ans = 0; for (const auto &i : c) ans += i.second; // for(const auto& i: c) cout << i.first << ":" << i.second << endl; cout << ans << endl; return 0; }
[ "control_flow.loop.for.initializer.change" ]
781,040
781,041
u702582248
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; constexpr long double EPS = 1e-15; const long double PI = acos(-1); constexpr int inf = 2e9; constexpr ll INF = 2e18; constexpr ll MOD = 1e9 + 7; constexpr ll MOD1 = 998244353; typedef pair<ll, ll> P; //#define all(v) (v).begin(), (v).end() #define rep(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) rep(i, 0, n) #define sz(s) (s).size() #define pb push_back #define fi first #define se second //#define mp make_pair void solve() { int n; cin >> n; map<int, int> mp; REP(i, n) { int a; cin >> a; if (sz(mp) == 0) { mp[a]++; continue; } auto itr = mp.upper_bound(a - 1); if (itr == mp.begin()) { mp[a]++; } else { int k = (*itr).fi; if (mp[k] == 1) { mp.erase(k); mp[a]++; } else { mp[k]--; mp[a]++; } } } int ans = 0; for (auto p : mp) { ans += p.se; } cout << ans << endl; } int main(int argc, char *argv[]) { /* Regular */ int case_num = 1; if (argc > 1 && stoi(argv[1])) cin >> case_num; REP(case_no, case_num) { cerr << endl << "case " << case_no + 1 << endl; solve(); } // /* AOJ */ // solve(); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; constexpr long double EPS = 1e-15; const long double PI = acos(-1); constexpr int inf = 2e9; constexpr ll INF = 2e18; constexpr ll MOD = 1e9 + 7; constexpr ll MOD1 = 998244353; typedef pair<ll, ll> P; //#define all(v) (v).begin(), (v).end() #define rep(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) rep(i, 0, n) #define sz(s) (s).size() #define pb push_back #define fi first #define se second //#define mp make_pair void solve() { int n; cin >> n; map<int, int> mp; REP(i, n) { int a; cin >> a; if (sz(mp) == 0) { mp[a]++; continue; } auto itr = mp.upper_bound(a - 1); // cout << (*itr).fi << endl; if (itr == mp.begin()) { mp[a]++; } else { itr--; int k = (*itr).fi; if (mp[k] == 1) { mp.erase(k); mp[a]++; } else { mp[k]--; mp[a]++; } } // for (auto p: mp) { // cout << p.fi << " "; // } // cout << endl; } int ans = 0; for (auto p : mp) { ans += p.se; } cout << ans << endl; } int main(int argc, char *argv[]) { /* Regular */ int case_num = 1; if (argc > 1 && stoi(argv[1])) cin >> case_num; REP(case_no, case_num) { cerr << endl << "case " << case_no + 1 << endl; solve(); } // /* AOJ */ // solve(); return 0; }
[ "expression.unary.arithmetic.add" ]
781,042
781,043
u891178744
cpp
p02973
// // Created by Tetsuya Shiota on 2019-04-13. // #include <algorithm> #include <bitset> #include <cassert> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define REP(i, b, n) for (Int i = b; i < Int(n); i++) #define rep(i, n) REP(i, 0, n) #define FOR(e, o) for (auto &&e : o) #ifdef LOCAL #define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl #define dump(x) \ cerr << __LINE__ << ' ' << #x << " : "; \ FOR(e, x) cerr << e << ' '; \ cerr << endl; #else #define pp(x) #define dump(x) #endif using namespace std; using Int = long long; using vi = vector<Int>; using vvi = vector<vi>; using pii = pair<Int, Int>; const Int dy[] = {-1, 0, 1, 0}; const Int dx[] = {0, 1, 0, -1}; template <typename T> void reverse(vector<T> &v) { reverse(v.begin(), v.end()); } template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); } template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); } template <typename T> T sum(const vector<T> &v) { return accumulate(v.begin(), v.end(), T(0)); } template <class T> void update_max(T &a, const T &b) { a = max(a, b); } template <class T> void update_min(T &a, const T &b) { a = min(a, b); } vector<pair<char, Int>> merge_cont_char(const string &s) { vector<pair<char, Int>> ret; if (s.empty()) return ret; ret.push_back(make_pair(s[0], 0)); FOR(c, s) { if (ret.back().first == c) ret.back().second++; else ret.push_back(make_pair(c, 1)); } return ret; } class Shakutori { public: // 全体の範囲 // [0, end) // 注目している範囲 // [tail, head) Int head, tail, end = 0; bool moveHead() { if (head == end) { return false; } head++; return true; } void moveTail() { tail++; } bool valid() { if (head == tail) return true; // [tail, head) // が解として適当か検証する return true; } void solve() { head = tail = 0; Int ans = 0; while (moveHead()) { while (!valid()) { moveTail(); } // ここで解を更新する } } }; class Solver { public: Int ans = 0, N; vi A; Solver() {} void input() { cin >> N; A = vi(N); FOR(a, A) cin >> a; } void solve() { set<Int> S; FOR(a, A) { dump(S); auto s = S.lower_bound(a); if (S.empty() || s == S.begin()) { ans++; } else { s--; Int last = *s; S.erase(s); } S.insert(a); } } void output() { cout << ans << endl; } }; void initilization() { struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; cin.tie(nullptr); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } int main() { initilization(); #ifdef LOCAL while (1) { Solver s; s.input(); if (cin.eof()) break; s.solve(); s.output(); } #else Solver s; s.input(); s.solve(); s.output(); #endif return 0; }
// // Created by Tetsuya Shiota on 2019-04-13. // #include <algorithm> #include <bitset> #include <cassert> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define REP(i, b, n) for (Int i = b; i < Int(n); i++) #define rep(i, n) REP(i, 0, n) #define FOR(e, o) for (auto &&e : o) #ifdef LOCAL #define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl #define dump(x) \ cerr << __LINE__ << ' ' << #x << " : "; \ FOR(e, x) cerr << e << ' '; \ cerr << endl; #else #define pp(x) #define dump(x) #endif using namespace std; using Int = long long; using vi = vector<Int>; using vvi = vector<vi>; using pii = pair<Int, Int>; const Int dy[] = {-1, 0, 1, 0}; const Int dx[] = {0, 1, 0, -1}; template <typename T> void reverse(vector<T> &v) { reverse(v.begin(), v.end()); } template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); } template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); } template <typename T> T sum(const vector<T> &v) { return accumulate(v.begin(), v.end(), T(0)); } template <class T> void update_max(T &a, const T &b) { a = max(a, b); } template <class T> void update_min(T &a, const T &b) { a = min(a, b); } vector<pair<char, Int>> merge_cont_char(const string &s) { vector<pair<char, Int>> ret; if (s.empty()) return ret; ret.push_back(make_pair(s[0], 0)); FOR(c, s) { if (ret.back().first == c) ret.back().second++; else ret.push_back(make_pair(c, 1)); } return ret; } class Shakutori { public: // 全体の範囲 // [0, end) // 注目している範囲 // [tail, head) Int head, tail, end = 0; bool moveHead() { if (head == end) { return false; } head++; return true; } void moveTail() { tail++; } bool valid() { if (head == tail) return true; // [tail, head) // が解として適当か検証する return true; } void solve() { head = tail = 0; Int ans = 0; while (moveHead()) { while (!valid()) { moveTail(); } // ここで解を更新する } } }; class Solver { public: Int ans = 0, N; vi A; Solver() {} void input() { cin >> N; A = vi(N); FOR(a, A) cin >> a; } void solve() { multiset<Int> S; FOR(a, A) { dump(S); auto s = S.lower_bound(a); if (S.empty() || s == S.begin()) { ans++; } else { s--; Int last = *s; S.erase(s); } S.insert(a); } } void output() { cout << ans << endl; } }; void initilization() { struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; cin.tie(nullptr); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } int main() { initilization(); #ifdef LOCAL while (1) { Solver s; s.input(); if (cin.eof()) break; s.solve(); s.output(); } #else Solver s; s.input(); s.solve(); s.output(); #endif return 0; }
[ "variable_declaration.type.change" ]
781,044
781,045
u996171098
cpp
p02973
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n; int a[maxn]; int f[maxn]; int tot; int main() { scanf("%d", &n); for (register int i = 1; i <= n; i++) scanf("%d", &a[i]); tot++; f[tot] = a[1]; for (register int i = 2; i <= n; i++) { if (a[i] <= f[tot]) f[++tot] = a[i]; else { int l = 1, r = tot, mid; while (l < r) { int mid = (l + r) >> 1; if (a[i] >= f[mid]) r = mid; else l = mid + 1; } f[l] = a[i]; } } printf("%d\n", tot); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n; int a[maxn]; int f[maxn]; int tot; int main() { scanf("%d", &n); for (register int i = 1; i <= n; i++) scanf("%d", &a[i]); tot++; f[tot] = a[1]; for (register int i = 2; i <= n; i++) { if (a[i] <= f[tot]) f[++tot] = a[i]; else { int l = 1, r = tot, mid; while (l < r) { int mid = (l + r) >> 1; if (a[i] > f[mid]) r = mid; else l = mid + 1; } f[l] = a[i]; } } printf("%d\n", tot); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
781,046
781,047
u088044957
cpp
p02973
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const int inf = 0x3f3f3f3f; int v[maxn], dp[maxn]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &v[i]); } dp[1] = v[1]; int len = 1; for (int i = 2; i <= n; i++) { if (dp[len] >= v[i]) { dp[++len] = v[i]; } else { int l = 1, r = len, mid; while (l <= r) { mid = (l + r) >> 1; if (dp[mid] > v[i]) { l = mid + 1; } else { r = mid - 1; } } dp[r] = v[i]; } } // for (int i = 1 ; i <= n ; i ++ ) { // printf("%d ",dp[i]) ; // } puts("") ; printf("%d\n", len); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const int inf = 0x3f3f3f3f; int v[maxn], dp[maxn]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &v[i]); } dp[1] = v[1]; int len = 1; for (int i = 2; i <= n; i++) { if (dp[len] >= v[i]) { dp[++len] = v[i]; } else { int l = 1, r = len, mid; while (l <= r) { mid = (l + r) >> 1; if (dp[mid] >= v[i]) { l = mid + 1; } else { r = mid - 1; } } dp[l] = v[i]; } } // for (int i = 1 ; i <= n ; i ++ ) { // printf("%d ",dp[i]) ; // } puts("") ; printf("%d\n", len); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
781,048
781,049
u251789483
cpp
p02973
#include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <string> #include <utility> #include <vector> #define ll long long int #define rep(i, x, y) for (int i = x; i < y; i++) #define rel(i, x, y) for (int i = x - 1; i >= y; i--) #define all(x) x.begin(), x.end() using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<int> ans; rep(i, 0, N) cin >> A[i]; ans.push_back(A[0]); rep(i, 1, N) { if (ans.front() >= A[i]) { ans.insert(ans.begin(), A[i]); } else if (ans.back() < A[i]) { ans[ans.size() - 1] = A[i]; } else { auto itr = upper_bound(all(ans), A[i]); --itr; *itr = A[i]; } } cout << ans.size() << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <string> #include <utility> #include <vector> #define ll long long int #define rep(i, x, y) for (int i = x; i < y; i++) #define rel(i, x, y) for (int i = x - 1; i >= y; i--) #define all(x) x.begin(), x.end() using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<int> ans; rep(i, 0, N) cin >> A[i]; ans.push_back(A[0]); rep(i, 1, N) { if (ans.front() >= A[i]) { ans.insert(ans.begin(), A[i]); } else if (ans.back() < A[i]) { ans[ans.size() - 1] = A[i]; } else { auto itr = lower_bound(all(ans), A[i]); --itr; *itr = A[i]; } } cout << ans.size() << endl; }
[ "identifier.change", "call.function.change" ]
781,054
781,055
u352200121
cpp
p02973
#include <stdio.h> #define fo(i, a, b) for (int i = a; i <= b; i++) #define fd(i, a, b) for (int i = a; i >= b; i--) #include <set> using namespace std; int n, a[110000], ans; multiset<int> q; int main() { scanf("%d", &n); fo(i, 1, n) scanf("%d", &a[i]); fo(i, 1, n) { auto it = q.lower_bound(a[i]); if (it == q.begin()) { ans++; q.insert(a[i]); } else { it--; q.erase(*it); q.insert(a[i]); } } printf("%d\n", ans); return 0; }
#include <stdio.h> #define fo(i, a, b) for (int i = a; i <= b; i++) #define fd(i, a, b) for (int i = a; i >= b; i--) #include <set> using namespace std; int n, a[110000], ans; multiset<int> q; int main() { scanf("%d", &n); fo(i, 1, n) scanf("%d", &a[i]); fo(i, 1, n) { auto it = q.lower_bound(a[i]); if (it == q.begin()) { ans++; q.insert(a[i]); } else { it--; q.erase(it); // erase(*it) q.insert(a[i]); } } printf("%d\n", ans); return 0; }
[ "call.arguments.change" ]
781,056
781,057
u651274386
cpp
p02973
#include <bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; */ using namespace std; #define ll long long #define ull unsigned long long #define f(a, b) for (ll i = a; i < b; i++) #define mod 1000000007 #define mp make_pair #define pb push_back #define pl pair<ll, ll> #define vll vector<ll> #define pll vector<pair<ll, ll>> #define ld long double #define fr(a, b) for (ll j = a; j >= b; j--) #define fi(a, b) for (ll j = a; j < b; j++) #define fii(a, b) for (ll k = a; k < b; k++) #define print(x) cerr << #x << " is " << x << endl; // typedef tree<ll // ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> // ordered_set; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "rt", stdin); // freopen("output.txt", "wt", stdout); // #endif ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; ll a[n]; f(0, n) cin >> a[i]; set<ll> s; ll ans = 0; fr(n - 1, 0) { auto it = s.upper_bound(a[j]); if (it == s.end()) ans++; else s.erase(it); s.insert(a[j]); } cout << ans; return 0; }
#include <bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; */ using namespace std; #define ll long long #define ull unsigned long long #define f(a, b) for (ll i = a; i < b; i++) #define mod 1000000007 #define mp make_pair #define pb push_back #define pl pair<ll, ll> #define vll vector<ll> #define pll vector<pair<ll, ll>> #define ld long double #define fr(a, b) for (ll j = a; j >= b; j--) #define fi(a, b) for (ll j = a; j < b; j++) #define fii(a, b) for (ll k = a; k < b; k++) #define print(x) cerr << #x << " is " << x << endl; // typedef tree<ll // ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> // ordered_set; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "rt", stdin); // freopen("output.txt", "wt", stdout); // #endif ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; ll a[n]; f(0, n) cin >> a[i]; multiset<ll> s; ll ans = 0; fr(n - 1, 0) { auto it = s.upper_bound(a[j]); if (it == s.end()) ans++; else s.erase(it); s.insert(a[j]); } cout << ans; return 0; }
[ "variable_declaration.type.change" ]
781,058
781,059
u875459711
cpp
p02973
#include <iostream> #include <set> #include <vector> using namespace std; int main() { cin.tie(0); int n; cin >> n; vector<int64_t> a(n); for (auto &r : a) { cin >> r; } multiset<int64_t> ss; for (auto &r : a) { // cout << "* " << ss.size() << endl; // for (auto &s: ss) { // cout << " * " << s << endl; // } auto it = ss.upper_bound(-r); if (it == ss.end()) { ss.insert(-r); } else { ss.erase(*it); ss.insert(-r); } } cout << ss.size() << endl; return 0; }
#include <iostream> #include <set> #include <vector> using namespace std; int main() { cin.tie(0); int n; cin >> n; vector<int64_t> a(n); for (auto &r : a) { cin >> r; } multiset<int64_t> ss; for (auto &r : a) { // cout << "* " << ss.size() << endl; // for (auto &s: ss) { // cout << " * " << s << endl; // } auto it = ss.upper_bound(-r); if (it == ss.end()) { ss.insert(-r); } else { ss.erase(it); ss.insert(-r); } } cout << ss.size() << endl; return 0; }
[ "call.arguments.change" ]
781,060
781,061
u932038818
cpp
p02973
#include <bits/stdc++.h> using namespace std; set<int> S; int main() { int N, A, cnt = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> A; auto it = S.upper_bound(A); if (it == S.begin()) { cnt++; S.insert(A); } else { it--; S.erase(it); S.insert(A); } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; multiset<int> S; int main() { int N, A, cnt = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> A; auto it = S.lower_bound(A); if (it == S.begin()) { cnt++; S.insert(A); } else { it--; S.erase(it); S.insert(A); } } cout << cnt << endl; }
[ "variable_declaration.type.change", "call.function.change" ]
781,062
781,063
u045811375
cpp
p02973
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; #define MP make_pair #define PB push_back #define ll long long #define int long long #define f(i, x, n) for (int i = x; i < n; i++) #define ld long double #define mod 1000000007 int n; int a[100005]; multiset<int> se; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; f(i, 0, n) { cin >> a[i]; } se.insert(a[0]); int ans = 1; f(i, 1, n) { // cout<<ans<<endl; if (*(se.begin()) < a[i]) { auto itr = se.upper_bound(a[i]); itr--; se.erase(itr); se.insert(a[i]); } else { se.insert(a[i]); ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; #define MP make_pair #define PB push_back #define ll long long #define int long long #define f(i, x, n) for (int i = x; i < n; i++) #define ld long double #define mod 1000000007 int n; int a[100005]; multiset<int> se; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; f(i, 0, n) { cin >> a[i]; } se.insert(a[0]); int ans = 1; f(i, 1, n) { // cout<<ans<<endl; if (*(se.begin()) < a[i]) { auto itr = se.lower_bound(a[i]); itr--; se.erase(itr); se.insert(a[i]); } else { se.insert(a[i]); ans++; } } cout << ans << endl; return 0; }
[ "call.function.change" ]
781,066
781,067
u054388349
cpp
p02973
#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; const int INF = numeric_limits<int>::max(); const ll MOD = 1000000007; template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } int main() { int n; cin >> n; vl a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vi maxi; maxi.push_back(a[0]); int colors = 1; for (int i = 1; i < n; ++i) { if (a[i] > maxi[0]) maxi[0] = a[i]; else if (a[i] <= maxi.back()) { colors++; maxi.push_back(a[i]); } else { int ok = 0; int ng = maxi.size() - 1; while (ok + 1 != ng) { int mid = (ng + ok) / 2; if (maxi[mid] < a[i]) ok = mid; else ng = mid; } maxi[ok] = a[i]; } } cout << colors << "\n"; return 0; }
#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; const int INF = numeric_limits<int>::max(); const ll MOD = 1000000007; template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } int main() { int n; cin >> n; vl a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vi maxi; maxi.push_back(a[0]); int colors = 1; for (int i = 1; i < n; ++i) { if (a[i] > maxi[0]) maxi[0] = a[i]; else if (a[i] <= maxi.back()) { colors++; maxi.push_back(a[i]); } else { int ng = 0; int ok = maxi.size() - 1; while (ng + 1 != ok) { int mid = (ng + ok) / 2; if (maxi[mid] < a[i]) ok = mid; else ng = mid; } maxi[ok] = a[i]; } } cout << colors << "\n"; return 0; }
[ "variable_declaration.name.change", "identifier.change", "control_flow.loop.condition.change" ]
781,068
781,069
u756088996
cpp
p02973
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <sys/time.h> #include <vector> //#include "cout.h" using namespace std; #define SZ(x) ((int)x.size()) #define MSET(x, a) memset(x, a, (int)sizeof(x)) #define PB push_back #define VI vector<int> #define PII pair<int, int> #define LL long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() #define FIT(it, v) \ for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++) #define OUT(A) cout << #A << " = " << (A) << endl #define OUT2(A, B) \ cout << "(" << #A << ", " << #B << ") = (" << (A) << ", " << (B) << ")" \ << endl template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(ALL(c), (e)) != (c).end()) int n; VI v; void solve() { cin >> n; REP(_, n) { LL a; cin >> a; auto itr = upper_bound(ALL(v), a); auto target = itr - v.begin() - 1; if (target < 0) v.insert(itr, a); else if (v[target] < a) v[target] = a; else v.insert(itr, a); } cout << SZ(v) << endl; } int main() { solve(); return 0; }
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <sys/time.h> #include <vector> //#include "cout.h" using namespace std; #define SZ(x) ((int)x.size()) #define MSET(x, a) memset(x, a, (int)sizeof(x)) #define PB push_back #define VI vector<int> #define PII pair<int, int> #define LL long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() #define FIT(it, v) \ for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++) #define OUT(A) cout << #A << " = " << (A) << endl #define OUT2(A, B) \ cout << "(" << #A << ", " << #B << ") = (" << (A) << ", " << (B) << ")" \ << endl template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(ALL(c), (e)) != (c).end()) int n; VI v; void solve() { cin >> n; REP(_, n) { LL a; cin >> a; auto itr = lower_bound(ALL(v), a); auto target = itr - v.begin() - 1; if (target < 0) v.insert(itr, a); else if (v[target] < a) v[target] = a; else v.insert(itr, a); // REP(i, SZ(v)) cout << v[i] << " "; // cout << endl; } cout << SZ(v) << endl; } int main() { solve(); return 0; }
[ "identifier.change", "call.function.change" ]
781,070
781,071
u307578234
cpp
p02973
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<int> st; int t; int ans = 0; for (int i = 0; i < n; ++i) { cin >> t; auto it = st.lower_bound(t); if (it == st.begin()) { st.insert(t); ++ans; } else { --it; st.erase(it); st.insert(t); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; multiset<int> st; int t; int ans = 0; for (int i = 0; i < n; ++i) { cin >> t; auto it = st.lower_bound(t); if (it == st.begin()) { st.insert(t); ++ans; } else { --it; st.erase(it); st.insert(t); } } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
781,076
781,077
u604693716
cpp
p02973
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; int a[maxn]; int d[maxn]; int main() { int i, j, k, m, n; cin >> n; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } int top = 0; for (i = n; i >= 1; i--) { if (a[i] >= d[top]) d[++top] = a[i]; int x = upper_bound(d + 1, d + n + 1, a[i]) - d; d[x] = a[i]; } printf("%d\n", top); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; int a[maxn]; int d[maxn]; int main() { int i, j, k, m, n; cin >> n; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } int top = 0; for (i = n; i >= 1; i--) { if (a[i] >= d[top]) d[++top] = a[i]; else { int x = upper_bound(d + 1, d + top + 1, a[i]) - d; d[x] = a[i]; } } printf("%d\n", top); return 0; }
[ "control_flow.branch.else.add", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
781,078
781,079
u478540642
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define int long long int n; int a[100020]; int f[100020]; signed main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } reverse(a, a + n); memset(f, 0x3f, sizeof f); for (int i = 0; i < n; i++) { int p = upper_bound(f, f + n, a[i]) - f; f[p] = a[i]; } int ans2 = upper_bound(f, f + n, 0x3f3f3f3f) - f; cout << ans2 << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long int n; int a[100020]; int f[100020]; signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } reverse(a, a + n); memset(f, 0x3f, sizeof f); for (int i = 0; i < n; i++) { int p = upper_bound(f, f + n, a[i]) - f; f[p] = a[i]; } int ans2 = upper_bound(f, f + n, 0x3f3f3f3f) - f; cout << ans2 << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
781,088
781,089
u453809729
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define int long long int n; int a[100020]; int f[100020]; signed main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } reverse(a, a + n); memset(f, 0x3f, sizeof f); for (int i = 0; i < n; i++) { int p = upper_bound(f, f + n, a[i]) - f; f[p] = a[i]; } int ans2 = lower_bound(f, f + n, 0x3f3f3f3f) - f; cout << ans2 << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long int n; int a[100020]; int f[100020]; signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } reverse(a, a + n); memset(f, 0x3f, sizeof f); for (int i = 0; i < n; i++) { int p = upper_bound(f, f + n, a[i]) - f; f[p] = a[i]; } int ans2 = upper_bound(f, f + n, 0x3f3f3f3f) - f; cout << ans2 << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "identifier.change", "call.function.change" ]
781,090
781,089
u453809729
cpp
p02973
//==========================Head files========================== #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define LL long long #define db double #define mp make_pair #define pr pair<int, int> #define fir first #define sec second #define pb push_back #define ms(i, j) memset(i, j, sizeof i) using namespace std; //==========================Templates========================== inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } inline LL readl() { LL x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } int power(int a, int b) { int ans = 1; while (b) { if (b & 1) ans = ans * a; b >>= 1; a = a * a; } return ans; } int power_mod(int a, int b, int mod) { a %= mod; int ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; b >>= 1, a = (a * a) % mod; } return ans; } LL powerl(LL a, LL b) { LL ans = 1ll; while (b) { if (b & 1ll) ans = ans * a; b >>= 1ll; a = a * a; } return ans; } LL power_modl(LL a, LL b, LL mod) { a %= mod; LL ans = 1ll; while (b) { if (b & 1ll) ans = (ans * a) % mod; b >>= 1ll, a = (a * a) % mod; } return ans; } LL gcdl(LL a, LL b) { return b == 0 ? a : gcdl(b, a % b); } LL abssl(LL a) { return a > 0 ? a : -a; } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int abss(int a) { return a > 0 ? a : -a; } //==========================Main body========================== #define LD "%I64d" #define D "%d" #define pt printf #define sn scanf #define pty printf("YES\n") #define ptn printf("NO\n") //==========================Code here========================== int len, n, a[100000 + 5], b[100000 + 5]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), a[i] = -a[i]; b[1] = a[1], len = 1; for (int i = 2; i <= n; ++i) { if (a[i] >= b[len]) b[++len] = a[i]; else { int p = lower_bound(b + 1, b + 1 + len, a[i]) - b; // ×¢Òâ upper_bound b[p] = a[i]; } } printf("%d\n", len); return 0; }
//==========================Head files========================== #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define LL long long #define db double #define mp make_pair #define pr pair<int, int> #define fir first #define sec second #define pb push_back #define ms(i, j) memset(i, j, sizeof i) using namespace std; //==========================Templates========================== inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } inline LL readl() { LL x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } int power(int a, int b) { int ans = 1; while (b) { if (b & 1) ans = ans * a; b >>= 1; a = a * a; } return ans; } int power_mod(int a, int b, int mod) { a %= mod; int ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; b >>= 1, a = (a * a) % mod; } return ans; } LL powerl(LL a, LL b) { LL ans = 1ll; while (b) { if (b & 1ll) ans = ans * a; b >>= 1ll; a = a * a; } return ans; } LL power_modl(LL a, LL b, LL mod) { a %= mod; LL ans = 1ll; while (b) { if (b & 1ll) ans = (ans * a) % mod; b >>= 1ll, a = (a * a) % mod; } return ans; } LL gcdl(LL a, LL b) { return b == 0 ? a : gcdl(b, a % b); } LL abssl(LL a) { return a > 0 ? a : -a; } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int abss(int a) { return a > 0 ? a : -a; } //==========================Main body========================== #define LD "%I64d" #define D "%d" #define pt printf #define sn scanf #define pty printf("YES\n") #define ptn printf("NO\n") //==========================Code here========================== int len, n, a[100000 + 5], b[100000 + 5]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), a[i] = -a[i]; b[1] = a[1], len = 1; for (int i = 2; i <= n; ++i) { if (a[i] >= b[len]) b[++len] = a[i]; else { int p = upper_bound(b + 1, b + 1 + len, a[i]) - b; // ×¢Òâ upper_bound b[p] = a[i]; } } printf("%d\n", len); return 0; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
781,091
781,092
u774596402
cpp
p02973
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; #define MOD 1000000007 #define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); i++) #define REP(i, n) rep(i, 0, n) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; // priority_queue<ll> max;//大きい順 // priority_queue<ll, Array, greater<ll>> min;//小さい順 /*firstについては昇順 secondについては降順 sort(all(wh), [&](P x, P y) { if (x.first == y.first)return x.second > y.second; return x.first < y.first; }); */ template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // substr 文字列取り出し // upper_bound // ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う // stoi struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag) G[to].push_back(Edge( from, revCap, (ll)G[from].size() - 1)); //最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } //二分グラフの最大マッチングを求めたりも出来る また二部グラフの最大独立集合は頂点数-最大マッチングのサイズ ll max_flow(Graph &G, ll s, ll t) // O(V(V+E)) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { // O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size()) d[i] = INF; REP(i, d.size()) negative[i] = false; d[s] = 0; REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true) negative[G[i][j].to] = true; } } } } void Dijkstra(Graph &G, ll s, Array &d) { // O(|E|log|V|) d.resize(G.size()); REP(i, d.size()) d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first) continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } void WarshallFloyd(Graph &G, Matrix &d) { // O(V^3) d.resize(G.size()); REP(i, d.size()) d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } bool tsort(Graph &graph, vector<int> &order) { //トポロジカルソートO(E+V) int n = graph.size(), k = 0; Array in(n); for (auto &es : graph) for (auto &e : es) in[e.to]++; priority_queue<ll, Array, greater<ll>> que; REP(i, n) if (in[i] == 0) que.push(i); while (que.size()) { int v = que.top(); que.pop(); order.push_back(v); for (auto &e : graph[v]) if (--in[e.to] == 0) que.push(e.to); } if (order.size() != n) return false; else return true; } class lca { public: const int n = 0; const int log2_n = 0; std::vector<std::vector<int>> parent; std::vector<int> depth; lca() {} lca(const Graph &g, int root) : n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n) { dfs(g, root, -1, 0); for (int k = 0; k + 1 < log2_n; k++) { for (int v = 0; v < (int)g.size(); v++) { if (parent[k][v] < 0) parent[k + 1][v] = -1; else parent[k + 1][v] = parent[k][parent[k][v]]; } } } void dfs(const Graph &g, int v, int p, int d) { parent[0][v] = p; depth[v] = d; for (auto &e : g[v]) { if (e.to != p) dfs(g, e.to, v, d + 1); } } int get(int u, int v) { if (depth[u] > depth[v]) std::swap(u, v); for (int k = 0; k < log2_n; k++) { if ((depth[v] - depth[u]) >> k & 1) { v = parent[k][v]; } } if (u == v) return u; for (int k = log2_n - 1; k >= 0; k--) { if (parent[k][u] != parent[k][v]) { u = parent[k][u]; v = parent[k][v]; } } return parent[0][u]; } }; class UnionFind { vector<int> data; ll num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(int x, int y) { // xとyの集合を統合する x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } num -= (x != y); return x != y; } bool findSet(int x, int y) { // xとyが同じ集合か返す return root(x) == root(y); } int root(int x) { // xのルートを返す return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { // xの集合のサイズを返す return -data[root(x)]; } int numSet() { //集合の数を返す return num; } }; class SumSegTree { private: int _sum(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return 0; // 交差しない if (a <= l && r <= b) return dat[k]; // a,l,r,bの順で完全に含まれる else { int s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 int s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return s1 + s2; } } public: int n, height; vector<int> dat; // 初期化(_nは最大要素数) SumSegTree(int _n) { n = 1; height = 1; while (n < _n) { n *= 2; height++; } dat = vector<int>(2 * n - 1, 0); } // 場所i(0-indexed)にxを足す void add(int i, int x) { i += n - 1; // i番目の葉ノードへ dat[i] += x; while (i > 0) { // 下から上がっていく i = (i - 1) / 2; dat[i] += x; } } // 区間[a,b)の総和。ノードk=[l,r)に着目している。 int sum(int a, int b) { return _sum(a, b, 0, 0, n); } }; class RmqTree { private: ll _find(ll a, ll b, ll k, ll l, ll r) { if (r <= a || b <= l) return INF; // 交差しない if (a <= l && r <= b) return dat[k]; // a,l,r,bの順で完全に含まれる else { ll s1 = _find(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 ll s2 = _find(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return min(s1, s2); } } public: ll n, height; vector<ll> dat; // 初期化(_nは最大要素数) RmqTree(ll _n) { n = 1; height = 1; while (n < _n) { n *= 2; height++; } dat = vector<ll>(2 * n - 1, INF); } // 場所i(0-indexed)をxにする void update(ll i, ll x) { i += n - 1; // i番目の葉ノードへ dat[i] = x; while (i > 0) { // 下から上がっていく i = (i - 1) / 2; dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]); } } // 区間[a,b)の最小値。ノードk=[l,r)に着目している。 ll find(ll a, ll b) { return _find(a, b, 0, 0, n); } }; //約数求める //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } vector<ll> lis_fast(const vector<ll> &a) { //最長部分増加列 const ll n = a.size(); vector<ll> A(n, INT_MAX); vector<ll> id(n); for (int i = 0; i < n; ++i) { id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i])); A[id[i]] = a[i]; } ll m = *max_element(id.begin(), id.end()); vector<ll> b(m + 1); for (int i = n - 1; i >= 0; --i) if (id[i] == m) b[m--] = a[i]; return b; } ll ModPow(ll x, ll n) { ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } // nCrとか class Combination { public: Array fact; Array inv; ll mod; ll mod_inv(ll x) { ll n = mod - 2LL; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } ll nHr(ll n, ll r) { return nCr(r + n - 1, r); } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } Matrix mIdentity(ll n) { Matrix A(n, Array(n)); for (int i = 0; i < n; ++i) A[i][i] = 1; return A; } Matrix mMul(const Matrix &A, const Matrix &B) { Matrix C(A.size(), Array(B[0].size())); for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[i].size(); ++j) for (int k = 0; k < A[i].size(); ++k) (C[i][j] += (A[i][k] % MOD) * (B[k][j] % MOD)) %= MOD; return C; } // O( n^3 log e ) Matrix mPow(const Matrix &A, ll e) { return e == 0 ? mIdentity(A.size()) : e % 2 == 0 ? mPow(mMul(A, A), e / 2) : mMul(A, mPow(A, e - 1)); } template <class T> class RectangleSum { public: vector<vector<T>> sum; T GetSum(int left, int right, int top, int bottom) { //[left, right], [top, bottom] T res = sum[bottom][right]; if (left > 0) res -= sum[bottom][left - 1]; if (top > 0) res -= sum[top - 1][right]; if (left > 0 && top > 0) res += sum[top - 1][left - 1]; return res; } RectangleSum(const vector<vector<T>> &s, int h, int w) { sum.resize(h); for (int i = 0; i < h; i++) sum[i].resize(w, 0); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { sum[y][x] = s[y][x]; if (y > 0) sum[y][x] += sum[y - 1][x]; if (x > 0) sum[y][x] += sum[y][x - 1]; if (y > 0 && x > 0) sum[y][x] -= sum[y - 1][x - 1]; } } } }; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; Array a(n); REP(i, n) cin >> a[i]; multiset<ll> se; se.insert(INF); REP(i, n) { auto itr = se.lower_bound(a[i]); if (itr == se.begin()) { se.insert(a[i]); } else { itr--; se.erase(*itr); se.insert(a[i]); } } cout << se.size() - 1 << endl; return 0; }
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; #define MOD 1000000007 #define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); i++) #define REP(i, n) rep(i, 0, n) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; // priority_queue<ll> max;//大きい順 // priority_queue<ll, Array, greater<ll>> min;//小さい順 /*firstについては昇順 secondについては降順 sort(all(wh), [&](P x, P y) { if (x.first == y.first)return x.second > y.second; return x.first < y.first; }); */ template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // substr 文字列取り出し // upper_bound // ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う // stoi struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag) G[to].push_back(Edge( from, revCap, (ll)G[from].size() - 1)); //最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } //二分グラフの最大マッチングを求めたりも出来る また二部グラフの最大独立集合は頂点数-最大マッチングのサイズ ll max_flow(Graph &G, ll s, ll t) // O(V(V+E)) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { // O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size()) d[i] = INF; REP(i, d.size()) negative[i] = false; d[s] = 0; REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true) negative[G[i][j].to] = true; } } } } void Dijkstra(Graph &G, ll s, Array &d) { // O(|E|log|V|) d.resize(G.size()); REP(i, d.size()) d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first) continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } void WarshallFloyd(Graph &G, Matrix &d) { // O(V^3) d.resize(G.size()); REP(i, d.size()) d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } bool tsort(Graph &graph, vector<int> &order) { //トポロジカルソートO(E+V) int n = graph.size(), k = 0; Array in(n); for (auto &es : graph) for (auto &e : es) in[e.to]++; priority_queue<ll, Array, greater<ll>> que; REP(i, n) if (in[i] == 0) que.push(i); while (que.size()) { int v = que.top(); que.pop(); order.push_back(v); for (auto &e : graph[v]) if (--in[e.to] == 0) que.push(e.to); } if (order.size() != n) return false; else return true; } class lca { public: const int n = 0; const int log2_n = 0; std::vector<std::vector<int>> parent; std::vector<int> depth; lca() {} lca(const Graph &g, int root) : n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n) { dfs(g, root, -1, 0); for (int k = 0; k + 1 < log2_n; k++) { for (int v = 0; v < (int)g.size(); v++) { if (parent[k][v] < 0) parent[k + 1][v] = -1; else parent[k + 1][v] = parent[k][parent[k][v]]; } } } void dfs(const Graph &g, int v, int p, int d) { parent[0][v] = p; depth[v] = d; for (auto &e : g[v]) { if (e.to != p) dfs(g, e.to, v, d + 1); } } int get(int u, int v) { if (depth[u] > depth[v]) std::swap(u, v); for (int k = 0; k < log2_n; k++) { if ((depth[v] - depth[u]) >> k & 1) { v = parent[k][v]; } } if (u == v) return u; for (int k = log2_n - 1; k >= 0; k--) { if (parent[k][u] != parent[k][v]) { u = parent[k][u]; v = parent[k][v]; } } return parent[0][u]; } }; class UnionFind { vector<int> data; ll num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(int x, int y) { // xとyの集合を統合する x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } num -= (x != y); return x != y; } bool findSet(int x, int y) { // xとyが同じ集合か返す return root(x) == root(y); } int root(int x) { // xのルートを返す return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { // xの集合のサイズを返す return -data[root(x)]; } int numSet() { //集合の数を返す return num; } }; class SumSegTree { private: int _sum(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return 0; // 交差しない if (a <= l && r <= b) return dat[k]; // a,l,r,bの順で完全に含まれる else { int s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 int s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return s1 + s2; } } public: int n, height; vector<int> dat; // 初期化(_nは最大要素数) SumSegTree(int _n) { n = 1; height = 1; while (n < _n) { n *= 2; height++; } dat = vector<int>(2 * n - 1, 0); } // 場所i(0-indexed)にxを足す void add(int i, int x) { i += n - 1; // i番目の葉ノードへ dat[i] += x; while (i > 0) { // 下から上がっていく i = (i - 1) / 2; dat[i] += x; } } // 区間[a,b)の総和。ノードk=[l,r)に着目している。 int sum(int a, int b) { return _sum(a, b, 0, 0, n); } }; class RmqTree { private: ll _find(ll a, ll b, ll k, ll l, ll r) { if (r <= a || b <= l) return INF; // 交差しない if (a <= l && r <= b) return dat[k]; // a,l,r,bの順で完全に含まれる else { ll s1 = _find(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 ll s2 = _find(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return min(s1, s2); } } public: ll n, height; vector<ll> dat; // 初期化(_nは最大要素数) RmqTree(ll _n) { n = 1; height = 1; while (n < _n) { n *= 2; height++; } dat = vector<ll>(2 * n - 1, INF); } // 場所i(0-indexed)をxにする void update(ll i, ll x) { i += n - 1; // i番目の葉ノードへ dat[i] = x; while (i > 0) { // 下から上がっていく i = (i - 1) / 2; dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]); } } // 区間[a,b)の最小値。ノードk=[l,r)に着目している。 ll find(ll a, ll b) { return _find(a, b, 0, 0, n); } }; //約数求める //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } vector<ll> lis_fast(const vector<ll> &a) { //最長部分増加列 const ll n = a.size(); vector<ll> A(n, INT_MAX); vector<ll> id(n); for (int i = 0; i < n; ++i) { id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i])); A[id[i]] = a[i]; } ll m = *max_element(id.begin(), id.end()); vector<ll> b(m + 1); for (int i = n - 1; i >= 0; --i) if (id[i] == m) b[m--] = a[i]; return b; } ll ModPow(ll x, ll n) { ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } // nCrとか class Combination { public: Array fact; Array inv; ll mod; ll mod_inv(ll x) { ll n = mod - 2LL; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } ll nHr(ll n, ll r) { return nCr(r + n - 1, r); } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } Matrix mIdentity(ll n) { Matrix A(n, Array(n)); for (int i = 0; i < n; ++i) A[i][i] = 1; return A; } Matrix mMul(const Matrix &A, const Matrix &B) { Matrix C(A.size(), Array(B[0].size())); for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[i].size(); ++j) for (int k = 0; k < A[i].size(); ++k) (C[i][j] += (A[i][k] % MOD) * (B[k][j] % MOD)) %= MOD; return C; } // O( n^3 log e ) Matrix mPow(const Matrix &A, ll e) { return e == 0 ? mIdentity(A.size()) : e % 2 == 0 ? mPow(mMul(A, A), e / 2) : mMul(A, mPow(A, e - 1)); } template <class T> class RectangleSum { public: vector<vector<T>> sum; T GetSum(int left, int right, int top, int bottom) { //[left, right], [top, bottom] T res = sum[bottom][right]; if (left > 0) res -= sum[bottom][left - 1]; if (top > 0) res -= sum[top - 1][right]; if (left > 0 && top > 0) res += sum[top - 1][left - 1]; return res; } RectangleSum(const vector<vector<T>> &s, int h, int w) { sum.resize(h); for (int i = 0; i < h; i++) sum[i].resize(w, 0); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { sum[y][x] = s[y][x]; if (y > 0) sum[y][x] += sum[y - 1][x]; if (x > 0) sum[y][x] += sum[y][x - 1]; if (y > 0 && x > 0) sum[y][x] -= sum[y - 1][x - 1]; } } } }; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; Array a(n); REP(i, n) cin >> a[i]; multiset<ll> se; se.insert(INF); REP(i, n) { auto itr = se.lower_bound(a[i]); if (itr == se.begin()) { se.insert(a[i]); } else { itr--; se.erase(itr); se.insert(a[i]); } } cout << se.size() - 1 << endl; return 0; }
[ "call.arguments.change" ]
781,095
781,096
u051493691
cpp
p02973
#include <algorithm> #include <iostream> #include <string> #include <vector> #define int long long #define mod 1000000007 using namespace std; vector<int> v; int n, a[123456]; signed main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; v.push_back(a[n - 1]); for (int i = n - 2; i >= 0; i--) { if (v[v.size() - 1] <= a[i]) { v.push_back(a[i]); } else { auto ir = lower_bound(v.begin(), v.end(), a[i]); v.erase(ir); v.insert(ir, a[i]); } } cout << v.size() << endl; }
#include <algorithm> #include <iostream> #include <vector> #define int long long #define mod 1000000007 using namespace std; vector<int> v; int n, a[123456]; signed main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; v.push_back(a[n - 1]); for (int i = n - 2; i >= 0; i--) { if (v[v.size() - 1] <= a[i]) { v.push_back(a[i]); } else { auto ir = upper_bound(v.begin(), v.end(), a[i]); v.erase(ir); v.insert(ir, a[i]); } } cout << v.size() << endl; }
[ "identifier.change", "call.function.change" ]
781,097
781,098
u141968173
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ll long long int #define ull unsigned long long int #define ld long double #define mod 1000000007 #define inf 1000000000000000007 #define eps 0.000000000001 #define pi 3.141592653589793 #define pii pair<int, int> #define pdd pair<ld, ld> #define pll pair<ll, ll> #define ff first #define ss second #define vii vector<int> #define vpl vector<pll> #define vll vector<ll> #define mseti multiset<ll> #define msetd multiset<ll, greater<ll>> #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define stp setprecision(20) // use fixed before stp #define endl '\n' int main() { FAST ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } mseti m; for (ll i = n; i >= 0; i--) { if (m.ub(a[i]) == m.end()) { m.insert(a[i]); } else { m.erase(m.lb(a[i])); m.insert(a[i]); } } cout << m.size(); }
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ll long long int #define ull unsigned long long int #define ld long double #define mod 1000000007 #define inf 1000000000000000007 #define eps 0.000000000001 #define pi 3.141592653589793 #define pii pair<int, int> #define pdd pair<ld, ld> #define pll pair<ll, ll> #define ff first #define ss second #define vii vector<int> #define vpl vector<pll> #define vll vector<ll> #define mseti multiset<ll> #define msetd multiset<ll, greater<ll>> #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define stp setprecision(20) // use fixed before stp #define endl '\n' int main() { FAST ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } mseti m; for (ll i = n - 1; i >= 0; i--) { if (m.ub(a[i]) == m.end()) { m.insert(a[i]); } else { m.erase(m.ub(a[i])); m.insert(a[i]); } } cout << m.size(); }
[ "control_flow.loop.for.initializer.change", "call.function.change", "call.arguments.change" ]
781,099
781,100
u002419600
cpp
p02973
#pragma GCC optimize("O2") #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdarg> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define whlie while #define retunr return #define reutrn return #define reutnr return #define mp make_pair #define pb push_back #define eb emplace_back #define fi first #define se second #define inf 1001001001 #define infLL (1LL << 61) #define FOR(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); (i)++) // [a,b) #define rep(i, N) FOR((i), 0, (int)(N)) // [0,N) #define FORR(i, a, b) for (int(i) = (int)(b)-1; (i) >= (int)(a); (i)--) #define repr(i, N) FORR((i), 0, (int)(N)) #define each(x, v) for (auto &x : v) #define all(v) (v).begin(), (v).end() #define sz(v) ((int)(v).size()) #define vrep(v, it) for (auto it = v.begin(); it != v.end(); it++) #define vrepr(v, it) for (auto it = v.rbegin(); it != v.rend(); it++) #define ini(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define inl(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define inc(...) \ char __VA_ARGS__; \ in(__VA_ARGS__) #define ins(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define ind(...) \ double __VA_ARGS__; \ in(__VA_ARGS__) #define inpii(...) \ pii __VA_ARGS__; \ in(__VA_ARGS__) //#define rand mtrand //#define randinit random_device seed_gen; mt19937 mtrand(seed_gen()+2) #ifdef LOCAL #define trc(...) \ do { \ cout << #__VA_ARGS__ << " = "; \ dbg_out(__VA_ARGS__); \ } while (0) #define stopif(val) assert(!(val)) #define trcv(v, ...) \ do { \ cout << #v << " = "; \ vector_debug(v, ##__VA_ARGS__); \ cout << endl; \ } while (0) #else #define trc(...) #define stopif(...) #define trcv(...) #endif using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vpii = vector<pii>; using vvi = vector<vector<int>>; struct IoSetupNya { IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); } } iosetupnya; /* int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);} ll gcd(ll a, ll b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);} ll lcm(int a, int b){return (1LL * a / gcd(a,b)) * b;} ll lcm(ll a, ll b){return (a / gcd(a,b)) * b;} */ inline ll pow(int a, int b) { ll ans = 1; rep(i, b) ans *= a; return ans; } inline ll pow(ll a, ll b) { ll ans = 1; rep(i, b) ans *= a; return ans; } inline ll pow(int a, ll b) { ll ans = 1; rep(i, b) ans *= a; return ans; } inline ll pow(ll a, int b) { ll ans = 1; rep(i, b) ans *= a; return ans; } template <typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; } template <typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; } template <typename C> inline void _cin(C &c) { cin >> c; } template <typename T, typename U> inline void _cin(pair<T, U> &p) { cin >> p.fi; cin >> p.se; } template <typename C> inline void _cout(const C &c) { cout << c; } template <typename T, typename U> inline void _cout(const pair<T, U> &p) { cout << p.fi << ' ' << p.se; } void in() {} template <typename T, class... U> void in(T &t, U &...u) { _cin(t); in(u...); } void out() { cout << "\n"; } template <typename T, class... U> void out(const T &t, U... u) { _cout(t); if (sizeof...(u)) cout << ' '; out(u...); } template <typename C> inline void in(vector<C> &v, int N = -1) { if (sz(v) != 0) { int M = (N == -1) ? sz(v) : N; rep(i, M) _cin(v[i]); } else { C c; rep(i, N) v.pb((_cin(c), c)); } } template <typename C> inline void in(C v[], int N) { rep(i, N) _cin(v[i]); } template <typename C> inline void out(const vector<C> &v, int N = -1) { int M = (N == -1) ? sz(v) : N; rep(i, M) { cout << ((i) ? " " : ""); _cout(v[i]); } cout << "\n"; } template <typename C> inline void out(C v[], int N) { rep(i, N) { cout << ((i) ? " " : ""); _cout(v[i]); } cout << "\n"; } template <typename C> inline void vector_debug(const vector<C> &v, int N = -1) { cout << "{"; int M = (N == -1) ? sz(v) : N; rep(i, M) { cout << ((i) ? ", " : ""); _cout(v[i]); } cout << "}"; } template <typename C> inline void vector_debug(C v[], int N) { cout << "{"; rep(i, N) { cout << ((i) ? ", " : ""); _cout(*(v + i)); } cout << "}"; } void dbg_out() { cout << endl; } template <typename T, class... U> void dbg_out(const T &t, U... u) { _cout(t); if (sizeof...(u)) cout << ", "; dbg_out(u...); } template <typename C, class... U> void dbg_out(const vector<C> &v, U... u) { vector_debug(v); if (sizeof...(u)) cout << ", "; dbg_out(u...); } template <typename C, class... U> void dbg_out(const vector<vector<C>> &v, U... u) { cout << "{ "; rep(i, sz(v)) { if (i) cout << ", "; vector_debug(v[i]); } cout << " }"; if (sizeof...(u)) cout << ", "; dbg_out(u...); } template <typename C> inline C vmax(const vector<C> &v) { C n = v[0]; rep(i, sz(v)) amax(n, v[i]); return n; } template <typename C> inline C vmax(C v[], int N) { C n = v[0]; rep(i, N) amax(n, v[i]); return n; } template <typename C> inline C vmin(const vector<C> &v) { C n = v[0]; rep(i, sz(v)) amin(n, v[i]); return n; } template <typename C> inline C vmin(C v[], int N) { C n = v[0]; rep(i, N) amin(n, v[i]); return n; } void die(string s) { out(s); exit(0); } //////////// /// main /// //////////// int main() { ini(N); vi a(N); in(a, N); vi ans(N + 1, -inf); rep(i, N) { auto it = lower_bound(all(ans), a[i], [](int a, int b) { return a > b; }); *it = a[i]; } auto it = lower_bound(all(ans), -inf, [](int a, int b) { return a > b; }); out(it - ans.begin()); }
#pragma GCC optimize("O2") #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdarg> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define whlie while #define retunr return #define reutrn return #define reutnr return #define mp make_pair #define pb push_back #define eb emplace_back #define fi first #define se second #define inf 1001001001 #define infLL (1LL << 61) #define FOR(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); (i)++) // [a,b) #define rep(i, N) FOR((i), 0, (int)(N)) // [0,N) #define FORR(i, a, b) for (int(i) = (int)(b)-1; (i) >= (int)(a); (i)--) #define repr(i, N) FORR((i), 0, (int)(N)) #define each(x, v) for (auto &x : v) #define all(v) (v).begin(), (v).end() #define sz(v) ((int)(v).size()) #define vrep(v, it) for (auto it = v.begin(); it != v.end(); it++) #define vrepr(v, it) for (auto it = v.rbegin(); it != v.rend(); it++) #define ini(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define inl(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define inc(...) \ char __VA_ARGS__; \ in(__VA_ARGS__) #define ins(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define ind(...) \ double __VA_ARGS__; \ in(__VA_ARGS__) #define inpii(...) \ pii __VA_ARGS__; \ in(__VA_ARGS__) //#define rand mtrand //#define randinit random_device seed_gen; mt19937 mtrand(seed_gen()+2) #ifdef LOCAL #define trc(...) \ do { \ cout << #__VA_ARGS__ << " = "; \ dbg_out(__VA_ARGS__); \ } while (0) #define stopif(val) assert(!(val)) #define trcv(v, ...) \ do { \ cout << #v << " = "; \ vector_debug(v, ##__VA_ARGS__); \ cout << endl; \ } while (0) #else #define trc(...) #define stopif(...) #define trcv(...) #endif using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vpii = vector<pii>; using vvi = vector<vector<int>>; struct IoSetupNya { IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); } } iosetupnya; /* int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);} ll gcd(ll a, ll b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);} ll lcm(int a, int b){return (1LL * a / gcd(a,b)) * b;} ll lcm(ll a, ll b){return (a / gcd(a,b)) * b;} */ inline ll pow(int a, int b) { ll ans = 1; rep(i, b) ans *= a; return ans; } inline ll pow(ll a, ll b) { ll ans = 1; rep(i, b) ans *= a; return ans; } inline ll pow(int a, ll b) { ll ans = 1; rep(i, b) ans *= a; return ans; } inline ll pow(ll a, int b) { ll ans = 1; rep(i, b) ans *= a; return ans; } template <typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; } template <typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; } template <typename C> inline void _cin(C &c) { cin >> c; } template <typename T, typename U> inline void _cin(pair<T, U> &p) { cin >> p.fi; cin >> p.se; } template <typename C> inline void _cout(const C &c) { cout << c; } template <typename T, typename U> inline void _cout(const pair<T, U> &p) { cout << p.fi << ' ' << p.se; } void in() {} template <typename T, class... U> void in(T &t, U &...u) { _cin(t); in(u...); } void out() { cout << "\n"; } template <typename T, class... U> void out(const T &t, U... u) { _cout(t); if (sizeof...(u)) cout << ' '; out(u...); } template <typename C> inline void in(vector<C> &v, int N = -1) { if (sz(v) != 0) { int M = (N == -1) ? sz(v) : N; rep(i, M) _cin(v[i]); } else { C c; rep(i, N) v.pb((_cin(c), c)); } } template <typename C> inline void in(C v[], int N) { rep(i, N) _cin(v[i]); } template <typename C> inline void out(const vector<C> &v, int N = -1) { int M = (N == -1) ? sz(v) : N; rep(i, M) { cout << ((i) ? " " : ""); _cout(v[i]); } cout << "\n"; } template <typename C> inline void out(C v[], int N) { rep(i, N) { cout << ((i) ? " " : ""); _cout(v[i]); } cout << "\n"; } template <typename C> inline void vector_debug(const vector<C> &v, int N = -1) { cout << "{"; int M = (N == -1) ? sz(v) : N; rep(i, M) { cout << ((i) ? ", " : ""); _cout(v[i]); } cout << "}"; } template <typename C> inline void vector_debug(C v[], int N) { cout << "{"; rep(i, N) { cout << ((i) ? ", " : ""); _cout(*(v + i)); } cout << "}"; } void dbg_out() { cout << endl; } template <typename T, class... U> void dbg_out(const T &t, U... u) { _cout(t); if (sizeof...(u)) cout << ", "; dbg_out(u...); } template <typename C, class... U> void dbg_out(const vector<C> &v, U... u) { vector_debug(v); if (sizeof...(u)) cout << ", "; dbg_out(u...); } template <typename C, class... U> void dbg_out(const vector<vector<C>> &v, U... u) { cout << "{ "; rep(i, sz(v)) { if (i) cout << ", "; vector_debug(v[i]); } cout << " }"; if (sizeof...(u)) cout << ", "; dbg_out(u...); } template <typename C> inline C vmax(const vector<C> &v) { C n = v[0]; rep(i, sz(v)) amax(n, v[i]); return n; } template <typename C> inline C vmax(C v[], int N) { C n = v[0]; rep(i, N) amax(n, v[i]); return n; } template <typename C> inline C vmin(const vector<C> &v) { C n = v[0]; rep(i, sz(v)) amin(n, v[i]); return n; } template <typename C> inline C vmin(C v[], int N) { C n = v[0]; rep(i, N) amin(n, v[i]); return n; } void die(string s) { out(s); exit(0); } //////////// /// main /// //////////// int main() { ini(N); vi a(N); in(a, N); vi ans(N + 1, -inf); rep(i, N) { auto it = upper_bound(all(ans), a[i], [](int a, int b) { return a > b; }); *it = a[i]; trc(ans); } auto it = lower_bound(all(ans), -inf, [](int a, int b) { return a > b; }); out(it - ans.begin()); }
[ "identifier.change", "call.function.change", "call.add" ]
781,101
781,102
u168578024
cpp
p02973
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int lis(vector<int> &A) { int N = A.size(); vector<int> L(N); L[0] = A[0]; int len = 1; for (int i = 1; i < N; i++) { if (L[len - 1] <= A[i]) { L[len++] = A[i]; } else { *lower_bound(L.begin(), L.begin() + len, A[i]) = A[i]; } } return len; } int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; reverse(A.begin(), A.end()); cout << lis(A) << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int lis(vector<int> &A) { int N = A.size(); vector<int> L(N); L[0] = A[0]; int len = 1; for (int i = 1; i < N; i++) { if (L[len - 1] <= A[i]) { L[len++] = A[i]; } else { *upper_bound(L.begin(), L.begin() + len, A[i]) = A[i]; } } return len; } int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; reverse(A.begin(), A.end()); cout << lis(A) << endl; return 0; }
[ "assignment.variable.change", "identifier.change", "call.function.change" ]
781,103
781,104
u265881782
cpp
p02973
#include <bits/stdc++.h> #define all(x) begin(x), end(x) #define dbg(x) cerr << #x << " = " << x << endl #define _ << ' ' << using namespace std; using ll = long long; using vi = vector<int>; int a[100000]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; set<int, greater<int>> c; int sol = 0; for (int i = 0; i < n; ++i) { auto it = c.lower_bound(a[i]); if (it == c.end()) { c.insert(a[i] + 1); sol++; } else { c.erase(it); c.insert(a[i] + 1); } } cout << sol; }
#include <bits/stdc++.h> #define all(x) begin(x), end(x) #define dbg(x) cerr << #x << " = " << x << endl #define _ << ' ' << using namespace std; using ll = long long; using vi = vector<int>; int a[100000]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; multiset<int, greater<int>> c; int sol = 0; for (int i = 0; i < n; ++i) { auto it = c.lower_bound(a[i]); if (it == c.end()) { c.insert(a[i] + 1); sol++; } else { c.erase(it); c.insert(a[i] + 1); } } cout << sol; }
[ "variable_declaration.type.change" ]
781,105
781,106
u562319622
cpp
p02973
#include <bits/stdc++.h> using namespace std; using Int = long long; int main() { int N; cin >> N; vector<int> A(N); for (auto &a : A) cin >> a; set<int> S; int ans = 0; for (int i = 0; i < N; i++) { auto it = S.lower_bound(A[i]); if (it == S.begin()) { S.insert(A[i]); ans++; } else { --it; S.erase(it); S.insert(A[i]); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using Int = long long; int main() { int N; cin >> N; vector<int> A(N); for (auto &a : A) cin >> a; multiset<int> S; int ans = 0; for (int i = 0; i < N; i++) { auto it = S.lower_bound(A[i]); if (it == S.begin()) { S.insert(A[i]); ans++; } else { --it; S.erase(it); S.insert(A[i]); } } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
781,109
781,110
u449722246
cpp
p02973
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using ll = long long; using ull = unsigned long long; const ll INF = 1e18; const ll MOD = 1e9 + 7; #define REP(i, n) for (ll i = 0; i < n; i++) int main() { ll n; cin >> n; multiset<ll> st; REP(i, n) { ll a; cin >> a; if (st.empty()) { st.insert(a); } else { auto itr = st.lower_bound(a); if (itr == st.begin()) { st.insert(a); } else { itr--; st.erase(*itr); st.insert(a); } } } cout << st.size() << endl; }
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using ll = long long; using ull = unsigned long long; const ll INF = 1e18; const ll MOD = 1e9 + 7; #define REP(i, n) for (ll i = 0; i < n; i++) int main() { ll n; cin >> n; multiset<ll> st; REP(i, n) { ll a; cin >> a; if (st.empty()) { st.insert(a); } else { auto itr = st.lower_bound(a); if (itr == st.begin()) { st.insert(a); } else { itr--; st.erase(itr); st.insert(a); } } } cout << st.size() << endl; }
[ "call.arguments.change" ]
781,113
781,114
u711985352
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ft first #define sd second #define fr(i, n) for (int i = 0; i < (n); ++i) #define Fr(i, n) for (int i = 1; i <= (n); ++i) #define ifr(i, n) for (int i = (n)-1; i >= 0; --i) #define iFr(i, n) for (int i = (n); i > 0; --i) int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); fr(i, n) cin >> a[i]; multiset<int> st; fr(i, n) { auto it = st.lower_bound(a[i]); if (it == st.begin()) st.insert(a[i]); else { int m = *(--it); st.erase(m); st.insert(a[i]); } } cout << st.size() << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ft first #define sd second #define fr(i, n) for (int i = 0; i < (n); ++i) #define Fr(i, n) for (int i = 1; i <= (n); ++i) #define ifr(i, n) for (int i = (n)-1; i >= 0; --i) #define iFr(i, n) for (int i = (n); i > 0; --i) int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); fr(i, n) cin >> a[i]; multiset<int> st; fr(i, n) { auto it = st.lower_bound(a[i]); if (it == st.begin()) st.insert(a[i]); else { int m = *(--it); st.erase(it); st.insert(a[i]); } } cout << st.size() << endl; }
[ "identifier.change", "call.arguments.change" ]
781,119
781,120
u434208140
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define MOD 1000000009 const long long INF = 1LL << 60; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; deque<ll> dq; rep(i, n) { int p = lower_bound(all(dq), a[i]) - dq.begin(); if (p == 0) dq.push_front(a[i]); else dq[p] = a[i]; } cout << dq.size() << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define MOD 1000000009 const long long INF = 1LL << 60; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; deque<ll> dq; rep(i, n) { int p = lower_bound(all(dq), a[i]) - dq.begin(); if (p == 0) dq.push_front(a[i]); else dq[p - 1] = a[i]; } cout << dq.size() << endl; }
[ "assignment.change" ]
781,121
781,122
u633967774
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } typedef long long ll; const long long INF = 1LL << 60; typedef pair<int, int> P; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; multiset<int> st; rep(i, N) { auto itr = st.lower_bound(A[i]); if (itr == st.begin()) { st.insert(A[i]); } else { itr--; st.erase(*itr); st.insert(A[i]); } } cout << (int)st.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } typedef long long ll; const long long INF = 1LL << 60; typedef pair<int, int> P; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; multiset<int> st; rep(i, N) { auto itr = st.lower_bound(A[i]); if (itr == st.begin()) { st.insert(A[i]); } else { itr--; st.erase(itr); st.insert(A[i]); } } cout << (int)st.size() << endl; return 0; }
[ "call.arguments.change" ]
781,123
781,124
u628332144
cpp
p02973
#include <bits/stdc++.h> #include <math.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long ll; using Graph = vector<vector<int>>; typedef long long ll; typedef pair<int, int> P; const int MOD = 1000000007; const int INF_32 = 1LL << 30; const int64_t INF_64 = 1LL << 60; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; multiset<int> s; int ans = 0; rep(i, N) { auto it = s.lower_bound(A[i]); if (it == s.begin()) { s.insert(A[i]); // cout << "i: " << i << endl; // cout << A[i] << endl; ans++; } else { auto p = prev(it); s.erase(*p); s.insert(A[i]); } } cout << ans << endl; }
#include <bits/stdc++.h> #include <math.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long ll; using Graph = vector<vector<int>>; typedef long long ll; typedef pair<int, int> P; const int MOD = 1000000007; const int INF_32 = 1LL << 30; const int64_t INF_64 = 1LL << 60; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; multiset<int> s; int ans = 0; rep(i, N) { auto it = s.lower_bound(A[i]); if (it == s.begin()) { s.insert(A[i]); // cout << "i: " << i << endl; // cout << A[i] << endl; ans++; } else { auto p = prev(it); s.erase(p); s.insert(A[i]); } } cout << ans << endl; }
[ "call.arguments.change" ]
781,129
781,130
u715366261
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define inf 10e17 #define rep(i, n) for (long long i = 0; i < n; i++) #define repr(i, n, m) for (long long i = m; i < n; i++) #define mod 1000000007 #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) \ for (auto &&itr : x) { \ cerr << (itr) << " "; \ } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t; } template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); multiset<int> st; repr(i, N, 0) { cin >> A[i]; int a = -A[i]; auto it = st.upper_bound(a); if (it == st.end()) { st.insert(a); } else { st.erase(*it); st.insert(a); } } cout << st.size() << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define inf 10e17 #define rep(i, n) for (long long i = 0; i < n; i++) #define repr(i, n, m) for (long long i = m; i < n; i++) #define mod 1000000007 #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) \ for (auto &&itr : x) { \ cerr << (itr) << " "; \ } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t; } template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); multiset<int> st; repr(i, N, 0) { cin >> A[i]; int a = -A[i]; auto it = st.upper_bound(a); if (it == st.end()) { st.insert(a); } else { st.erase(it); st.insert(a); } } cout << st.size() << endl; }
[ "call.arguments.change" ]
781,131
781,132
u898749314
cpp
p02973
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; #define INF 10e17 #define rep(i, n) for (long long i = 0; i < n; i++) #define repr(i, n, m) for (long long i = m; i < n; i++) #define END cout << endl #define MOD 1000000007 #define pb push_back #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) \ for (auto &&itr : x) { \ debug(itr); \ } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t; } template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t; } int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a[i]; } // 広義減少列問題に帰着させる。 multiset<ll> st; st.insert(a[0]); int ans = 1; for (int i = n - 2; i >= 0; --i) { auto it = st.upper_bound(a[i]); if (it == st.end()) { st.insert(a[i]); ans += 1; } else { st.erase(it); st.insert(a[i]); } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; #define INF 10e17 #define rep(i, n) for (long long i = 0; i < n; i++) #define repr(i, n, m) for (long long i = m; i < n; i++) #define END cout << endl #define MOD 1000000007 #define pb push_back #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) \ for (auto &&itr : x) { \ debug(itr); \ } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t; } template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t; } int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a[i]; } // 広義減少列問題に帰着させる。 multiset<ll> st; st.insert(a[n - 1]); int ans = 1; for (int i = n - 2; i >= 0; --i) { auto it = st.upper_bound(a[i]); if (it == st.end()) { st.insert(a[i]); ans += 1; } else { st.erase(it); st.insert(a[i]); } } cout << ans << endl; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "call.arguments.change" ]
781,133
781,134
u898749314
cpp
p02973
#include <bits/stdc++.h> using namespace std; //#define int long long #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i < n; ++i) #define exrep(i, a, b) for (ll i = a; i < b; i++) #define out(x) cout << x << endl #define EPS (1e-7) #define gearup \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<bool>> vvb; typedef vector<vector<double>> vvd; typedef vector<vector<string>> vvs; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef vector<vector<vector<ll>>> vvvl; ll MOD = 1000000007; const long long L_INF = 1LL << 60; const int INF = 2147483647; // 2^31-1 const double PI = acos(-1); // cout<<fixed<<setprecision(10); template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> void debug(T v) { rep(i, v.size()) cout << v[i] << " "; cout << endl; } const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; struct mint { long long x; mint(long long x = 0) : x((x % MOD + MOD) % MOD) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint &operator-=(const mint a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(long long t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime MOD mint inv() const { return pow(MOD - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; signed main() { gearup; ll n; cin >> n; deque<int> deq; rep(i, n) { int num; cin >> num; int idx = lower_bound(all(deq), num) - deq.begin(); if (idx == 0) deq.push_front(num); else deq[idx] = num; } int res = deq.size(); out(res); }
#include <bits/stdc++.h> using namespace std; //#define int long long #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i < n; ++i) #define exrep(i, a, b) for (ll i = a; i < b; i++) #define out(x) cout << x << endl #define EPS (1e-7) #define gearup \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<bool>> vvb; typedef vector<vector<double>> vvd; typedef vector<vector<string>> vvs; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef vector<vector<vector<ll>>> vvvl; ll MOD = 1000000007; const long long L_INF = 1LL << 60; const int INF = 2147483647; // 2^31-1 const double PI = acos(-1); // cout<<fixed<<setprecision(10); template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> void debug(T v) { rep(i, v.size()) cout << v[i] << " "; cout << endl; } const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; struct mint { long long x; mint(long long x = 0) : x((x % MOD + MOD) % MOD) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint &operator-=(const mint a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(long long t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime MOD mint inv() const { return pow(MOD - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; signed main() { gearup; ll n; cin >> n; deque<int> deq; rep(i, n) { int num; cin >> num; int idx = lower_bound(all(deq), num) - deq.begin(); if (idx == 0) deq.push_front(num); else deq[idx - 1] = num; //上書き } int res = deq.size(); out(res); }
[ "assignment.change" ]
781,150
781,151
u929582923
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) typedef pair<ll, ll> P; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; deque<ll> list; ll top; cin >> top; list.push_back(top); rep(i, n - 1) { ll x; cin >> x; auto it = lower_bound(list.rbegin(), list.rend(), x); ll d = distance(list.rbegin(), it); if (d == 0) { list.push_front(x); } else { list[d - 1] = x; } // sort(list.begin(), list.end(), less<ll>()); } cout << list.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) typedef pair<ll, ll> P; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; deque<ll> list; ll top; cin >> top; list.push_back(top); rep(i, n - 1) { ll x; cin >> x; auto it = lower_bound(list.begin(), list.end(), x); ll d = distance(list.begin(), it); if (d == 0) { list.push_front(x); } else { list[d - 1] = x; } // sort(list.begin(), list.end(), less<ll>()); } cout << list.size() << endl; return 0; }
[ "call.function.change", "call.arguments.change" ]
781,165
781,166
u459930111
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) typedef pair<ll, ll> P; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; vector<ll> list; ll top; cin >> top; list.push_back(top); rep(i, n - 1) { ll x; cin >> x; auto it = lower_bound(list.rbegin(), list.rend(), x); ll d = distance(list.rbegin(), it); if (d == 0) { list.push_back(x); } else { list[d - 1] = x; } // sort(list.begin(), list.end(), less<ll>()); } cout << list.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) typedef pair<ll, ll> P; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; deque<ll> list; ll top; cin >> top; list.push_back(top); rep(i, n - 1) { ll x; cin >> x; auto it = lower_bound(list.begin(), list.end(), x); ll d = distance(list.begin(), it); if (d == 0) { list.push_front(x); } else { list[d - 1] = x; } // sort(list.begin(), list.end(), less<ll>()); } cout << list.size() << endl; return 0; }
[ "variable_declaration.type.change", "call.function.change", "call.arguments.change" ]
781,167
781,166
u459930111
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) typedef pair<ll, ll> P; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; vector<ll> list; ll top; cin >> top; list.push_back(top); rep(i, n - 1) { ll x; cin >> x; auto it = lower_bound(list.begin(), list.end(), x); ll d = distance(list.begin(), it); if (d == 0) { list.push_back(x); } else { list[d - 1] = x; } // sort(list.begin(), list.end(), less<ll>()); } cout << list.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) typedef pair<ll, ll> P; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; deque<ll> list; ll top; cin >> top; list.push_back(top); rep(i, n - 1) { ll x; cin >> x; auto it = lower_bound(list.begin(), list.end(), x); ll d = distance(list.begin(), it); if (d == 0) { list.push_front(x); } else { list[d - 1] = x; } // sort(list.begin(), list.end(), less<ll>()); } cout << list.size() << endl; return 0; }
[ "variable_declaration.type.change", "call.function.change" ]
781,168
781,166
u459930111
cpp
p02973
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { int n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[n - 1 - i]; vector<long long> dp(n, 10000000007); dp[0] = a[0]; for (int i = 1; i < n; i++) { if (a[i] >= dp[i - 1]) dp[i] = a[i]; else { dp[lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin()] = a[i]; } } for (int i = n - 1; i >= 0; i--) { if (dp[i] != 10000000007) { cout << i + 1 << endl; break; } } }
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { int n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[n - 1 - i]; vector<long long> dp(n, 10000000007); dp[0] = a[0]; for (int i = 1; i < n; i++) { if (a[i] >= dp[i - 1]) dp[i] = a[i]; else { dp[upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin()] = a[i]; } } for (int i = n - 1; i >= 0; i--) { if (dp[i] != 10000000007) { cout << i + 1 << endl; break; } } }
[ "assignment.variable.change", "identifier.change", "call.function.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
781,177
781,178
u016987091
cpp
p02973
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { multiset<int> st; int n; cin >> n; int a; cin >> a; st.insert(a); for (int i = 0; i < n - 1; i++) { int a; cin >> a; auto o = st.multiset::lower_bound(a); if (o == st.begin()) { st.insert(a); } else { st.erase(*--o); st.insert(a); } } cout << st.size() << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { multiset<int> st; int n; cin >> n; int a; cin >> a; st.insert(a); for (int i = 0; i < n - 1; i++) { int a; cin >> a; auto o = st.multiset::lower_bound(a); if (o == st.begin()) { st.insert(a); } else { st.erase(--o); st.insert(a); } } cout << st.size() << endl; return 0; }
[ "call.arguments.change" ]
781,183
781,184
u003026289
cpp
p02973
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll MOD = 1000000007; const ld PI = acos(-1); const ld EPS = 0.0000000001; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; 0 <= i; i--) #define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; (ll)(b) <= i; i--) #define ALL(x) x.begin(), x.end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<ll> a(n); REP(i, n) cin >> a[i]; multiset<ll> mp; REP(i, n) { auto itr = mp.lower_bound(a[i]); if (itr != mp.begin()) mp.erase(--itr); else mp.insert(a[i]); } cout << mp.size() << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll MOD = 1000000007; const ld PI = acos(-1); const ld EPS = 0.0000000001; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; 0 <= i; i--) #define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; (ll)(b) <= i; i--) #define ALL(x) x.begin(), x.end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<ll> a(n); REP(i, n) cin >> a[i]; multiset<ll> mp; REP(i, n) { auto itr = mp.lower_bound(a[i]); if (itr != mp.begin()) mp.erase(--itr); mp.insert(a[i]); } cout << mp.size() << endl; }
[ "control_flow.branch.else.remove" ]
781,187
781,188
u050087249
cpp
p02973
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> c; rep(i, n) { int a; cin >> a; int sz = c.size(); if (!sz) { c.push_back(a); continue; } int j = upper_bound(c.begin(), c.end(), a) - c.begin() - 1; if (j < 0 || a == c[j]) { c.insert(c.begin(), a); } else { c[j] = a; } } cout << c.size() << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> c; rep(i, n) { int a; cin >> a; int sz = c.size(); if (!sz) { c.push_back(a); continue; } int j = lower_bound(c.begin(), c.end(), a) - c.begin() - 1; if (j < 0 || a == c[j]) { c.insert(c.begin(), a); } else { c[j] = a; } } cout << c.size() << endl; return 0; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
781,193
781,194
u894496005
cpp
p02973
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> //#include<unordered_set> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/ #pragma GCC optimize("Ofast") #pragma GCC optimize("fast-math") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") #define pb push_back #define ld long double mt19937 rnd(51); int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a; for (int i = 0; i < n; i++) { int p; cin >> p; if (a.size() == 0) { a.pb(p); } else { if (a.back() >= p) { a.pb(p); } else { int l = -1, r = n; while (r - l > 1) { int mid = (r + l) / 2; if (a[mid] < p) { r = mid; } else { l = mid; } } a[r] = p; } } } cout << a.size() << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> //#include<unordered_set> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/ #pragma GCC optimize("Ofast") #pragma GCC optimize("fast-math") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") #define pb push_back #define ld long double mt19937 rnd(51); int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a; for (int i = 0; i < n; i++) { int p; cin >> p; if (a.size() == 0) { a.pb(p); } else { if (a.back() >= p) { a.pb(p); } else { int l = -1, r = a.size(); while (r - l > 1) { int mid = (r + l) / 2; if (a[mid] < p) { r = mid; } else { l = mid; } } a[r] = p; } } } cout << a.size() << endl; return 0; }
[ "call.add" ]
781,195
781,196
u533463334
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; void solve(long long N, std::vector<long long> A) { multiset<ll> s; for (int i = 0; i < N; i++) { auto itr = s.lower_bound(A[i]); if (itr == s.begin()) { s.insert(A[i]); } else { --itr; s.erase(*itr); s.insert(A[i]); } } cout << s.size() << endl; } // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: // You use the default template now. You can remove this line by using your // custom template) int main() { long long N; scanf("%lld", &N); std::vector<long long> A(N); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); } solve(N, std::move(A)); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; void solve(long long N, std::vector<long long> A) { multiset<ll> s; for (int i = 0; i < N; i++) { auto itr = s.lower_bound(A[i]); if (itr == s.begin()) { // cerr <<"*itr=" << *itr<< endl; s.insert(A[i]); } else { --itr; s.erase(itr); s.insert(A[i]); } } cout << s.size() << endl; } // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: // You use the default template now. You can remove this line by using your // custom template) int main() { long long N; scanf("%lld", &N); std::vector<long long> A(N); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); } solve(N, std::move(A)); return 0; }
[ "call.arguments.change" ]
781,197
781,198
u943966256
cpp
p02973
// g++ -std=c++14 test.cpp -o test.out #include <algorithm> #include <bitset> #include <cassert> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string.h> #include <utility> #include <vector> using namespace std; #define LL long long int const LL INF = (LL)(1e18) + 1; const int INF_INT = 2147483647 - 1e6 - 1; const LL mod = 1000000007ll; const int mod_int = 1000000007; LL N; LL A[100000]; LL ans = 0; void solve() { //数をグループに分類、グループの数を回答とする multiset<LL> group_max; //各グループに格納されている数のうち最大値 group_max.insert(A[0]); for (int i = 1; i < N; i++) { auto iter = group_max.lower_bound(A[i]); if (iter == group_max.begin()) { group_max.insert(A[i]); continue; } iter--; if (*iter < A[i]) { group_max.erase(*iter); group_max.insert(A[i]); } else { group_max.insert(A[i]); } } ans = (LL)group_max.size(); } int main() { cin >> N; for (int i = 0; i < N; i++) cin >> A[i]; solve(); cout << ans << endl; return 0; }
// g++ -std=c++14 test.cpp -o test.out //問題URL // https://atcoder.jp/contests/abc134/tasks/abc134_e // multisetの注意点: //ある値iをmultisetから削除したい時、erase(i)をすると // multisetにiが複数入っている時これが全部削除対象になる //一個だけ削除したい時は //削除したい要素のイテレータをeraseの引数にしておく必要がある #include <algorithm> #include <bitset> #include <cassert> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string.h> #include <utility> #include <vector> using namespace std; #define LL long long int const LL INF = (LL)(1e18) + 1; const int INF_INT = 2147483647 - 1e6 - 1; const LL mod = 1000000007ll; const int mod_int = 1000000007; LL N; LL A[100000]; LL ans = 0; void solve() { //数をグループに分類、グループの数を回答とする multiset<LL> group_max; //各グループに格納されている数のうち最大値 group_max.insert(A[0]); for (int i = 1; i < N; i++) { auto iter = group_max.lower_bound(A[i]); if (iter == group_max.begin()) { group_max.insert(A[i]); continue; } iter--; if (*iter < A[i]) { group_max.erase(iter); group_max.insert(A[i]); } else { group_max.insert(A[i]); } } ans = (LL)group_max.size(); } int main() { cin >> N; for (int i = 0; i < N; i++) cin >> A[i]; solve(); cout << ans << endl; return 0; }
[ "call.arguments.change" ]
781,199
781,200
u302000346
cpp
p02973
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); vector<int> dp; dp.push_back(a[0]); rep(i, n) { if (a[i] > dp.back()) dp.push_back(a[i]); else { int idx = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; } // rep(i, dp.size()) cout << dp[i] << " "; // cout << endl; } cout << dp.size() << endl; return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); vector<int> dp; dp.push_back(a[0]); rep1(i, n) { if (a[i] >= dp.back()) dp.push_back(a[i]); else { int idx = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; } // rep(i, dp.size()) cout << dp[i] << " "; // cout << endl; } cout << dp.size() << endl; return 0; }
[ "identifier.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
781,208
781,209
u374051158
cpp
p02973
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); vector<int> dp; dp.push_back(a[0]); rep(i, n) { if (a[i] > dp.back()) dp.push_back(a[i]); else { int idx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; } } cout << dp.size() << endl; return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); vector<int> dp; dp.push_back(a[0]); rep1(i, n) { if (a[i] >= dp.back()) dp.push_back(a[i]); else { int idx = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; } // rep(i, dp.size()) cout << dp[i] << " "; // cout << endl; } cout << dp.size() << endl; return 0; }
[ "identifier.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.function.change", "expression.operation.binary.change" ]
781,210
781,209
u374051158
cpp
p02973
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); vector<int> dp; dp.push_back(a[0]); rep(i, n) { if (a[i] >= dp.back()) dp.push_back(a[i]); else { int idx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; } } cout << dp.size() - 1 << endl; return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; reverse(a.begin(), a.end()); vector<int> dp; dp.push_back(a[0]); rep1(i, n) { if (a[i] >= dp.back()) dp.push_back(a[i]); else { int idx = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; } // rep(i, dp.size()) cout << dp[i] << " "; // cout << endl; } cout << dp.size() << endl; return 0; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
781,211
781,209
u374051158
cpp
p02973
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < n; i++) #define REPR(i, n) for (long long i = n - 1; i >= 0; i--) #define FOR(i, m, n) for (long long i = m; i <= n; i++) #define FORR(i, m, n) for (long long i = m; i >= n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define VSORTR(v) sort(v.rbegin(), v.rend()); #define ALL(v) (v).begin(), (v).end() #define FIN \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); using namespace std; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<ll, ll>; const ll mod = 1e9 + 7; const ll inf = 1e15; int main() { FIN ll n; cin >> n; vll a(n); REP(i, n) cin >> a[i]; reverse(ALL(a)); multiset<ll> st; ll ans = 1; st.insert(a[0]); FOR(i, 1, n - 1) { if (st.upper_bound(a[i]) == st.end()) { ans++; st.insert(a[i]); } else { st.insert(a[i]); st.erase(*(++st.upper_bound(a[i]))); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < n; i++) #define REPR(i, n) for (long long i = n - 1; i >= 0; i--) #define FOR(i, m, n) for (long long i = m; i <= n; i++) #define FORR(i, m, n) for (long long i = m; i >= n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define VSORTR(v) sort(v.rbegin(), v.rend()); #define ALL(v) (v).begin(), (v).end() #define FIN \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); using namespace std; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<ll, ll>; const ll mod = 1e9 + 7; const ll inf = 1e15; int main() { FIN ll n; cin >> n; vll a(n); REP(i, n) cin >> a[i]; reverse(ALL(a)); multiset<ll> st; ll ans = 1; st.insert(a[0]); FOR(i, 1, n - 1) { if (st.upper_bound(a[i]) == st.end()) { ans++; st.insert(a[i]); } else { st.insert(a[i]); st.erase(st.upper_bound(a[i])++); } } cout << ans << endl; // multiset<ll> st; // st.insert(1); // st.insert(1); // cout<<st.count(1)<<endl; // st.erase(1); // cout<<st.count(1)<<endl; return 0; }
[ "call.arguments.change" ]
781,216
781,217
u557565572
cpp
p02973
#include <algorithm> #include <cmath> #include <cstdint> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define All(v) (v).begin(), (v).end() #define pb push_back #define MP(a, b) make_pair((a), (b)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int INF = 1 << 30; const ll LINF = 1LL << 60; const int MOD = 1e9 + 7; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; multiset<int> se; rep(i, N) { auto it = se.lower_bound(A[i]); if (it == se.begin()) { se.insert(A[i]); } else { it--; se.erase(*it); se.insert(A[i]); } } cout << se.size() << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdint> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define All(v) (v).begin(), (v).end() #define pb push_back #define MP(a, b) make_pair((a), (b)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int INF = 1 << 30; const ll LINF = 1LL << 60; const int MOD = 1e9 + 7; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; multiset<int> se; rep(i, N) { auto it = se.lower_bound(A[i]); if (it == se.begin()) { se.insert(A[i]); } else { it--; se.erase(se.find(*it)); se.insert(A[i]); } } cout << se.size() << endl; return 0; }
[ "call.add", "call.arguments.change" ]
781,218
781,219
u917282863
cpp
p02973
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> P1; typedef pair<P, P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i, x) for (ll i = 0; i < x; i++) #define repn(i, x) for (ll i = 1; i <= x; i++) #define SORT(x) sort(x.begin(), x.end()) #define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end()) #define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin()) #define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin()) const ll MAX = 510000; const int MOD = 1000000007; // 最長増加部分列の長さを求める ll LIS(const vector<ll> &a) { ll N = (ll)a.size(); vector<long long> dp(N, INF); for (ll i = 0; i < N; ++i) { // dp[k] >= a[i] となる最小のイテレータを見つける auto it = lower_bound(dp.begin(), dp.end(), a[i]); // そこを a[i] で書き換える *it = a[i]; } // dp[k] < INF となる最大の k に対して k+1 が答え // それは dp[k] >= INF となる最小の k に一致する return lower_bound(dp.begin(), dp.end(), INF) - dp.begin(); } int main() { ll N; cin >> N; vector<ll> a(N); for (ll i = 0; i < N; ++i) cin >> a[i]; for (ll i = 0; i < N; ++i) a[i] = -a[i]; cout << LIS(a) << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> P1; typedef pair<P, P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i, x) for (ll i = 0; i < x; i++) #define repn(i, x) for (ll i = 1; i <= x; i++) #define SORT(x) sort(x.begin(), x.end()) #define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end()) #define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin()) #define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin()) const ll MAX = 510000; const int MOD = 1000000007; // 最長増加部分列の長さを求める ll LIS(const vector<ll> &a) { ll N = (ll)a.size(); vector<long long> dp(N, INF); for (ll i = 0; i < N; ++i) { // dp[k] >= a[i] となる最小のイテレータを見つける auto it = upper_bound(dp.begin(), dp.end(), a[i]); // そこを a[i] で書き換える *it = a[i]; } // dp[k] < INF となる最大の k に対して k+1 が答え // それは dp[k] >= INF となる最小の k に一致する return lower_bound(dp.begin(), dp.end(), INF) - dp.begin(); } int main() { ll N; cin >> N; vector<ll> a(N); for (ll i = 0; i < N; ++i) cin >> a[i]; for (ll i = 0; i < N; ++i) a[i] = -a[i]; cout << LIS(a) << endl; }
[ "identifier.change", "call.function.change" ]
781,220
781,221
u284045566
cpp
p02973
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--) #define irep(i, m, n) \ for (long long i = (long long)(m); i < (long long)(n); ++i) #define ireps(i, m, n) \ for (long long i = (long long)(m); i <= (long long)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout << d << endl; #define coutd(d) cout << std::setprecision(10) << d << endl; #define cinline(n) getline(cin, n); #define replace_all(s, b, a) replace(s.begin(), s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) long long(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vs = vector<string>; using vpll = vector<pair<ll, ll>>; using vtp = vector<tuple<ll, ll, ll>>; using vb = vector<bool>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e9; const ll MOD = 1e9 + 7; const ll LINF = 1e18; signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vll a(n); rep(i, n) cin >> a[i]; deque<ll> q; ll ans = 0; rep(i, n) { auto itr = lower_bound(all(q), a[i]); if (itr == q.begin()) q.push_front(a[i]); else itr++, *itr = a[i]; } cout << q.size() << endl; }
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--) #define irep(i, m, n) \ for (long long i = (long long)(m); i < (long long)(n); ++i) #define ireps(i, m, n) \ for (long long i = (long long)(m); i <= (long long)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout << d << endl; #define coutd(d) cout << std::setprecision(10) << d << endl; #define cinline(n) getline(cin, n); #define replace_all(s, b, a) replace(s.begin(), s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) long long(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vs = vector<string>; using vpll = vector<pair<ll, ll>>; using vtp = vector<tuple<ll, ll, ll>>; using vb = vector<bool>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e9; const ll MOD = 1e9 + 7; const ll LINF = 1e18; signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vll a(n); rep(i, n) cin >> a[i]; deque<ll> q; ll ans = 0; rep(i, n) { auto itr = lower_bound(all(q), a[i]); if (itr == q.begin()) q.push_front(a[i]); else itr--, *itr = a[i]; } cout << q.size() << endl; }
[]
781,231
781,232
u530107518
cpp
p02973
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i) #define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout << d << endl; #define coutd(d) cout << std::setprecision(10) << d << endl; #define cinline(n) getline(cin, n); #define replace_all(s, b, a) replace(s.begin(), s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) int(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vs = vector<string>; using vpll = vector<pair<ll, ll>>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e15; const int MOD = 1e9 + 7; const ll LINF = 1e18; signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vll a(n); rep(i, n) cin >> a[i]; deque<ll> d; rep(i, n) { auto itr = lower_bound(all(d), a[i]); if (itr == d.begin()) d.push_front(a[i]); else { ll i = itr - d.begin() - 1; d[i] = a[i]; } } cout << d.size() << endl; }
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i) #define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout << d << endl; #define coutd(d) cout << std::setprecision(10) << d << endl; #define cinline(n) getline(cin, n); #define replace_all(s, b, a) replace(s.begin(), s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) int(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vs = vector<string>; using vpll = vector<pair<ll, ll>>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e15; const int MOD = 1e9 + 7; const ll LINF = 1e18; signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vll a(n); rep(i, n) cin >> a[i]; deque<ll> d; rep(i, n) { auto itr = lower_bound(all(d), a[i]); if (itr == d.begin()) d.push_front(a[i]); else { ll j = itr - d.begin() - 1; d[j] = a[i]; } } cout << d.size() << endl; }
[ "variable_declaration.name.change", "identifier.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
781,233
781,234
u530107518
cpp
p02973
#pragma region template #include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 998244353, MAX = 1e18, larg = 1e5, INF = -1e18; long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z; long long max_value = INF, max_index = -1; long long min_value = MAX, min_index = -1; typedef long long ll; int dp[100001]; int arr[100000]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> N; rep(i, N) { cin >> arr[i]; } reverse(arr, arr + N); rep(i, N + 1) { dp[i] = MAX; } rep(i, N) { *upper_bound(dp, dp + N, arr[i]) = arr[i]; } cout << (lower_bound(dp, dp + N, MAX) - dp) << endl; }
#pragma region template #include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 998244353, MAX = 1e18, larg = 1e5, INF = -1e18; long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z; long long max_value = INF, max_index = -1; long long min_value = MAX, min_index = -1; typedef long long ll; ll dp[100001]; ll arr[100000]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> N; rep(i, N) { cin >> arr[i]; } reverse(arr, arr + N); rep(i, N + 1) { dp[i] = MAX; } rep(i, N) { *upper_bound(dp, dp + N, arr[i]) = arr[i]; } cout << (lower_bound(dp, dp + N, MAX) - dp) << endl; }
[ "variable_declaration.type.change" ]
781,235
781,236
u554988565
cpp
p02973
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int64_t> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); vector<int> L; L.push_back(A[0]); for (int i = 0; i < N; i++) { auto itr = lower_bound(L.begin(), L.end(), A[i]); int k = distance(L.begin(), itr); if (k == 0) L.insert(L.begin(), A[i]); else L.at(k - 1) = A[i]; } int ans = L.size(); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int64_t> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); vector<int64_t> L; L.push_back(A[0]); for (int i = 1; i < N; i++) { auto itr = lower_bound(L.begin(), L.end(), A[i]); int k = distance(L.begin(), itr); if (k == 0) L.insert(L.begin(), A[i]); else L.at(k - 1) = A[i]; } int ans = L.size(); cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change", "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
781,241
781,242
u101018317
cpp
p02973
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define sz(x) int(x.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; const int INT_INF = 1 << 30; #define MOD 1000000007LL #define PI 3.141592653589793 #define endl "\n" int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; vll B(0); ll bsize = 0; for (int i = 0; i < N; i++) { ll A; cin >> A; if (i == 0) { B.push_back(A); bsize++; } else if (B.at(0) < A) { B.at(0) = A; } else if (B.at(bsize - 1) >= A) { B.push_back(A); bsize++; } else { auto ite = lower_bound(B.rbegin(), B.rend(), A); *ite = A; /* int ok = bsize-1; int ng = 0; while(ok - ng > 1){ int mid = (ok + ng) / 2; if(B.at(mid) < A) ok = mid; else ng = mid; } B.at(ok) = A; */ } } cout << B.size() << endl; }
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define sz(x) int(x.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; const int INT_INF = 1 << 30; #define MOD 1000000007LL #define PI 3.141592653589793 #define endl "\n" int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; vll B(0); ll bsize = 0; for (int i = 0; i < N; i++) { ll A; cin >> A; if (i == 0) { B.push_back(A); bsize++; } else if (B.at(0) < A) { B.at(0) = A; } else if (B.at(bsize - 1) >= A) { B.push_back(A); bsize++; } else { auto ite = lower_bound(B.rbegin(), B.rend(), A); ite--; *ite = A; /* int ok = bsize-1; int ng = 0; while(ok - ng > 1){ int mid = (ok + ng) / 2; if(B.at(mid) < A) ok = mid; else ng = mid; } B.at(ok) = A; */ } } cout << B.size() << endl; }
[ "expression.unary.arithmetic.add" ]
781,243
781,244
u455266724
cpp
p02973
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i < (ll)(n); i++) #define INF 10000000000 #define MOD 998244353 using ll = long long; using Graph = vector<vector<int>>; int main() { int N; cin >> N; vector<ll> A(N); rep(i, N) cin >> A.at(i); vector<ll> res; res.push_back(A.at(N - 1)); for (int i = N - 2; i >= 0; i--) { // sort(begin(res),end(res)); auto iter = lower_bound(begin(res), end(res), A.at(i)); ll dist = distance(begin(res), iter); if (dist == (ll)res.size()) { res.push_back(A.at(i)); } else { res.at(dist) = A.at(i); } } cout << res.size() << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i < (ll)(n); i++) #define INF 10000000000 #define MOD 998244353 using ll = long long; using Graph = vector<vector<int>>; int main() { int N; cin >> N; vector<ll> A(N); rep(i, N) cin >> A.at(i); vector<ll> res; res.push_back(A.at(N - 1)); for (int i = N - 2; i >= 0; i--) { // sort(begin(res),end(res)); auto iter = upper_bound(begin(res), end(res), A.at(i)); ll dist = distance(begin(res), iter); if (dist == (ll)res.size()) { res.push_back(A.at(i)); } else { res.at(dist) = A.at(i); } } cout << res.size() << endl; }
[ "identifier.change", "call.function.change" ]
781,245
781,246
u779216084
cpp
p02973
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> //cout << fixed << setprecision(15) << x << endl; #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; const int INF = 1e9 + 6; const int MOD = 1e9 + 7; const ll LLINF = 1LL << 60; #define P pair<int, int> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() int main() { int N; cin >> N; int A[N]; rep(i, N) cin >> A[i]; deque<int> ans; ans.push_front(A[0]); rep(i, N - 1) { int key = (lower_bound(all(ans), A[i + 1]) - ans.begin()) - 1; if (key == -1) { ans.push_front(A[i + 1]); } else { A[key] = A[i + 1]; // sort(all(ans)); } } cout << ans.size() << endl; }
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> //cout << fixed << setprecision(15) << x << endl; #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; const int INF = 1e9 + 6; const int MOD = 1e9 + 7; const ll LLINF = 1LL << 60; #define P pair<int, int> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() int main() { int N; cin >> N; int A[N]; rep(i, N) cin >> A[i]; deque<int> ans; ans.push_front(A[0]); rep(i, N - 1) { int key = (lower_bound(all(ans), A[i + 1]) - ans.begin()) - 1; if (key == -1) { ans.push_front(A[i + 1]); } else { ans[key] = A[i + 1]; } } cout << ans.size() << endl; }
[ "assignment.variable.change", "identifier.change" ]
781,251
781,252
u275488634
cpp
p02973
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++) #define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--) const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll MOD = 1000000007; const ll INF = 1000000000000000000L; #ifdef __DEBUG /** * For DEBUG * https://github.com/ta7uw/cpp-pyprint */ #include "cpp-pyprint/pyprint.h" #endif void Main() { ll N; cin >> N; vector<ll> A(N); rep(i, N) cin >> A[i]; vector<ll> B; rep(i, N) { ll a = A[i]; auto idx = lower_bound(B.begin(), B.end(), a); if (idx == B.begin()) { B.push_back(a); } else { *idx = a; } } cout << B.size() << '\n'; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++) #define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--) const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll MOD = 1000000007; const ll INF = 1000000000000000000L; #ifdef __DEBUG /** * For DEBUG * https://github.com/ta7uw/cpp-pyprint */ #include "cpp-pyprint/pyprint.h" #endif void Main() { ll N; cin >> N; vector<ll> A(N); rep(i, N) cin >> A[i]; deque<ll> B; rep(i, N) { ll a = A[i]; auto idx = lower_bound(B.begin(), B.end(), a); if (idx == B.begin()) { B.push_front(a); } else { idx--; *idx = a; } } cout << B.size() << '\n'; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
[ "variable_declaration.type.change", "call.function.change", "expression.unary.arithmetic.add" ]
781,253
781,254
u427344224
cpp
p02973
#include <bits/stdc++.h> using namespace std; int N; int big_n = 2000000000; int main() { cin >> N; vector<int> A(N); vector<int> B(N + 1); B.at(0) = -1; vector<vector<int>> C(N); for (int i = 1; i <= N; i++) { cin >> A.at(i - 1); B.at(i) = big_n; } for (int i = N - 1; i >= 0; i--) { auto ir = lower_bound(B.begin(), B.end(), A.at(i)); int d = distance(B.begin(), ir); B.at(d) = A.at(i); } int max_c = 0; for (int i = 0; i <= N; i++) { if (B.at(i) == big_n) { break; } max_c++; } cout << max_c - 1 << endl; }
#include <bits/stdc++.h> using namespace std; int N; int big_n = 2000000000; int main() { cin >> N; vector<int> A(N); vector<int> B(N + 1); B.at(0) = -1; vector<vector<int>> C(N); for (int i = 1; i <= N; i++) { cin >> A.at(i - 1); B.at(i) = big_n; } for (int i = N - 1; i >= 0; i--) { auto ir = upper_bound(B.begin(), B.end(), A.at(i)); int d = distance(B.begin(), ir); B.at(d) = A.at(i); } int max_c = 0; for (int i = 0; i <= N; i++) { if (B.at(i) == big_n) { break; } max_c++; } cout << max_c - 1 << endl; }
[ "identifier.change", "call.function.change" ]
781,255
781,256
u844382784
cpp
p02973
#include <algorithm> #include <cassert> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long int llint; typedef pair<int, int> pint; typedef pair<llint, llint> pllint; typedef vector<int> vint; typedef vector<llint> vllint; typedef vector<pint> vpint; typedef vector<string> vstring; typedef vector<pair<llint, llint>> vpllint; typedef vector<vector<int>> vvint; typedef vector<vector<llint>> vvllint; typedef vector<vector<pint>> vvpint; typedef vector<bool> vbool; typedef vector<vbool> vvbool; typedef vector<vpllint> vvpllint; #define rep(i, n) for (int i = 0; i < n; i++) #define drep(i, n) for (int i = n - 1; 0 <= i; i--) #define yes(ans) \ if (ans) \ cout << "yes" << endl; \ else \ cout << "no" << endl; #define Yes(ans) \ if (ans) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define YES(ans) \ if (ans) \ cout << "YES" << endl; \ else \ cout << "NO" << endl; #define POSSIBLE(ans) \ if (ans) \ cout << "POSSIBLE" << endl; \ else \ cout << "IMPOSSIBLE" << endl; #define Pi 3.1415926535897932384626 #define mod llint(1e9 + 7) #define Inf 2147483647 #define llInf 9223372036854775807 #define all(x) x.begin(), x.end() #define pb push_back #define isin(n, i) 0 <= i &&i < n class UnionFind { public: //親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> Parent; //作るときはParentの値を全て-1にする //こうすると全てバラバラになる UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)]; //親をとってきたい } // AとBをくっ付ける bool connect(int A, int B) { // AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらひっくり返しちゃう。 if (size(A) < size(B)) swap(A, B); // Aのサイズを更新する Parent[A] += Parent[B]; // Bの親をAに変更する Parent[B] = A; return true; } }; //セグ木・0-indexed・非再帰・(大きさ・単位元・関数)で初期化 template <typename T> struct SegTree { //比較関数の型 using F = function<T(T, T)>; //二分木を配列で表したもの vector<T> seg; //木の半分の大きさ int siz; //単位元 const T unit; //比較する関数 const F f; //大きさn、unit(単位元)、f(モノイド)でsegtreeを初期化する SegTree(int n, const T unit, const F f) : unit(unit), f(f) { siz = 1; while (siz < n) siz <<= 1; seg.assign(siz * 2 - 1, unit); siz--; } // k番目にtを入力 void set(int k, const T &t) { seg[k + siz] = t; } // fによって木を構築する void build() { for (int i = siz - 1; 0 <= i; i--) { seg[i] = f(seg[i * 2 + 1], seg[i * 2 + 2]); } } T operator[](const int i) { return seg[i + siz]; } // k番目をxに更新する void update(int k, T x) { k += siz; seg[k] = x; while (0 < k) { k = (k - 1) >> 1; seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]); } } //[a,b)について、fした結果を返す //半開区域のためa以上b未満の位置を指す T query(int a, int b) { T l = unit, r = unit; for (a += siz, b += siz; a < b; a >>= 1, b >>= 1) { if (!(a & 1)) l = f(seg[a++], l); if (!(b & 1)) r = f(seg[--b], r); } return f(l, r); } }; // aとbの最大公約数を求めるよ long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } // 返り値: a と b の最大公約数 // ax + by = gcd(a, b) を満たす (x, y) が格納される long long extGCD(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } // mod. m での a の逆元 a^{-1} を計算する long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } // nCrを1000000007で割った余りを求める llint nCr(llint n, llint r) { llint ans = 1; for (llint i = 0; i < r; i++) { ans *= n - i; ans %= 1000000007; } for (llint i = 1; i <= r; i++) { ans *= modinv(i, 1000000007); ans %= 1000000007; } return ans; } // aのb乗をmodで割った余りを求める llint power(llint a, llint b) { if (b == 1) return a; if (b == 0) return 1; llint tmp = power(a, (llint)b / 2); tmp *= tmp; tmp %= mod; if (b % 2 == 1) { tmp *= a; tmp %= mod; } return tmp; } // bitを表すsub,要素数を表すlength bool next_combination(llint &sub, int length) { llint x = sub & -sub, y = sub + x; sub = (((sub & ~y) / x) >> 1) | y; return sub < (llint)(1 << (llint)length); } int main() { int n; cin >> n; vint a(n); map<int, int> m; rep(i, n) { cin >> a[i]; m[a[i]]++; } int ans = 0; for (auto i : m) ans = max(ans, i.second); vint table; rep(i, n) { if (table.empty()) table.pb(-a[i]); else { int idx = lower_bound(all(table), -a[i]) - table.begin(); if (idx == table.size()) { table.pb(-a[i]); } else table[idx] = -a[i]; } } ans = max(ans, (int)table.size()); cout << ans << endl; return 0; }
#include <algorithm> #include <cassert> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long int llint; typedef pair<int, int> pint; typedef pair<llint, llint> pllint; typedef vector<int> vint; typedef vector<llint> vllint; typedef vector<pint> vpint; typedef vector<string> vstring; typedef vector<pair<llint, llint>> vpllint; typedef vector<vector<int>> vvint; typedef vector<vector<llint>> vvllint; typedef vector<vector<pint>> vvpint; typedef vector<bool> vbool; typedef vector<vbool> vvbool; typedef vector<vpllint> vvpllint; #define rep(i, n) for (int i = 0; i < n; i++) #define drep(i, n) for (int i = n - 1; 0 <= i; i--) #define yes(ans) \ if (ans) \ cout << "yes" << endl; \ else \ cout << "no" << endl; #define Yes(ans) \ if (ans) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define YES(ans) \ if (ans) \ cout << "YES" << endl; \ else \ cout << "NO" << endl; #define POSSIBLE(ans) \ if (ans) \ cout << "POSSIBLE" << endl; \ else \ cout << "IMPOSSIBLE" << endl; #define Pi 3.1415926535897932384626 #define mod llint(1e9 + 7) #define Inf 2147483647 #define llInf 9223372036854775807 #define all(x) x.begin(), x.end() #define pb push_back #define isin(n, i) 0 <= i &&i < n class UnionFind { public: //親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> Parent; //作るときはParentの値を全て-1にする //こうすると全てバラバラになる UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)]; //親をとってきたい } // AとBをくっ付ける bool connect(int A, int B) { // AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらひっくり返しちゃう。 if (size(A) < size(B)) swap(A, B); // Aのサイズを更新する Parent[A] += Parent[B]; // Bの親をAに変更する Parent[B] = A; return true; } }; //セグ木・0-indexed・非再帰・(大きさ・単位元・関数)で初期化 template <typename T> struct SegTree { //比較関数の型 using F = function<T(T, T)>; //二分木を配列で表したもの vector<T> seg; //木の半分の大きさ int siz; //単位元 const T unit; //比較する関数 const F f; //大きさn、unit(単位元)、f(モノイド)でsegtreeを初期化する SegTree(int n, const T unit, const F f) : unit(unit), f(f) { siz = 1; while (siz < n) siz <<= 1; seg.assign(siz * 2 - 1, unit); siz--; } // k番目にtを入力 void set(int k, const T &t) { seg[k + siz] = t; } // fによって木を構築する void build() { for (int i = siz - 1; 0 <= i; i--) { seg[i] = f(seg[i * 2 + 1], seg[i * 2 + 2]); } } T operator[](const int i) { return seg[i + siz]; } // k番目をxに更新する void update(int k, T x) { k += siz; seg[k] = x; while (0 < k) { k = (k - 1) >> 1; seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]); } } //[a,b)について、fした結果を返す //半開区域のためa以上b未満の位置を指す T query(int a, int b) { T l = unit, r = unit; for (a += siz, b += siz; a < b; a >>= 1, b >>= 1) { if (!(a & 1)) l = f(seg[a++], l); if (!(b & 1)) r = f(seg[--b], r); } return f(l, r); } }; // aとbの最大公約数を求めるよ long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } // 返り値: a と b の最大公約数 // ax + by = gcd(a, b) を満たす (x, y) が格納される long long extGCD(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } // mod. m での a の逆元 a^{-1} を計算する long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } // nCrを1000000007で割った余りを求める llint nCr(llint n, llint r) { llint ans = 1; for (llint i = 0; i < r; i++) { ans *= n - i; ans %= 1000000007; } for (llint i = 1; i <= r; i++) { ans *= modinv(i, 1000000007); ans %= 1000000007; } return ans; } // aのb乗をmodで割った余りを求める llint power(llint a, llint b) { if (b == 1) return a; if (b == 0) return 1; llint tmp = power(a, (llint)b / 2); tmp *= tmp; tmp %= mod; if (b % 2 == 1) { tmp *= a; tmp %= mod; } return tmp; } // bitを表すsub,要素数を表すlength bool next_combination(llint &sub, int length) { llint x = sub & -sub, y = sub + x; sub = (((sub & ~y) / x) >> 1) | y; return sub < (llint)(1 << (llint)length); } int main() { int n; cin >> n; vint a(n); map<int, int> m; rep(i, n) { cin >> a[i]; m[a[i]]++; } int ans = 0; for (auto i : m) ans = max(ans, i.second); vint table; rep(i, n) { if (table.empty()) table.pb(-a[i]); else { int idx = upper_bound(all(table), -a[i]) - table.begin(); if (idx == table.size()) { table.pb(-a[i]); } else table[idx] = -a[i]; } } ans = max(ans, (int)table.size()); cout << ans << endl; return 0; }
[ "identifier.change", "call.function.change", "expression.operation.binary.change" ]
781,260
781,261
u376082984
cpp