Submission #877837

# Submission time Handle Problem Language Result Execution time Memory
877837 2023-11-23T17:33:16 Z alexdd Money (IZhO17_money) C++17
0 / 100
1 ms 2396 KB
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n;
int a[1000005];
int dp[1000005];
set<int> s;
bool isgood(int le, int ri)///le < x < ri
{
    if(s.empty())
        return 1;
    auto it = s.upper_bound(le);
    if(it!=s.end() && *it < ri)
        return 0;
    return 1;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    int ultr=0;
    int poz=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i>1 && a[i]<a[i-1])
            ultr=i-1;
        for(int j=poz;j<i;j++)
        {
            if(j>=ultr && isgood(a[j+1],a[i]))///daca se poate
            {
                poz=j;
                dp[i] = dp[poz]+1;
                break;
            }
            s.insert(a[j]);
        }
    }
    cout<<dp[n];
    return 0;
}
/**
6
3 6 4 5 1 2
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Incorrect 0 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Incorrect 0 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Incorrect 0 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Incorrect 0 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -