Submission #794293

# Submission time Handle Problem Language Result Execution time Memory
794293 2023-07-26T12:12:38 Z TahirAliyev Stranded Far From Home (BOI22_island) C++17
0 / 100
1 ms 308 KB
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
 
using namespace std;
 
#define ll long long int
#define oo 4e18
#define pii pair<int, int>

const int MAX = 2e5 + 5;

ll Presum[MAX];
int arr[MAX];
int ans[MAX];

int main(){
    int n, m; cin >> n >> m;
    vector<pii> v;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
        Presum[i] = Presum[i - 1] + arr[i];
        v.push_back({arr[i], i});
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for (int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
    }
    set<int> s;
    s.insert(0);
    s.insert(n + 1);
    s.insert(v[0].second);
    
    ans[v[0].second] = 1;
    for(pii &a: v){
        auto itr = s.lower_bound(a.second);
        int l = (*(prev(itr)));
        int r = (*itr);
        ll sum = Presum[r - 1] - Presum[l];
        cout << sum << '\n';
        s.insert(a.second);
        if((sum >= arr[l] && sum >= arr[r]) || (sum >= arr[l] && ans[l]) || (sum >= arr[r] && ans[r])){
            ans[a.second] = 1;
            continue;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i];
    }
    
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -