답안 #341844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341844 2020-12-31T07:40:07 Z Redhood Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
1039 ms 88432 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define len(x) (int)(x).size()
#define pb push_back
#define p2(x) (x)*(x)
#define all(x) (x).begin() , (x).end()
#define mkp make_pair


//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("-O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long double ld;
typedef long long ll;
const int N = 1e6 + 10;
const int inf = 1e9;
int fen[N];
void add(int v , int mn){
    for(;v<N;v += v & -v)
        fen[v] = max(fen[v] , mn);
}
int get(int r){
    int ans = -inf;
    for(;r > 0 ; r -= r & -r)
        ans = max(ans , fen[r]);
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n , m;cin >> n >> m;
    vector < int > w(n);
    for(auto &i  : w)
        cin >> i;
    vector < int > answer(m) , K(m);
    vector < vector < pair < int , int > > > left(n + 1);


    for(int qq = 0; qq < m; ++qq){
        int l , r , k;
        cin >> l >> r >> k;
        --l , --r;
        K[qq] = k;
        left[l].pb({qq , r});
    }
    vector < int > stac;
    fill(fen , fen + N , -inf);
    for(int l = n - 1; l  >= 0 ;--l){
        while(!stac.empty() && w[stac.back()] < w[l]){
            int lul = stac.back();
            add(lul , w[l]+w[stac.back()]);
            stac.pop_back();
        }
        stac.pb(l);
        for(auto u : left[l]){
            answer[u.fi] = get(u.se);
        }
    }
//    cout << " ANSWER \n";
//    for(auto u : answer)
//        cout << u << '\n';
    for(int i = 0 ; i < m; ++i){
        if(K[i] >= answer[i])
            cout << 1;
        else
            cout << 0;
        cout << '\n';
    }
    return 0;
}
/*


*/

# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4224 KB Output is correct
4 Correct 3 ms 4076 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 3 ms 4332 KB Output is correct
7 Correct 3 ms 4332 KB Output is correct
8 Correct 3 ms 4332 KB Output is correct
9 Correct 3 ms 4204 KB Output is correct
10 Correct 3 ms 4332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4224 KB Output is correct
4 Correct 3 ms 4076 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 3 ms 4332 KB Output is correct
7 Correct 3 ms 4332 KB Output is correct
8 Correct 3 ms 4332 KB Output is correct
9 Correct 3 ms 4204 KB Output is correct
10 Correct 3 ms 4332 KB Output is correct
11 Correct 5 ms 4332 KB Output is correct
12 Correct 5 ms 4460 KB Output is correct
13 Correct 6 ms 4588 KB Output is correct
14 Correct 7 ms 4716 KB Output is correct
15 Correct 7 ms 4716 KB Output is correct
16 Correct 7 ms 4716 KB Output is correct
17 Correct 6 ms 4588 KB Output is correct
18 Correct 6 ms 4588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 997 ms 61984 KB Output is correct
2 Correct 992 ms 61920 KB Output is correct
3 Correct 1000 ms 61676 KB Output is correct
4 Correct 1014 ms 61672 KB Output is correct
5 Correct 980 ms 65764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 10092 KB Output is correct
2 Correct 68 ms 9856 KB Output is correct
3 Correct 70 ms 10600 KB Output is correct
4 Correct 72 ms 10852 KB Output is correct
5 Correct 72 ms 10860 KB Output is correct
6 Correct 53 ms 9832 KB Output is correct
7 Correct 53 ms 9832 KB Output is correct
8 Correct 62 ms 10216 KB Output is correct
9 Correct 40 ms 6500 KB Output is correct
10 Correct 62 ms 10212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4224 KB Output is correct
4 Correct 3 ms 4076 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 3 ms 4332 KB Output is correct
7 Correct 3 ms 4332 KB Output is correct
8 Correct 3 ms 4332 KB Output is correct
9 Correct 3 ms 4204 KB Output is correct
10 Correct 3 ms 4332 KB Output is correct
11 Correct 5 ms 4332 KB Output is correct
12 Correct 5 ms 4460 KB Output is correct
13 Correct 6 ms 4588 KB Output is correct
14 Correct 7 ms 4716 KB Output is correct
15 Correct 7 ms 4716 KB Output is correct
16 Correct 7 ms 4716 KB Output is correct
17 Correct 6 ms 4588 KB Output is correct
18 Correct 6 ms 4588 KB Output is correct
19 Correct 179 ms 16492 KB Output is correct
20 Correct 184 ms 16236 KB Output is correct
21 Correct 148 ms 14828 KB Output is correct
22 Correct 145 ms 14828 KB Output is correct
23 Correct 152 ms 14844 KB Output is correct
24 Correct 142 ms 15712 KB Output is correct
25 Correct 132 ms 15584 KB Output is correct
26 Correct 151 ms 16232 KB Output is correct
27 Correct 153 ms 16228 KB Output is correct
28 Correct 155 ms 16480 KB Output is correct
29 Correct 171 ms 17144 KB Output is correct
30 Correct 175 ms 17124 KB Output is correct
31 Correct 174 ms 16992 KB Output is correct
32 Correct 179 ms 16992 KB Output is correct
33 Correct 171 ms 17216 KB Output is correct
34 Correct 126 ms 15208 KB Output is correct
35 Correct 123 ms 15080 KB Output is correct
36 Correct 119 ms 15132 KB Output is correct
37 Correct 117 ms 15208 KB Output is correct
38 Correct 123 ms 15080 KB Output is correct
39 Correct 141 ms 15848 KB Output is correct
40 Correct 123 ms 13792 KB Output is correct
41 Correct 146 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4224 KB Output is correct
4 Correct 3 ms 4076 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 3 ms 4332 KB Output is correct
7 Correct 3 ms 4332 KB Output is correct
8 Correct 3 ms 4332 KB Output is correct
9 Correct 3 ms 4204 KB Output is correct
10 Correct 3 ms 4332 KB Output is correct
11 Correct 5 ms 4332 KB Output is correct
12 Correct 5 ms 4460 KB Output is correct
13 Correct 6 ms 4588 KB Output is correct
14 Correct 7 ms 4716 KB Output is correct
15 Correct 7 ms 4716 KB Output is correct
16 Correct 7 ms 4716 KB Output is correct
17 Correct 6 ms 4588 KB Output is correct
18 Correct 6 ms 4588 KB Output is correct
19 Correct 997 ms 61984 KB Output is correct
20 Correct 992 ms 61920 KB Output is correct
21 Correct 1000 ms 61676 KB Output is correct
22 Correct 1014 ms 61672 KB Output is correct
23 Correct 980 ms 65764 KB Output is correct
24 Correct 75 ms 10092 KB Output is correct
25 Correct 68 ms 9856 KB Output is correct
26 Correct 70 ms 10600 KB Output is correct
27 Correct 72 ms 10852 KB Output is correct
28 Correct 72 ms 10860 KB Output is correct
29 Correct 53 ms 9832 KB Output is correct
30 Correct 53 ms 9832 KB Output is correct
31 Correct 62 ms 10216 KB Output is correct
32 Correct 40 ms 6500 KB Output is correct
33 Correct 62 ms 10212 KB Output is correct
34 Correct 179 ms 16492 KB Output is correct
35 Correct 184 ms 16236 KB Output is correct
36 Correct 148 ms 14828 KB Output is correct
37 Correct 145 ms 14828 KB Output is correct
38 Correct 152 ms 14844 KB Output is correct
39 Correct 142 ms 15712 KB Output is correct
40 Correct 132 ms 15584 KB Output is correct
41 Correct 151 ms 16232 KB Output is correct
42 Correct 153 ms 16228 KB Output is correct
43 Correct 155 ms 16480 KB Output is correct
44 Correct 171 ms 17144 KB Output is correct
45 Correct 175 ms 17124 KB Output is correct
46 Correct 174 ms 16992 KB Output is correct
47 Correct 179 ms 16992 KB Output is correct
48 Correct 171 ms 17216 KB Output is correct
49 Correct 126 ms 15208 KB Output is correct
50 Correct 123 ms 15080 KB Output is correct
51 Correct 119 ms 15132 KB Output is correct
52 Correct 117 ms 15208 KB Output is correct
53 Correct 123 ms 15080 KB Output is correct
54 Correct 141 ms 15848 KB Output is correct
55 Correct 123 ms 13792 KB Output is correct
56 Correct 146 ms 16000 KB Output is correct
57 Correct 1039 ms 63596 KB Output is correct
58 Correct 1030 ms 81772 KB Output is correct
59 Correct 989 ms 79564 KB Output is correct
60 Correct 974 ms 79724 KB Output is correct
61 Correct 972 ms 79624 KB Output is correct
62 Correct 988 ms 79596 KB Output is correct
63 Correct 668 ms 88432 KB Output is correct
64 Correct 675 ms 88412 KB Output is correct
65 Correct 929 ms 83668 KB Output is correct
66 Correct 923 ms 83668 KB Output is correct
67 Correct 937 ms 83796 KB Output is correct
68 Correct 989 ms 85848 KB Output is correct
69 Correct 991 ms 85592 KB Output is correct
70 Correct 976 ms 85204 KB Output is correct
71 Correct 980 ms 85132 KB Output is correct
72 Correct 978 ms 85080 KB Output is correct
73 Correct 590 ms 86532 KB Output is correct
74 Correct 631 ms 87508 KB Output is correct
75 Correct 592 ms 86484 KB Output is correct
76 Correct 589 ms 86504 KB Output is correct
77 Correct 589 ms 86476 KB Output is correct
78 Correct 837 ms 87356 KB Output is correct
79 Correct 647 ms 68192 KB Output is correct
80 Correct 815 ms 85624 KB Output is correct