답안 #470799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
470799 2021-09-05T17:00:09 Z Killer2501 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
1275 ms 125576 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "tests"
#define pll pair<ll, ll>
#define pi pair<ll, pll>
#define fi first
#define se second

using namespace std;
const ll mod = 1e9;
const ll N = 1e6+55;
const int base = 313;
ll n, m, t, k, T, ans, q, tong, c[N], a[N], b[N], h[N], d[N], lab[N], fe[N];
vector<ll> adj[N], kq;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
void add(ll id, ll x)
{
    for(; id; id -= id & -id)fe[id] = max(fe[id], x);
}
ll get(ll id)
{
    ll total = 0;
    for(; id <= n; id += id & -id)total = max(total, fe[id]);
    return total;
}
void sol()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    for(int i = 1; i <= m; i ++)
    {
        cin >> b[i] >> c[i] >> h[i];
        adj[c[i]].pb(i);
    }
    for(int i = 1; i <= n; i ++)
    {
        while(!kq.empty() && a[i] >= a[kq.back()])kq.pop_back();
        k = kq.empty() ? 0 : kq.back();
        add(k, a[k]+a[i]);
        for(ll j: adj[i])
        {
            d[j] = (get(b[j]) <= h[j]);
        }
        kq.pb(i);
    }
    for(int i = 1; i <= m; i ++)cout << d[i] << '\n';
}
int main()
{
    if(fopen(task".in", "r"))
    {
       freopen(task".in", "r", stdin);
       freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:62:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:63:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23852 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 14 ms 23808 KB Output is correct
8 Correct 14 ms 23836 KB Output is correct
9 Correct 15 ms 23884 KB Output is correct
10 Correct 13 ms 23756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23852 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 14 ms 23808 KB Output is correct
8 Correct 14 ms 23836 KB Output is correct
9 Correct 15 ms 23884 KB Output is correct
10 Correct 13 ms 23756 KB Output is correct
11 Correct 15 ms 23920 KB Output is correct
12 Correct 16 ms 24012 KB Output is correct
13 Correct 16 ms 24012 KB Output is correct
14 Correct 17 ms 24140 KB Output is correct
15 Correct 18 ms 24128 KB Output is correct
16 Correct 16 ms 24048 KB Output is correct
17 Correct 17 ms 24152 KB Output is correct
18 Correct 16 ms 24088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1182 ms 116472 KB Output is correct
2 Correct 1196 ms 125576 KB Output is correct
3 Correct 1221 ms 125412 KB Output is correct
4 Correct 1163 ms 125460 KB Output is correct
5 Correct 1056 ms 117568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 30532 KB Output is correct
2 Correct 77 ms 30036 KB Output is correct
3 Correct 76 ms 29628 KB Output is correct
4 Correct 78 ms 29752 KB Output is correct
5 Correct 80 ms 29816 KB Output is correct
6 Correct 76 ms 29092 KB Output is correct
7 Correct 69 ms 28996 KB Output is correct
8 Correct 78 ms 29652 KB Output is correct
9 Correct 56 ms 28092 KB Output is correct
10 Correct 92 ms 29628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23852 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 14 ms 23808 KB Output is correct
8 Correct 14 ms 23836 KB Output is correct
9 Correct 15 ms 23884 KB Output is correct
10 Correct 13 ms 23756 KB Output is correct
11 Correct 15 ms 23920 KB Output is correct
12 Correct 16 ms 24012 KB Output is correct
13 Correct 16 ms 24012 KB Output is correct
14 Correct 17 ms 24140 KB Output is correct
15 Correct 18 ms 24128 KB Output is correct
16 Correct 16 ms 24048 KB Output is correct
17 Correct 17 ms 24152 KB Output is correct
18 Correct 16 ms 24088 KB Output is correct
19 Correct 202 ms 37316 KB Output is correct
20 Correct 193 ms 37288 KB Output is correct
21 Correct 207 ms 36160 KB Output is correct
22 Correct 166 ms 36164 KB Output is correct
23 Correct 160 ms 36224 KB Output is correct
24 Correct 144 ms 34500 KB Output is correct
25 Correct 156 ms 34604 KB Output is correct
26 Correct 162 ms 35052 KB Output is correct
27 Correct 162 ms 34996 KB Output is correct
28 Correct 172 ms 35284 KB Output is correct
29 Correct 183 ms 35704 KB Output is correct
30 Correct 182 ms 35780 KB Output is correct
31 Correct 182 ms 35872 KB Output is correct
32 Correct 188 ms 35856 KB Output is correct
33 Correct 187 ms 35632 KB Output is correct
34 Correct 154 ms 34244 KB Output is correct
35 Correct 150 ms 34320 KB Output is correct
36 Correct 145 ms 34244 KB Output is correct
37 Correct 142 ms 34336 KB Output is correct
38 Correct 152 ms 34244 KB Output is correct
39 Correct 171 ms 36028 KB Output is correct
40 Correct 142 ms 34596 KB Output is correct
41 Correct 170 ms 35764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23852 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 14 ms 23808 KB Output is correct
8 Correct 14 ms 23836 KB Output is correct
9 Correct 15 ms 23884 KB Output is correct
10 Correct 13 ms 23756 KB Output is correct
11 Correct 15 ms 23920 KB Output is correct
12 Correct 16 ms 24012 KB Output is correct
13 Correct 16 ms 24012 KB Output is correct
14 Correct 17 ms 24140 KB Output is correct
15 Correct 18 ms 24128 KB Output is correct
16 Correct 16 ms 24048 KB Output is correct
17 Correct 17 ms 24152 KB Output is correct
18 Correct 16 ms 24088 KB Output is correct
19 Correct 1182 ms 116472 KB Output is correct
20 Correct 1196 ms 125576 KB Output is correct
21 Correct 1221 ms 125412 KB Output is correct
22 Correct 1163 ms 125460 KB Output is correct
23 Correct 1056 ms 117568 KB Output is correct
24 Correct 85 ms 30532 KB Output is correct
25 Correct 77 ms 30036 KB Output is correct
26 Correct 76 ms 29628 KB Output is correct
27 Correct 78 ms 29752 KB Output is correct
28 Correct 80 ms 29816 KB Output is correct
29 Correct 76 ms 29092 KB Output is correct
30 Correct 69 ms 28996 KB Output is correct
31 Correct 78 ms 29652 KB Output is correct
32 Correct 56 ms 28092 KB Output is correct
33 Correct 92 ms 29628 KB Output is correct
34 Correct 202 ms 37316 KB Output is correct
35 Correct 193 ms 37288 KB Output is correct
36 Correct 207 ms 36160 KB Output is correct
37 Correct 166 ms 36164 KB Output is correct
38 Correct 160 ms 36224 KB Output is correct
39 Correct 144 ms 34500 KB Output is correct
40 Correct 156 ms 34604 KB Output is correct
41 Correct 162 ms 35052 KB Output is correct
42 Correct 162 ms 34996 KB Output is correct
43 Correct 172 ms 35284 KB Output is correct
44 Correct 183 ms 35704 KB Output is correct
45 Correct 182 ms 35780 KB Output is correct
46 Correct 182 ms 35872 KB Output is correct
47 Correct 188 ms 35856 KB Output is correct
48 Correct 187 ms 35632 KB Output is correct
49 Correct 154 ms 34244 KB Output is correct
50 Correct 150 ms 34320 KB Output is correct
51 Correct 145 ms 34244 KB Output is correct
52 Correct 142 ms 34336 KB Output is correct
53 Correct 152 ms 34244 KB Output is correct
54 Correct 171 ms 36028 KB Output is correct
55 Correct 142 ms 34596 KB Output is correct
56 Correct 170 ms 35764 KB Output is correct
57 Correct 1275 ms 104992 KB Output is correct
58 Correct 1166 ms 125096 KB Output is correct
59 Correct 1107 ms 122256 KB Output is correct
60 Correct 1136 ms 122268 KB Output is correct
61 Correct 1148 ms 122180 KB Output is correct
62 Correct 1124 ms 122144 KB Output is correct
63 Correct 773 ms 109000 KB Output is correct
64 Correct 776 ms 108952 KB Output is correct
65 Correct 975 ms 114180 KB Output is correct
66 Correct 1008 ms 114116 KB Output is correct
67 Correct 1004 ms 114232 KB Output is correct
68 Correct 1049 ms 117228 KB Output is correct
69 Correct 1073 ms 96964 KB Output is correct
70 Correct 1045 ms 96456 KB Output is correct
71 Correct 1052 ms 96540 KB Output is correct
72 Correct 1075 ms 96556 KB Output is correct
73 Correct 738 ms 88576 KB Output is correct
74 Correct 776 ms 88456 KB Output is correct
75 Correct 749 ms 88468 KB Output is correct
76 Correct 728 ms 88492 KB Output is correct
77 Correct 753 ms 105668 KB Output is correct
78 Correct 965 ms 106232 KB Output is correct
79 Correct 751 ms 98476 KB Output is correct
80 Correct 949 ms 106864 KB Output is correct