Submission #37184

#TimeUsernameProblemLanguageResultExecution timeMemory
37184Ulugbek_AbdimanabovMoney (IZhO17_money)C++14
0 / 100
0 ms21548 KiB
//Solution by Zhusupov Nurlan
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define endl '\n'
#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base LL(1e9 + 7)
#define fname "money."
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define mp make_pair

int n, a[sz], ans, d[sz], was[sz];
PII b[sz];

int main()
{
    freopen(fname"in", "r", stdin);
    freopen(fname"out", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      d[i] = INF;
    }

    for (int i = 1; i <= n; i++) {
      int l = 0, r = n + 1;
      while (r - l > 1) {
        int m = (l + r) >> 1;
        if (a[i] <= d[m])
          r = m;
        else
          l = m;
      }
        ans = max(ans, r);
        d[r] = a[i];
    }
    cout << ans << "\n";
}

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:30:35: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(fname"in", "r", stdin);
                                   ^
money.cpp:31:37: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(fname"out", "w", stdout);
                                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...