답안 #794294

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794294 2023-07-26T12:13:11 Z TahirAliyev Stranded Far From Home (BOI22_island) C++17
0 / 100
238 ms 18924 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];
        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];
    }
    
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Incorrect 2 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 215 ms 18920 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 238 ms 18904 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 203 ms 18924 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Incorrect 2 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -