답안 #553183

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
553183 2022-04-25T03:08:48 Z Tien_Noob Money (IZhO17_money) C++17
0 / 100
1 ms 212 KB
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
#define Log2(x) 31 - __builtin_clz(x)
using namespace std;
const int N = 1e6;
int dp[N + 1], n, p = - 1, a[N + 1];
queue<int> Q;
set<int> Set;
void read()
{
    cin >> n;
    a[0] = 1e9;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        if (a[i] < a[i - 1] || a[i] > p)
        {
            while(!Q.empty())
            {
                Set.insert(Q.front());
                Q.pop();
            }
            dp[i] = dp[i - 1] + 1;
            auto it = Set.upper_bound(a[i]);
            p = (it == Set.end() ? N + 1 : *it);
        }
        else
        {
            dp[i] = dp[i - 1];
        }
        Q.push(i);
    }
    cout << dp[n];
}
void solve()
{

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen(TASK".INP", "r"))
    {
        freopen(TASK".INP", "r", stdin);
        //freopen(TASK".OUT", "w", stdout);
    }
    int t = 1;
    bool typetest = false;
    if (typetest)
    {
        cin >> t;
    }
    for (int __ = 1; __ <= t; ++ __)
    {
        //cout << "Case " << __ << ": ";
        read();
        solve();
    }
}

Compilation message

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