Submission #361690

# Submission time Handle Problem Language Result Execution time Memory
361690 2021-01-31T09:10:04 Z daringtrifles Global Warming (NOI13_gw) C++17
23 / 40
328 ms 25580 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll int
#define pll pair<ll, ll>
#define FOR(i, a, b) for (signed ll i = (signed ll)(a); i < (signed ll)(b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<ll>
#define sll set<ll>
#define ld long double
#define inf 10000000000
#define mll multiset<ll>
#define vpll vector<pll>
#define nn << "\n"
#define ss << " "
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18

//ALL FUNCTIONS SHOULD BE LL!!!!
vll parent(1000005),sz(1000005);
void make_set(ll v) {
    parent[v] = v;
    sz[v] = 1;
}
ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void unite(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (sz[a] < sz[b])
            swap(a, b);
        parent[b] = a;
        sz[a] += sz[b];
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;

    vpll v(n);

    FOR(i,0,n){
        cin>>v[i].first; v[i].second=i+1;
    }
    
    sort(v.rbegin(),v.rend());
    vector<bool> risen(n+5);
    ll curr=0,ans=-1;
    FOR(i,0,n){
        make_set(v[i].second);
        curr++;
        risen[v[i].second]=1;
        if (risen[v[i].second-1]){
            unite(v[i].second-1,v[i].second); --curr;
        }
        if (risen[v[i].second+1]){
            unite(v[i].second+1,v[i].second);--curr;
        }
        if (i+1<n&&v[i+1].second==v[i].second) continue;
        ans=max(ans,curr);
    }
    cout<<ans;

}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8172 KB Output is correct
2 Correct 8 ms 8172 KB Output is correct
3 Correct 5 ms 8172 KB Output is correct
4 Correct 6 ms 8172 KB Output is correct
5 Correct 7 ms 8320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 8940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 9068 KB Output is correct
2 Correct 21 ms 8940 KB Output is correct
3 Correct 29 ms 8940 KB Output is correct
4 Correct 30 ms 8940 KB Output is correct
5 Correct 28 ms 8940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 315 ms 16180 KB Output is correct
2 Correct 318 ms 25544 KB Output is correct
3 Correct 306 ms 25452 KB Output is correct
4 Correct 328 ms 25580 KB Output is correct
5 Correct 301 ms 25068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 320 ms 16180 KB Output is correct
2 Correct 321 ms 24940 KB Output is correct
3 Correct 323 ms 24940 KB Output is correct
4 Incorrect 284 ms 19052 KB Output isn't correct
5 Halted 0 ms 0 KB -