Submission #1292349

#TimeUsernameProblemLanguageResultExecution timeMemory
1292349binminh01LIS (INOI20_lis)C++20
20 / 100
4091 ms924 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define sz(a) (int)a.size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define eb emplace_back
#define open(s) freopen(s, "r", stdin)
#define write(s) freopen(s, "w", stdout)
using pii = pair<int, int>;
using pll = pair<ll, ll>;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vdo;
typedef vector<vdo> vvdo;
typedef vector<string> vs;
typedef vector<pii> vpair;
typedef vector<vpair> vvpair;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> pqg;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vll, greater<ll>> pqgll;
#define For(i, a, b) for (auto i = (a); i < (b); ++i)
#define FOR(i, a, b) for (auto i = (a); i <= (b); ++i)
#define Fore(i, a, b) for (auto i = (a); i >= (b); --i)
#define trav(i, a) for (auto &i: a)

int q;
namespace sub1 {
    int lis(const vi &a) {
        vi b;
        trav(v,a){
            int i = lower_bound(all(b), v) - b.begin();
            if (i == sz(b)) b.pb(v);
            else b[i] = v;
        }
        return sz(b);
    }
    void solve() {
        vi a;
        while (q--) {
            int k, v; cin >> k >> v;
            a.insert(a.begin() + k - 1, v);
            cout << lis(a) << '\n';
        }
    }
};
int main() {
    if (fopen("lis.inp", "r")) freopen("lis.inp", "r", stdin), freopen("lis.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> q;
    sub1::solve();
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:57:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     if (fopen("lis.inp", "r")) freopen("lis.inp", "r", stdin), freopen("lis.out", "w", stdout);
      |                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:57:71: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     if (fopen("lis.inp", "r")) freopen("lis.inp", "r", stdin), freopen("lis.out", "w", stdout);
      |                                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...