답안 #443290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443290 2021-07-10T09:42:52 Z BeanZ Money (IZhO17_money) C++14
0 / 100
0 ms 204 KB
// I_Love_LPL 1y0m2d
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
long long mod = 1000007;
const int lim = 4e5 + 5;
const int lg = 20;
const int base = 311;
const long double eps = 1e-6;
ll dp[N][105], a[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("tests.inp", "r")){
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
    ll n;
    cin >> n;
    set<ll> s;
    ll nx = -1, ans = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (nx < 0 || a[i] < a[i - 1] || a[i] >= nx) {
            ans++;
            auto it = s.lower_bound(a[i]);
            if (it == s.end()) nx = 1e9;
            nx = *it;
        }
        s.insert(a[i]);
    }
    cout << ans;
}
/*
6
3 6 4 5 1 2
Ans:

Out:
*/

Compilation message

money.cpp: In function 'int main()':
money.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
money.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -