QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#569616#367. Long Mansionmakrav100 ✓217ms77452kbC++203.6kb2024-09-17 01:32:312024-09-17 01:32:32

Judging History

你现在查看的是最新测评结果

  • [2024-09-17 01:32:32]
  • 评测
  • 测评结果:100
  • 用时:217ms
  • 内存:77452kb
  • [2024-09-17 01:32:31]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second

// struct segtree {
//     int n;
//     vector<int> t;
//     segtree() = default;
//     segtree(int n_) {
//         n = n_;
//         t.assign(4 * n, 0);
//     }

//     void upd(int v, int tl, int tr, int p) {
//         if (tl + 1 == tr) {
//             t[v] = 1;
//             return;
//         }
//         int tm = (tl + tr) / 2;
//         if (p < tm) upd(v * 2, tl, tm, p);
//         else upd(v * 2 + 1, tm, tr, p);
//         t[v] = 1;
//     }

//     int getl1(int v, int tl, int tr, int l, int r) {
//         if (!t[v]) return -1;
//         if (tr <= l || tl >= r) return -1;
//         if (tl + 1 == tr) return tl;
//         int tm = (tl + tr) / 2;
//         int asw = getl1(v * 2, tl, tm, l, r);
//         if (asw == -1) return getl1(v * 2 + 1, tm, tr, l, r);
//         return asw;
//     }
// };  

void solve() {
    int n; cin >> n;
    vector<int> c(n - 1);
    vector<vector<int>> pos_doors(n + 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i]; pos_doors[c[i]].pb(i);
    }
    vector<vector<int>> keys(n);
    vector<vector<int>> pos(n + 1);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        keys[i].assign(k, 0);
        for (int j = 0; j < k; j++) {
            cin >> keys[i][j];
            pos[keys[i][j]].pb(i);
        }
    }
    auto checkr = [&](int l, int r) {
        if (r == n - 1) return false;
        int dn = c[r];
        auto it = lower_bound(all(pos[dn]), l);
        if (it - pos[dn].begin() == sz(pos[dn]) || pos[dn][it - pos[dn].begin()] > r) return false;
        return true;
    };
    auto checkl = [&](int l, int r) {
        if (l == 0) return false;
        int dn = c[l - 1];
        auto it = lower_bound(all(pos[dn]), l);
        if (it - pos[dn].begin() == sz(pos[dn]) || pos[dn][it - pos[dn].begin()] > r) return false;
        return true;
    };

    vector<int> right(n);
    stack<pair<int, int>> segs;
    for (int i = n - 1; i >= 0; i--) {
        int curr = i;
        while (!segs.empty()) {
            if (checkr(i, curr)) {
                curr = segs.top().second;
                segs.pop();
            } else break;
        }
        right[i] = curr;
        segs.push({i, curr});
    }
    //return;
    
    vector<pair<int, int>> ans(n);
    //stack<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        if (i > 0 && ans[i - 1].second >= i) {
            if (checkl(i, right[i])) ans[i] = ans[i - 1];
            else ans[i] = {i, right[i]};
        } else {
            int l = i, r = right[i];
            while (true) {
                if (checkl(l, r)) {
                    r = max(r, ans[l - 1].second);
                    l = min(l, ans[l - 1].first);
                }
                else if (checkr(l, r)) {
                    r++;
                }
                else break;
            }
            ans[i] = {l, r};
        }
    }
    int q; cin >> q;
    while (q--) {
        int x, y; cin >> x >> y;
        x--; y--;
        cout << (ans[x].first <= y && y <= ans[x].second ? "YES\n" : "NO\n");
    }
}

signed main() {
    int tt = 1;
    #ifdef LOCAL 
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        ios::sync_with_stdio(false); 
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 3884kb

input:

2000
10 7 7 6 12 13 3 13 10 13 10 4 1 12 13 10 10 11 14 9 2 15 15 12 6 1 7 11 14 2 4 12 15 2 4 1 7 3 8 1 10 9 10 9 1 1 3 3 10 8 14 7 15 12 4 15 13 14 13 2 6 9 12 6 12 10 11 9 15 8 15 11 2 7 9 13 14 1 1 10 14 13 13 14 15 6 8 2 1 11 11 5 4 4 13 3 6 6 12 13 1 10 6 1 15 14 6 4 7 4 13 5 1 2 11 1 8 10 7 7...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 5000 lines

Test #2:

score: 5
Accepted
time: 2ms
memory: 4088kb

input:

3000
1 4 1 3 3 4 1 2 4 1 2 3 4 2 3 4 4 1 3 1 4 2 2 4 3 3 2 1 3 2 1 3 4 4 3 2 3 2 2 4 4 1 1 3 4 1 4 1 4 1 3 3 4 1 2 1 2 4 2 1 2 1 2 3 3 3 4 2 3 2 1 2 2 1 1 1 1 1 3 3 4 1 4 4 4 4 4 1 2 4 2 2 3 3 4 2 4 3 1 2 4 1 2 1 4 1 4 4 1 3 4 3 1 2 1 3 3 2 1 2 1 2 2 4 3 3 2 4 3 3 3 1 2 1 2 4 4 1 4 1 2 1 4 4 2 2 4 2...

output:

NO
YES
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
NO
NO
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
NO
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO...

result:

ok 5000 lines

Test #3:

score: 5
Accepted
time: 3ms
memory: 4160kb

input:

5000
1 2 1 1 2 1 2 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 1 1 2 2 1 2 1 2 2 1 1 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 1 2 2 2 2 2 1 1 1 1 2 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 1 2 1 1 1...

output:

YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
...

result:

ok 5000 lines

Test #4:

score: 5
Accepted
time: 2ms
memory: 3908kb

input:

2000
583 580 319 242 218 934 584 174 18 1224 1376 793 803 842 1430 1269 1442 225 1470 376 1017 352 1081 587 689 582 492 930 918 1266 105 598 1273 343 1047 1499 247 1409 1061 1246 1248 324 1362 1254 208 1448 1438 58 1125 270 1029 355 555 212 881 1232 1093 351 1353 1436 236 498 28 635 187 1439 1257 14...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
...

result:

ok 5000 lines

Test #5:

score: 5
Accepted
time: 0ms
memory: 3936kb

input:

2000
32 16 47 21 12 29 8 37 50 11 22 44 1 17 3 16 19 43 27 23 32 20 28 12 30 36 12 13 24 22 30 7 45 27 33 19 3 7 3 2 33 13 3 40 26 34 42 8 25 42 28 16 48 31 46 43 45 4 37 35 37 46 43 13 3 12 40 20 8 20 47 6 19 3 16 8 21 37 24 30 44 49 34 21 18 41 23 38 13 9 39 50 40 43 17 2 15 31 43 17 8 11 4 41 35 ...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YE...

result:

ok 5000 lines

Test #6:

score: 5
Accepted
time: 2ms
memory: 3976kb

input:

2000
393 319 1075 467 1727 78 1638 314 1362 1450 906 1073 899 1271 1520 1329 1545 170 962 1240 234 1392 593 184 1177 1387 426 130 1896 1179 407 1322 607 1589 1825 1959 1525 1442 499 1177 139 998 682 1095 1944 1626 1161 917 831 1289 553 1406 653 644 1694 1476 1342 451 52 881 1519 1465 792 1544 862 13...

output:

NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
...

result:

ok 5000 lines

Test #7:

score: 5
Accepted
time: 2ms
memory: 3972kb

input:

2000
1600 1598 1596 1594 1592 1590 1588 1586 1584 1582 1580 1578 1576 1574 1572 1570 1568 1566 1564 1562 1560 1558 1556 1554 1552 1550 1548 1546 1544 1542 1540 1538 1536 1534 1532 1530 1528 1526 1524 1522 1520 1518 1516 1514 1512 1510 1508 1506 1504 1502 1500 1498 1496 1494 1492 1490 1488 1486 1484 ...

output:

YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
N...

result:

ok 5000 lines

Subtask #2:

score: 5
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 5
Accepted
time: 50ms
memory: 3928kb

input:

2000
2 6 4 1 2 7 2 2 7 6 8 4 8 7 4 5 5 10 8 7 1 1 3 1 1 5 10 2 6 1 5 10 4 5 3 1 1 9 10 9 6 2 5 2 1 10 3 8 4 3 1 3 7 6 10 1 7 1 7 1 1 6 5 10 9 8 1 10 7 5 2 9 9 8 5 3 10 7 4 3 3 9 5 8 4 3 1 6 3 4 1 4 1 9 2 5 5 6 3 10 10 7 1 4 5 4 10 1 10 2 7 4 10 10 3 2 7 4 5 8 3 6 1 6 6 8 10 3 7 8 6 9 4 1 5 8 6 8 5 3...

output:

NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
N...

result:

ok 500000 lines

Test #9:

score: 5
Accepted
time: 54ms
memory: 3836kb

input:

2000
12 10 1 9 6 12 9 5 14 11 3 4 13 5 4 3 9 1 3 11 3 14 11 15 3 1 6 7 12 6 8 8 11 15 14 11 4 5 1 1 8 1 9 4 3 4 4 12 6 14 5 8 9 9 3 9 4 4 10 11 6 1 8 9 15 2 15 11 12 15 6 11 15 5 15 11 12 2 8 13 7 7 7 3 13 1 11 7 15 7 14 1 4 6 8 15 1 10 4 10 15 7 6 14 9 13 1 9 6 15 14 5 9 6 5 1 6 15 2 10 4 1 13 4 2 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Test #10:

score: 5
Accepted
time: 55ms
memory: 3940kb

input:

3000
4 3 4 2 2 4 1 4 4 1 1 4 3 3 3 2 2 2 2 2 4 3 2 4 2 4 2 3 3 4 1 3 2 2 2 1 3 1 3 1 1 3 2 2 1 4 4 2 1 3 3 3 2 2 2 2 3 1 3 3 4 3 3 1 4 1 2 3 3 4 4 4 3 2 3 4 2 2 1 3 4 4 1 3 3 3 1 2 2 1 4 3 4 3 4 1 1 2 1 2 1 3 1 3 3 2 3 2 4 2 4 1 3 4 1 3 3 2 2 2 4 3 3 4 1 4 2 2 4 3 1 4 1 4 2 3 2 2 3 2 2 4 4 4 3 3 1 1...

output:

NO
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
YES...

result:

ok 500000 lines

Test #11:

score: 5
Accepted
time: 54ms
memory: 4312kb

input:

5000
2 1 1 2 1 1 1 1 2 2 1 1 1 2 1 2 2 1 2 1 2 2 2 2 2 1 1 1 2 1 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 1 2 1 1 2 2 1 1 1 1 2 1 1 2 1 2 2 1 1 1 1 1 1 2 1 2 2 2 1 2 1 1 2 1 1 1 1 2 1 1 1 2 1 2 2 2 2 2 2 2 2 1 1 1 2 2 1 2 1 2 1 1 1 2 1 2 1 1 2 2 1 1 1 1 2 2 1 2 2 2 1 2 1 2 1 2 2 2 1 2 2 1 2 1 2 2 1 1 2 1 2 1 1...

output:

YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO...

result:

ok 500000 lines

Test #12:

score: 5
Accepted
time: 48ms
memory: 3812kb

input:

1000
7 9 6 5 5 6 1 5 8 8 2 2 2 7 8 1 7 1 2 3 5 9 3 8 3 2 4 2 5 2 4 5 8 4 7 8 7 4 9 1 4 7 8 6 4 5 3 8 2 2 7 3 9 6 7 8 9 3 4 6 6 3 1 3 2 6 7 5 2 3 6 2 9 5 6 6 1 7 4 8 2 5 9 1 3 7 4 7 1 2 6 6 6 7 1 6 6 7 3 8 1 3 4 4 5 6 5 4 3 5 5 1 3 9 5 3 4 3 9 8 8 7 1 8 4 1 2 9 5 9 8 2 8 2 7 4 5 5 7 7 3 8 3 1 6 1 9 2...

output:

NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO...

result:

ok 500000 lines

Test #13:

score: 5
Accepted
time: 40ms
memory: 3920kb

input:

2000
7 934 186 622 706 491 44 653 767 868 969 459 53 784 117 200 38 884 163 351 264 227 126 798 848 198 224 13 69 271 14 428 279 247 887 469 618 312 104 665 267 100 549 798 821 628 405 254 272 965 307 579 160 700 148 94 133 866 482 431 356 155 412 478 609 24 503 808 87 173 542 661 838 261 785 294 88...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
NO
N...

result:

ok 500000 lines

Test #14:

score: 5
Accepted
time: 49ms
memory: 3960kb

input:

2000
512 1028 621 489 681 387 852 266 661 1124 791 653 595 876 587 1461 1384 757 858 998 454 264 719 197 982 907 87 7 1242 879 544 1243 1062 1072 83 1069 648 1446 463 1472 455 1044 490 698 289 4 617 1459 500 947 39 272 419 859 363 247 866 1099 414 1317 715 1261 384 755 717 280 236 90 1307 410 611 45...

output:

NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES...

result:

ok 500000 lines

Test #15:

score: 5
Accepted
time: 49ms
memory: 3868kb

input:

2000
68 76 71 44 79 9 100 63 67 57 10 37 13 18 5 38 31 2 10 3 53 52 51 3 53 31 69 9 92 86 99 97 10 32 48 92 87 11 29 87 56 16 16 83 98 29 69 81 95 31 11 5 17 27 20 85 28 21 75 100 96 33 35 28 56 70 93 69 88 56 51 80 77 58 55 92 91 97 91 53 24 52 46 15 27 100 36 45 28 96 4 24 95 27 87 50 89 78 31 53 ...

output:

NO
NO
YES
YES
NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
...

result:

ok 500000 lines

Test #16:

score: 5
Accepted
time: 45ms
memory: 3872kb

input:

2000
29 31 20 23 48 38 11 25 19 42 50 20 1 11 28 23 40 47 16 4 22 38 38 9 18 37 30 11 28 2 13 8 34 38 11 47 12 33 7 15 21 32 4 40 50 25 47 27 14 1 15 19 18 27 23 43 16 29 47 24 29 38 37 43 39 9 46 44 41 35 2 34 35 7 41 50 4 25 22 4 23 45 21 30 40 23 29 39 5 26 11 50 14 29 33 19 30 1 23 48 17 20 28 4...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 500000 lines

Test #17:

score: 5
Accepted
time: 41ms
memory: 3844kb

input:

2000
77 54 98 39 48 26 62 94 31 17 64 35 85 76 90 23 42 14 82 35 14 42 88 86 16 62 14 82 27 56 15 22 72 87 79 90 15 38 64 87 25 21 4 29 55 77 59 9 64 3 16 83 73 57 13 58 9 77 67 16 65 87 80 78 62 94 31 57 86 38 42 34 50 93 31 100 77 3 77 32 59 45 23 62 57 27 19 7 32 82 28 34 69 66 79 53 51 3 72 4 36...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES...

result:

ok 500000 lines

Test #18:

score: 5
Accepted
time: 49ms
memory: 3984kb

input:

2000
13 996 153 283 920 937 117 129 171 126 323 593 586 731 194 955 157 505 375 677 242 378 468 564 492 693 341 9 170 56 843 973 706 946 987 434 139 196 553 552 778 819 45 153 292 358 752 794 155 6 912 606 196 262 135 584 261 648 722 925 259 370 53 795 121 411 860 514 149 550 532 78 900 674 119 558 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
Y...

result:

ok 500000 lines

Test #19:

score: 5
Accepted
time: 49ms
memory: 3892kb

input:

2000
1107 79 168 257 317 1245 730 523 1075 947 517 135 326 702 955 153 383 201 523 867 1279 971 1219 698 53 1203 982 830 277 586 658 1405 31 1142 1086 1464 421 908 859 741 222 613 593 121 668 217 105 1022 637 1239 1457 365 355 1477 1288 317 493 1228 108 784 366 490 478 255 1376 644 141 734 385 1471 ...

output:

YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
...

result:

ok 500000 lines

Test #20:

score: 5
Accepted
time: 48ms
memory: 3928kb

input:

2000
18 77 18 62 90 74 36 29 39 83 11 97 82 95 45 39 10 36 36 70 41 100 43 62 56 50 18 20 87 44 55 38 28 29 24 53 82 55 20 54 35 43 67 6 52 45 87 75 69 71 72 69 16 86 61 26 78 80 52 83 69 57 12 3 2 57 3 1 94 79 6 85 41 20 1 68 51 22 3 11 30 97 92 51 58 53 71 71 19 50 50 37 82 100 25 82 71 9 79 9 27 ...

output:

NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO...

result:

ok 500000 lines

Test #21:

score: 5
Accepted
time: 42ms
memory: 3816kb

input:

2000
35 7 29 42 18 43 3 21 31 31 1 39 26 2 39 40 14 36 19 6 29 50 46 5 15 17 47 10 22 49 8 46 15 33 34 16 35 49 47 15 15 11 18 28 46 26 33 6 44 45 31 11 9 9 39 13 42 42 40 5 11 26 2 48 12 4 34 48 13 7 16 33 35 10 6 37 9 37 28 42 31 47 18 34 13 5 12 43 32 12 31 47 25 11 42 29 15 21 47 39 45 42 37 9 3...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 500000 lines

Test #22:

score: 5
Accepted
time: 41ms
memory: 3980kb

input:

2000
892 53 1960 1156 1451 1304 1017 721 115 1386 735 1627 726 127 8 1950 117 668 1384 526 521 1878 766 236 287 1932 1925 1860 1663 1038 1990 727 1245 40 219 704 1944 671 94 1700 1345 1766 1888 699 1206 1869 1462 726 1707 311 910 956 586 247 479 1877 785 166 254 1170 906 164 1245 950 873 1241 1758 1...

output:

NO
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
N...

result:

ok 500000 lines

Test #23:

score: 5
Accepted
time: 52ms
memory: 3900kb

input:

2000
1600 1598 1596 1594 1592 1590 1588 1586 1584 1582 1580 1578 1576 1574 1572 1570 1568 1566 1564 1562 1560 1558 1556 1554 1552 1550 1548 1546 1544 1542 1540 1538 1536 1534 1532 1530 1528 1526 1524 1522 1520 1518 1516 1514 1512 1510 1508 1506 1504 1502 1500 1498 1496 1494 1492 1490 1488 1486 1484 ...

output:

NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO...

result:

ok 500000 lines

Test #24:

score: 5
Accepted
time: 52ms
memory: 3944kb

input:

2000
1600 1598 1596 1594 1592 1590 1588 1586 1584 1582 1580 1578 1576 1574 1572 1570 1568 1566 1564 1562 1560 1558 1556 1554 1552 1550 1548 1546 1544 1542 1540 1538 1536 1534 1532 1530 1528 1526 1524 1522 1520 1518 1516 1514 1512 1510 1508 1506 1504 1502 1500 1498 1496 1494 1492 1490 1488 1486 1484 ...

output:

YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
YES...

result:

ok 500000 lines

Test #25:

score: 5
Accepted
time: 44ms
memory: 4164kb

input:

2000
1600 1598 1596 1594 1592 1590 1588 1586 1584 1582 1580 1578 1576 1574 1572 1570 1568 1566 1564 1562 1560 1558 1556 1554 1552 1550 1548 1546 1544 1542 1540 1538 1536 1534 1532 1530 1528 1526 1524 1522 1520 1518 1516 1514 1512 1510 1508 1506 1504 1502 1500 1498 1496 1494 1492 1490 1488 1486 1484 ...

output:

NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
N...

result:

ok 500000 lines

Test #26:

score: 5
Accepted
time: 48ms
memory: 4176kb

input:

2000
1800 1798 1796 1794 1792 1790 1788 1786 1784 1782 1780 1778 1776 1774 1772 1770 1768 1766 1764 1762 1760 1758 1756 1754 1752 1750 1748 1746 1744 1742 1740 1738 1736 1734 1732 1730 1728 1726 1724 1722 1720 1718 1716 1714 1712 1710 1708 1706 1704 1702 1700 1698 1696 1694 1692 1690 1688 1686 1684 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Subtask #3:

score: 15
Accepted

Test #27:

score: 15
Accepted
time: 101ms
memory: 17680kb

input:

100000
2 7 4 20 14 19 16 3 15 15 6 18 12 2 2 16 14 15 2 9 5 16 12 6 10 9 18 6 15 11 7 15 20 7 12 1 12 17 4 19 15 5 6 19 3 1 6 18 19 15 3 1 3 3 16 8 20 20 1 3 3 11 1 4 5 20 10 2 19 9 13 20 11 11 5 9 19 3 19 16 13 7 16 20 8 9 19 14 11 9 9 20 16 20 7 6 13 15 3 4 15 15 4 10 15 3 16 5 18 17 19 7 7 2 10 2...

output:

NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Test #28:

score: 15
Accepted
time: 111ms
memory: 17164kb

input:

100000
3 2 8 15 7 1 4 11 15 6 10 7 12 2 13 6 2 7 11 10 2 15 2 10 1 4 5 3 1 9 12 4 14 4 11 13 4 7 4 3 6 11 4 11 2 9 15 9 9 2 9 8 3 14 3 13 11 13 2 4 14 8 7 3 3 14 4 10 9 4 1 15 1 13 6 15 6 1 2 2 4 7 7 13 1 12 15 3 4 7 10 13 14 14 11 13 10 4 11 9 6 5 10 2 4 10 6 5 4 11 13 2 15 11 13 11 9 1 7 10 10 13 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
YE...

result:

ok 500000 lines

Test #29:

score: 15
Accepted
time: 92ms
memory: 17176kb

input:

100000
4 3 9 4 6 9 4 9 10 2 10 1 3 1 4 3 6 6 9 5 4 7 8 8 2 4 5 9 4 8 2 1 3 6 7 2 9 4 7 4 9 9 5 2 8 3 10 8 7 5 1 2 1 7 9 5 1 3 3 3 2 8 8 1 5 10 6 5 2 4 3 7 6 7 4 2 10 8 7 7 4 7 1 8 6 7 9 1 8 7 8 3 8 6 3 2 7 5 8 1 3 9 6 10 8 8 7 8 1 7 1 3 9 10 9 4 5 5 5 2 8 7 1 1 8 2 8 2 9 7 3 1 1 7 2 1 6 8 9 8 2 1 3 ...

output:

NO
NO
NO
YES
YES
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
YES
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
...

result:

ok 500000 lines

Test #30:

score: 15
Accepted
time: 104ms
memory: 17412kb

input:

100000
12 14 16 2 18 6 7 2 18 12 11 14 5 9 14 5 16 3 10 13 6 17 17 8 16 17 8 13 14 4 2 16 8 10 3 11 2 8 14 2 18 9 10 9 13 8 15 11 9 2 16 18 6 8 5 4 6 13 9 2 6 7 18 12 4 5 3 7 2 8 12 17 11 16 3 2 17 6 5 7 1 2 1 16 13 18 13 6 1 12 9 1 18 13 18 6 9 15 2 15 3 10 5 1 16 16 5 17 11 10 9 6 18 5 11 13 10 11...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Test #31:

score: 15
Accepted
time: 111ms
memory: 17320kb

input:

100000
15 17 8 15 2 2 6 15 11 13 1 3 15 17 14 8 7 9 4 9 13 3 12 3 2 12 10 6 10 12 15 7 4 12 6 15 6 12 8 9 8 11 12 14 11 7 4 17 16 16 2 7 1 5 6 9 1 3 17 16 9 11 10 16 11 4 5 14 5 17 13 12 3 4 17 10 8 10 5 16 6 4 1 4 7 5 10 5 8 11 9 1 6 11 9 9 6 15 7 9 10 15 7 17 7 3 5 6 8 16 15 8 10 9 11 5 4 5 17 15 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 500000 lines

Test #32:

score: 15
Accepted
time: 84ms
memory: 16424kb

input:

100000
19 3 17 13 6 8 11 20 18 20 5 10 15 9 16 11 4 8 11 13 18 4 14 17 11 16 18 11 19 20 1 1 2 19 10 19 8 2 4 6 20 17 14 11 4 4 2 5 19 12 8 7 6 16 12 13 13 10 13 15 15 15 16 6 5 20 20 14 11 4 3 7 20 7 6 2 11 8 4 1 8 19 5 9 2 17 2 8 20 9 20 19 2 5 17 1 17 10 8 18 15 9 13 4 18 20 10 20 9 17 9 13 12 9 ...

output:

NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
Y...

result:

ok 500000 lines

Test #33:

score: 15
Accepted
time: 79ms
memory: 16252kb

input:

100000
14 1 17 17 12 1 12 16 5 20 19 11 9 19 16 19 5 10 13 17 12 8 18 12 4 1 17 1 3 10 3 9 10 7 6 12 9 10 10 11 9 13 18 11 14 2 14 17 20 2 13 15 14 3 12 17 14 8 5 9 12 11 10 17 14 11 16 7 9 1 12 11 18 15 14 12 12 19 7 13 5 10 9 11 8 18 18 17 19 15 2 17 7 2 19 10 2 8 10 10 19 8 9 20 8 16 19 19 9 15 8...

output:

YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YE...

result:

ok 500000 lines

Test #34:

score: 15
Accepted
time: 75ms
memory: 16512kb

input:

100000
18 17 18 13 20 6 1 5 6 6 14 2 11 17 2 8 7 1 7 19 11 6 6 6 16 3 16 5 8 3 6 4 10 9 12 14 5 15 4 3 4 11 1 9 13 17 3 5 5 17 14 4 1 1 4 4 7 11 15 10 18 13 4 9 7 10 5 4 5 16 6 2 6 20 1 11 9 6 15 16 7 15 11 4 17 14 18 13 7 2 1 18 17 10 8 11 15 10 3 15 6 6 11 7 2 1 10 15 11 12 20 10 9 19 7 15 8 17 10...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YE...

result:

ok 500000 lines

Test #35:

score: 15
Accepted
time: 69ms
memory: 16288kb

input:

100000
14 17 6 16 7 14 15 12 20 10 2 9 4 4 2 13 6 15 3 11 13 13 1 3 11 9 18 6 5 10 20 17 5 10 6 12 7 12 12 14 3 18 7 12 8 14 19 8 20 19 19 16 3 1 11 19 20 11 14 4 8 2 15 5 14 11 7 11 13 16 13 1 8 15 12 15 7 4 6 10 20 19 18 17 1 19 20 14 18 17 2 8 15 20 19 1 19 5 12 9 20 11 14 18 7 2 15 5 13 18 3 14 ...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YE...

result:

ok 500000 lines

Test #36:

score: 15
Accepted
time: 72ms
memory: 16340kb

input:

100000
10 12 9 14 15 11 15 14 15 6 10 8 17 17 7 8 6 12 9 13 5 7 12 19 13 17 18 5 13 9 9 8 12 2 10 20 10 7 14 9 3 9 12 18 3 5 7 6 14 6 10 19 15 4 1 12 20 17 6 16 5 18 10 5 14 10 15 12 15 10 3 2 15 11 15 19 20 16 1 11 4 17 8 14 12 11 7 2 6 15 1 8 9 9 4 4 16 13 3 6 2 12 14 1 8 9 18 3 5 16 15 4 7 9 16 1...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 500000 lines

Test #37:

score: 15
Accepted
time: 77ms
memory: 16256kb

input:

100000
3 10 10 17 1 10 1 19 4 9 9 16 11 1 3 7 2 3 17 16 11 1 5 15 18 16 18 8 3 7 14 10 15 17 8 19 9 12 19 2 8 15 15 8 18 19 14 12 4 7 17 10 10 11 3 3 12 6 19 10 19 19 6 4 16 12 18 14 17 11 1 6 1 3 1 18 13 13 5 19 5 1 1 15 18 15 7 3 4 9 16 4 13 1 6 3 16 18 7 17 12 16 13 11 18 1 9 6 3 15 14 6 4 15 5 1...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 500000 lines

Subtask #4:

score: 75
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #38:

score: 75
Accepted
time: 176ms
memory: 58864kb

input:

400000
4151 5723 719 5378 5791 3062 2487 565 5641 7750 7095 3999 7347 6142 3707 58 67 1800 2963 3940 4939 5338 1519 209 6871 7764 7593 5374 2405 1910 7935 3750 2898 7295 3452 5565 8541 5552 9010 793 7899 9983 3031 4433 6070 5735 2329 1086 4338 6284 8254 1742 6286 2252 620 5383 6019 7889 4642 40 6060...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 500000 lines

Test #39:

score: 75
Accepted
time: 169ms
memory: 71220kb

input:

500000
783 95 774 803 441 316 173 671 35 647 420 934 40 60 153 612 718 699 246 818 87 458 376 553 249 199 398 858 360 279 222 335 793 422 435 874 295 931 251 792 835 735 197 529 468 162 680 70 406 946 894 143 654 482 87 721 971 843 82 729 777 897 782 752 192 604 175 970 801 16 324 692 144 420 597 75...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 500000 lines

Test #40:

score: 75
Accepted
time: 161ms
memory: 45688kb

input:

300000
199 1360 318 1144 1472 1401 1230 1945 1284 1582 1825 1047 1893 393 1049 114 1009 307 1571 1681 1291 1435 239 74 1706 483 477 64 1867 808 973 650 1378 1964 1145 1100 814 257 255 1173 1450 1971 1013 1364 1183 67 753 295 679 60 1489 1553 1724 1412 1092 967 303 1489 1308 632 1429 1861 1211 1127 1...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 500000 lines

Test #41:

score: 75
Accepted
time: 217ms
memory: 65828kb

input:

500000
2 1 1 1 1 2 2 1 1 1 2 2 1 2 2 1 2 2 2 2 1 2 1 2 2 1 1 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 1 1 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 1 1 2 1 2 2 2 2 1 1 2 1 1 2 2 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 2 1 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 2 2 1 1 2 2 2 1 2 1 2 2 1 2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 2 1 1 2 2 1 1 1 2...

output:

NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
NO
YES
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES...

result:

ok 500000 lines

Test #42:

score: 75
Accepted
time: 91ms
memory: 18108kb

input:

100000
16564 32123 20848 45440 35708 41844 22706 36966 28906 33873 8678 2302 49335 1793 41943 44810 40149 5902 36084 4532 31496 3342 12515 42132 48580 4373 25196 1266 35202 6346 34273 24088 18428 3092 30429 3011 47671 1553 48314 4822 9809 48340 9597 22747 44912 16665 9676 25255 14874 24869 20735 284...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YE...

result:

ok 500000 lines

Test #43:

score: 75
Accepted
time: 90ms
memory: 17000kb

input:

100000
5952 19697 8891 18100 16774 5255 1250 15585 19480 613 16532 8760 401 13155 3589 10991 11453 17592 1128 15748 8473 16532 3774 19333 18902 1526 6793 8124 8957 12651 19390 15797 18380 5956 2297 10542 30 10450 11659 19066 7913 5185 4462 12721 1985 19630 17337 2232 18490 9382 8654 12680 3403 16445...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
...

result:

ok 500000 lines

Test #44:

score: 75
Accepted
time: 148ms
memory: 33024kb

input:

200000
35933 17745 8404 91578 62086 18854 43426 33600 91210 98904 71546 35503 77959 84355 78564 32167 24874 4517 13874 82514 71509 14970 23842 56091 18188 12614 16081 89436 12381 53649 29686 33333 64234 53068 546 25400 15091 40721 55410 47808 52036 23689 63502 84706 52537 15976 86082 66460 44778 466...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YE...

result:

ok 500000 lines

Test #45:

score: 75
Accepted
time: 152ms
memory: 33580kb

input:

200000
68347 111425 65514 106460 4384 49233 39321 9789 82382 34146 55387 73372 62218 23507 65122 70784 109301 82865 3745 28205 22263 109403 65087 50709 19848 115269 75704 72110 88795 28119 63953 108063 116519 100021 24502 39828 77971 40218 85745 91056 93693 35229 19913 3746 37159 82518 9205 14545 10...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
...

result:

ok 500000 lines

Test #46:

score: 75
Accepted
time: 152ms
memory: 33992kb

input:

200000
81024 135875 33009 129708 11930 36660 7408 15682 61593 25340 97364 9059 89738 38762 43466 32050 10217 80938 37586 34349 99797 112843 104199 11863 135602 133434 42669 118675 12974 130400 97362 45327 57819 34389 127686 101131 149099 33263 97495 31205 75130 40987 34469 129986 18357 2742 118197 6...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
...

result:

ok 500000 lines

Test #47:

score: 75
Accepted
time: 101ms
memory: 17836kb

input:

100000
40334 7369 42820 28678 42863 8601 32756 41123 13699 19989 30630 46080 2568 44964 37282 16884 44924 47556 7048 4257 40932 1275 39932 31334 24044 19564 12574 45204 27100 10037 19076 13837 17922 40788 6407 34168 19122 46458 37943 19297 11991 12520 2940 47982 41444 13350 44010 33437 46156 19795 3...

output:

NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
...

result:

ok 500000 lines

Test #48:

score: 75
Accepted
time: 88ms
memory: 17000kb

input:

100000
2960 1998 1311 4063 9415 2006 7998 7479 6345 1713 6679 4616 9470 3462 4647 8387 7598 1519 4047 5996 7203 4288 4820 3426 2137 5490 8039 9721 6785 1691 5039 8310 2309 5276 8610 9686 2246 8231 9379 8571 9809 1802 6661 4964 6576 6428 6669 7224 4316 2483 8469 2015 6576 480 973 4509 1145 5848 8700 ...

output:

NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
...

result:

ok 500000 lines

Test #49:

score: 75
Accepted
time: 149ms
memory: 31108kb

input:

200000
30006 9125 1928 33918 2808 39681 6789 15869 26357 17676 19140 9531 14425 22873 25652 31740 22010 24410 12466 23234 877 10760 39085 10500 38837 8617 37673 10638 3671 10241 7135 19636 22921 9751 31233 2932 29448 3170 28698 26983 30473 2513 19668 31396 33927 29748 33492 20082 21243 34122 11391 3...

output:

NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
N...

result:

ok 500000 lines

Test #50:

score: 75
Accepted
time: 149ms
memory: 32160kb

input:

200000
38512 67171 18963 79992 78740 37423 21835 40300 50897 58154 34137 65031 23838 67 76768 8971 55169 53918 74357 18157 31839 77816 5443 65357 7153 67378 40910 25361 28887 34940 38868 1309 3911 64415 67408 75697 57694 16614 26776 70750 8599 28842 72614 50598 71385 32121 21363 14255 40490 6499 747...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO...

result:

ok 500000 lines

Test #51:

score: 75
Accepted
time: 166ms
memory: 34812kb

input:

200000
11970 59859 69535 175911 20259 4549 126112 43162 153068 84370 188698 81359 68099 81346 179910 155979 11930 20823 169321 73649 30206 87546 122751 168316 116685 184071 148916 143896 155524 69298 135051 137886 117878 54292 7714 126826 122777 63894 57292 189915 65787 110840 138462 120039 169682 1...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO...

result:

ok 500000 lines

Test #52:

score: 75
Accepted
time: 96ms
memory: 39752kb

input:

200000
180000 179998 179996 179994 179992 179990 179988 179986 179984 179982 179980 179978 179976 179974 179972 179970 179968 179966 179964 179962 179960 179958 179956 179954 179952 179950 179948 179946 179944 179942 179940 179938 179936 179934 179932 179930 179928 179926 179924 179922 179920 179918...

output:

NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO...

result:

ok 500000 lines

Test #53:

score: 75
Accepted
time: 147ms
memory: 57620kb

input:

300000
260000 259998 259996 259994 259992 259990 259988 259986 259984 259982 259980 259978 259976 259974 259972 259970 259968 259966 259964 259962 259960 259958 259956 259954 259952 259950 259948 259946 259944 259942 259940 259938 259936 259934 259932 259930 259928 259926 259924 259922 259920 259918...

output:

NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Test #54:

score: 75
Accepted
time: 154ms
memory: 77452kb

input:

400000
380000 379998 379996 379994 379992 379990 379988 379986 379984 379982 379980 379978 379976 379974 379972 379970 379968 379966 379964 379962 379960 379958 379956 379954 379952 379950 379948 379946 379944 379942 379940 379938 379936 379934 379932 379930 379928 379926 379924 379922 379920 379918...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Test #55:

score: 75
Accepted
time: 147ms
memory: 58448kb

input:

300000
280000 279998 279996 279994 279992 279990 279988 279986 279984 279982 279980 279978 279976 279974 279972 279970 279968 279966 279964 279962 279960 279958 279956 279954 279952 279950 279948 279946 279944 279942 279940 279938 279936 279934 279932 279930 279928 279926 279924 279922 279920 279918...

output:

NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 500000 lines

Extra Test:

score: 0
Extra Test Passed