답안 #361684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361684 2021-01-31T08:53:16 Z daringtrifles 지구 온난화 (NOI13_gw) C++17
13 / 40
552 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#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 1000000000000000000
#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(1000000),sz(1000000);
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;
    }
    
    sort(v.rbegin(),v.rend());
    map<ll,bool> risen;
    ll curr=0,ans=-inf;
    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;
        }
        ans=max(ans,curr);
    }
    cout<<ans;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 16108 KB Output is correct
2 Correct 10 ms 16108 KB Output is correct
3 Correct 10 ms 16108 KB Output is correct
4 Correct 10 ms 16108 KB Output is correct
5 Correct 10 ms 16108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 24044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 24812 KB Output is correct
2 Correct 66 ms 24428 KB Output is correct
3 Correct 111 ms 24940 KB Output is correct
4 Correct 115 ms 24684 KB Output is correct
5 Correct 113 ms 24580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 546 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 552 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -