QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203569#2481. PickpocketsRd_rainydaysWA 689ms4308kbC++201.8kb2023-10-06 18:15:292023-10-06 18:15:29

Judging History

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

  • [2023-10-06 18:15:29]
  • 评测
  • 测评结果:WA
  • 用时:689ms
  • 内存:4308kb
  • [2023-10-06 18:15:29]
  • 提交

answer

#include <bits/stdc++.h>
#define N 200005
#define M 20
using namespace std;
int n, m;
int a[N];
struct zero
{
  int len, val;
  friend bool operator<(zero a, zero b) { return a.len == b.len ? a.val < b.val : a.len > b.len; }
} lib[M];
priority_queue<int, vector<int>, greater<int>> q;
int siz = 0, B;
int upper = 0;
int aux[M];

int ans = 0;
int st_time;
void dfs(int i, int s, int w) {
  if ((clock() - st_time) > 0.960 * CLOCKS_PER_SEC) {
    printf("%d\n", ans);
    exit(0);
  }

  if (i == siz + 1) {
    ans = std::max(ans, w);
    return;
  }

  int tot = 0, vaild[M];
  for (int j = 0; j < m; j++) if (s >> j & 1)
    vaild[tot ++] = j;
  
  for (int t = (1 << tot) - 1; t >= 0; t--) {
    int len_s = 0;
    int val_s = 0;
    int sn = s;
    for (int j = 0; j < tot && len_s <= aux[i]; j++) if (t >> j & 1) {
      len_s += lib[vaild[j]].len;
      val_s += lib[vaild[j]].val;
      sn ^= (1 << vaild[j]);
    }
    if (len_s != aux[i]) continue;

    dfs(i + 1, sn, w + val_s);
  }
}

int main() {
  st_time = clock();

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    upper = max(upper, a[i]);
  }
  a[n + 1] = 0;
  for (int u = 1; u <= upper; u++) {
    int las = 0;
    for (int i = 1; i <= n + 1; i++) if (a[i] < u) {
      int nwlen = i - 1 - las;
      if (nwlen != 0) {
        if (siz == m) {
          puts("0");
          exit(0);
        } else {
          siz++;
          q.push(nwlen);
        }
      }
      las = i;
    }
  }
  for (int i = 1; i <= siz; i++) {
    aux[siz - i + 1] = q.top();
    q.pop();
  }

  for (int i = 0; i < m; i++)
    scanf("%d%d", &lib[i].len, &lib[i].val);
  
  std::sort(lib, lib + m);
  
  dfs(1, (1 << m) - 1, 0);
  printf("%d\n", ans);
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4060kb

input:

2 2
1 2
1 5
2 5

output:

10

result:

ok single line: '10'

Test #2:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

2 2
1 2
2 5
1 5

output:

10

result:

ok single line: '10'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

3 4
2 1 2
3 2
1 1
1 2
1 3

output:

7

result:

ok single line: '7'

Test #4:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

1 5
2
1 2
1 5
1 3
1 5
1 3

output:

10

result:

ok single line: '10'

Test #5:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

1 5
1
1 2
1 1
1 2
1 5
1 2

output:

5

result:

ok single line: '5'

Test #6:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

1 7
0
1 5
1 5
1 5
1 2
1 5
1 3
1 6

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

3 6
2 1 1
2 1
3 5
2 3
3 3
2 4
3 3

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

2 5
1 1
1 5
2 4
1 4
2 2
1 1

output:

9

result:

ok single line: '9'

Test #9:

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

input:

1 2
1
1 5
1 4

output:

5

result:

ok single line: '5'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

2 4
0 1
1 6
2 2
2 5
2 5

output:

6

result:

ok single line: '6'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

3 5
0 0 0
3 2
3 1
3 1
1 3
1 5

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

3 6
0 1 0
3 3
1 3
1 2
1 2
1 3
3 2

output:

3

result:

ok single line: '3'

Test #13:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

2 7
2 0
2 2
1 6
2 4
1 6
1 6
1 2
2 6

output:

12

result:

ok single line: '12'

Test #14:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

2 6
0 3
2 3
2 16
1 12
2 10
1 16
1 8

output:

36

result:

ok single line: '36'

Test #15:

score: 0
Accepted
time: 2ms
memory: 4068kb

input:

3 13
4 0 3
1 19
3 12
1 13
2 19
1 18
3 4
3 10
1 13
1 19
2 10
3 15
1 20
3 5

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

4 2
3 2 4 0
4 10
3 14

output:

0

result:

ok single line: '0'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

4 6
3 1 3 1
4 9
4 18
1 15
3 15
2 6
1 19

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

3 14
3 0 1
3 16
3 7
3 9
3 11
3 15
3 15
2 16
1 1
2 18
3 16
3 13
3 11
1 4
3 4

output:

0

result:

ok single line: '0'

Test #19:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

2 9
3 1
1 18
1 15
1 15
1 4
2 17
1 4
2 1
1 15
2 16

output:

63

result:

ok single line: '63'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

1 9
2
1 5
1 11
1 20
1 10
1 10
1 11
1 9
1 8
1 19

output:

39

result:

ok single line: '39'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

4 7
1 0 0 2
4 15
4 18
2 8
2 2
2 6
3 11
3 11

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

2 2
2 3
2 6
1 1

output:

0

result:

ok single line: '0'

Test #23:

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

input:

1 15
4
1 2
1 12
1 7
1 5
1 13
1 10
1 7
1 5
1 1
1 18
1 9
1 5
1 17
1 9
1 6

output:

60

result:

ok single line: '60'

Test #24:

score: 0
Accepted
time: 12ms
memory: 3856kb

input:

4 14
4 4 0 4
4 20
2 13
2 4
1 20
3 4
4 6
3 9
2 8
1 19
3 14
2 18
2 18
1 15
1 19

output:

130

result:

ok single line: '130'

Test #25:

score: 0
Accepted
time: 0ms
memory: 4052kb

input:

2 5
0 0
1 16
2 20
1 16
2 3
2 11

output:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 0ms
memory: 4004kb

input:

2 8
4 0
2 7
1 20
2 10
2 17
1 17
1 17
1 15
2 20

output:

69

result:

ok single line: '69'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3920kb

input:

4 12
4 1 2 1
1 17
3 18
4 19
1 7
4 19
3 19
1 6
1 18
2 3
3 17
1 9
3 4

output:

76

result:

ok single line: '76'

Test #28:

score: 0
Accepted
time: 1ms
memory: 4044kb

input:

1 14
2
1 13
1 15
1 17
1 9
1 1
1 15
1 9
1 18
1 13
1 4
1 20
1 11
1 18
1 18

output:

38

result:

ok single line: '38'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

4 8
4 0 4 3
4 16
4 13
1 6
1 12
4 10
3 19
4 16
3 6

output:

0

result:

ok single line: '0'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3996kb

input:

2 6
0 3
2 8
2 2
2 13
2 15
1 19
1 9

output:

0

result:

ok single line: '0'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

5 13
3 1 4 1 0
2 5
3 1
5 12
5 9
4 13
5 1
2 6
3 6
2 8
2 15
4 5
1 8
3 12

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

4 9
3 2 4 3
4 14
4 10
4 11
1 14
4 8
3 17
4 12
3 9
3 9

output:

0

result:

ok single line: '0'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

2 15
1 0
2 4
2 17
2 4
2 4
1 7
2 10
1 9
1 8
2 20
1 1
2 9
1 6
1 17
2 15
2 4

output:

17

result:

ok single line: '17'

Test #34:

score: 0
Accepted
time: 6ms
memory: 4108kb

input:

100000 16
14443 55420 45271 59540 17506 45279 49513 7118 52062 23449 62240 81654 47001 82704 81577 90132 54258 108 41873 82899 73494 8454 43677 34844 92634 48581 7109 1530 89551 44235 82584 49481 69802 20448 78330 70257 67421 71672 45574 96521 64524 43129 33599 37095 57123 69486 6307 74558 9699 1494...

output:

0

result:

ok single line: '0'

Test #35:

score: 0
Accepted
time: 6ms
memory: 4304kb

input:

100000 16
34132 25992 9700 90156 37155 60117 91934 19647 21415 98451 85854 51164 39403 80732 68947 34179 10383 43258 89748 79195 49897 93439 99072 84649 3567 21423 59855 21175 31153 43214 81799 35873 50482 75563 11972 64395 85329 14962 60476 19670 77437 86503 26544 26505 97938 98378 18263 91959 1093...

output:

0

result:

ok single line: '0'

Test #36:

score: 0
Accepted
time: 6ms
memory: 4120kb

input:

100000 16
49337 49202 98923 88065 90751 42204 62277 46326 94035 61743 11491 18245 67892 65458 14981 83057 23342 60570 53140 91901 61983 77500 5364 30637 59391 20822 7992 68913 25963 56681 75276 54999 95145 6833 64626 37669 49186 62351 47235 26430 2217 29040 8409 79387 68362 31357 19385 15922 24388 2...

output:

0

result:

ok single line: '0'

Test #37:

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

input:

100000 16
100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 100000 0 10...

output:

0

result:

ok single line: '0'

Test #38:

score: 0
Accepted
time: 331ms
memory: 4000kb

input:

1 16
16
1 813962
1 261224
1 292357
1 26638
1 342500
1 220901
1 329926
1 283296
1 444155
1 512333
1 670909
1 546612
1 398289
1 243805
1 299229
1 241034

output:

5927170

result:

ok single line: '5927170'

Test #39:

score: 0
Accepted
time: 382ms
memory: 3908kb

input:

1 16
16
1 559357
1 192158
1 650434
1 120360
1 505929
1 98087
1 596733
1 565702
1 460486
1 797314
1 77027
1 569947
1 799522
1 791499
1 794206
1 658821

output:

8237582

result:

ok single line: '8237582'

Test #40:

score: 0
Accepted
time: 1ms
memory: 4044kb

input:

12 16
1 1 1 1 1 1 1 1 1 1 1 1
12 3
10 2
3 9
9 2
3 9
3 10
7 1
8 2
2 4
9 5
12 11
7 3
12 4
5 6
6 7
12 6

output:

26

result:

ok single line: '26'

Test #41:

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

input:

12 16
1 1 1 1 1 1 1 1 1 1 1 1
10 9
7 8
4 3
7 7
3 6
9 2
1 7
1 10
12 10
2 4
3 10
2 3
4 9
8 6
8 11
9 7

output:

42

result:

ok single line: '42'

Test #42:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

10 16
1 1 1 1 1 1 1 1 1 1
3 8
3 9
8 11
3 7
2 10
6 3
10 3
9 4
8 11
8 6
10 7
8 2
5 10
1 3
7 2
10 10

output:

29

result:

ok single line: '29'

Test #43:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

18 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
9 9
1 4
4 3
6 6
16 3
13 6
2 3
7 5
8 4
12 4
12 6
11 3
11 3
16 1
5 4
10 2

output:

22

result:

ok single line: '22'

Test #44:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

20 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11 1
3 1
4 3
14 5
7 6
10 4
11 1
17 2
8 8
3 9
8 9
5 6
10 11
17 8
8 6
3 7

output:

30

result:

ok single line: '30'

Test #45:

score: 0
Accepted
time: 1ms
memory: 4064kb

input:

7 16
1 1 1 1 1 1 1
4 9
6 11
4 6
3 11
5 1
5 3
7 9
6 8
2 10
5 5
7 1
5 4
2 10
5 9
5 7
5 11

output:

31

result:

ok single line: '31'

Test #46:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

10 16
1 1 1 1 1 1 1 1 1 1
6 5
1 11
3 1
3 10
10 9
10 11
5 9
8 7
8 2
4 1
4 11
10 9
9 5
8 11
6 1
8 1

output:

31

result:

ok single line: '31'

Test #47:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

20 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 2
9 7
20 8
1 3
10 7
18 9
10 9
16 7
20 9
12 11
3 8
4 6
3 2
2 9
13 5
17 2

output:

35

result:

ok single line: '35'

Test #48:

score: 0
Accepted
time: 1ms
memory: 4052kb

input:

2 16
1 1
1 11
2 7
1 8
1 8
2 4
1 3
2 8
2 7
1 4
1 2
2 11
1 2
2 11
1 11
1 5
1 11

output:

22

result:

ok single line: '22'

Test #49:

score: 0
Accepted
time: 1ms
memory: 4068kb

input:

4 16
1 1 1 1
1 6
3 4
4 8
2 3
2 11
4 3
4 9
1 6
3 5
3 10
2 1
1 4
3 4
1 1
3 2
3 5

output:

23

result:

ok single line: '23'

Test #50:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

6 16
1 1 1 1 1 1
2 10
5 6
2 7
5 10
3 1
5 7
1 2
5 4
3 9
1 9
1 1
5 1
4 7
3 5
5 9
1 8

output:

34

result:

ok single line: '34'

Test #51:

score: 0
Accepted
time: 1ms
memory: 3908kb

input:

20 16
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
11 10
17 11
3 11
2 4
6 4
13 9
11 3
4 11
16 8
4 4
20 1
8 9
2 6
12 11
19 6
19 5

output:

59

result:

ok single line: '59'

Test #52:

score: 0
Accepted
time: 2ms
memory: 4000kb

input:

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

output:

50

result:

ok single line: '50'

Test #53:

score: 0
Accepted
time: 21ms
memory: 3920kb

input:

10 16
4 4 4 4 4 4 4 4 4 4
10 11
10 2
1 5
1 5
9 11
9 4
9 7
5 9
1 8
3 11
6 6
5 5
2 3
6 1
8 2
7 11

output:

74

result:

ok single line: '74'

Test #54:

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

input:

15 16
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
9 2
2 6
11 8
1 4
13 11
1 3
14 4
13 3
7 8
6 6
6 6
13 11
5 1
6 5
4 4
8 9

output:

72

result:

ok single line: '72'

Test #55:

score: 0
Accepted
time: 6ms
memory: 4044kb

input:

20 16
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
2 9
8 11
10 6
13 4
7 3
16 5
19 8
14 2
3 6
16 8
2 6
20 9
16 5
10 5
12 9
8 4

output:

0

result:

ok single line: '0'

Test #56:

score: 0
Accepted
time: 594ms
memory: 3908kb

input:

4 16
7 7 7 7
3 6
1 9
4 11
4 11
4 2
3 2
4 1
1 10
3 6
4 11
2 6
2 3
4 9
4 6
2 11
1 9

output:

96

result:

ok single line: '96'

Test #57:

score: 0
Accepted
time: 22ms
memory: 3988kb

input:

13 16
8 8 8 8 8 8 8 8 8 8 8 8 8
3 11
7 8
6 3
7 5
7 1
12 6
1 7
12 3
5 3
7 5
11 9
1 5
13 4
10 5
7 7
11 4

output:

0

result:

ok single line: '0'

Test #58:

score: 0
Accepted
time: 23ms
memory: 3920kb

input:

15 16
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
1 11
15 7
11 3
7 10
3 2
2 6
7 1
7 11
13 7
15 3
10 4
11 8
8 4
9 2
9 4
15 4

output:

0

result:

ok single line: '0'

Test #59:

score: 0
Accepted
time: 436ms
memory: 3920kb

input:

2 16
10 10
2 10
2 3
2 7
1 5
1 9
1 8
2 7
1 7
2 9
2 10
1 4
2 7
1 8
1 3
1 1
1 11

output:

105

result:

ok single line: '105'

Test #60:

score: 0
Accepted
time: 1ms
memory: 4048kb

input:

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

output:

27

result:

ok single line: '27'

Test #61:

score: 0
Accepted
time: 3ms
memory: 4000kb

input:

8 16
2 2 2 2 2 2 2 2
3 5
8 3
5 8
1 7
1 5
5 5
7 7
4 5
8 6
8 8
5 11
2 1
1 1
3 11
6 2
6 6

output:

43

result:

ok single line: '43'

Test #62:

score: 0
Accepted
time: 6ms
memory: 3908kb

input:

16 16
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
4 2
11 2
9 3
11 7
6 5
5 5
6 6
6 1
1 11
7 7
15 2
9 8
6 9
2 1
12 4
16 1

output:

53

result:

ok single line: '53'

Test #63:

score: 0
Accepted
time: 0ms
memory: 4068kb

input:

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

output:

60

result:

ok single line: '60'

Test #64:

score: 0
Accepted
time: 252ms
memory: 3976kb

input:

6 16
5 5 5 5 5 5
3 2
3 11
5 3
2 1
2 7
6 10
6 2
6 1
1 9
2 8
4 11
2 5
5 7
6 5
1 7
4 5

output:

80

result:

ok single line: '80'

Test #65:

score: 0
Accepted
time: 148ms
memory: 3980kb

input:

8 16
6 6 6 6 6 6 6 6
6 9
5 3
4 4
3 11
7 6
3 4
6 1
1 4
7 5
6 9
8 5
6 8
2 5
2 1
6 7
2 6

output:

69

result:

ok single line: '69'

Test #66:

score: 0
Accepted
time: 12ms
memory: 3980kb

input:

16 16
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
1 8
7 4
15 2
14 9
15 3
16 5
10 6
15 4
1 6
15 10
4 4
14 1
15 8
2 2
13 7
14 4

output:

0

result:

ok single line: '0'

Test #67:

score: 0
Accepted
time: 639ms
memory: 3920kb

input:

8 16
8 8 8 8 8 8 8 8
8 6
2 6
1 9
5 4
8 3
3 1
5 2
8 9
7 9
4 1
8 10
7 5
8 4
5 3
2 4
3 1

output:

67

result:

ok single line: '67'

Test #68:

score: 0
Accepted
time: 592ms
memory: 4064kb

input:

8 16
9 9 9 9 9 9 9 9
3 5
3 2
6 6
1 3
3 6
8 5
2 11
5 6
7 5
8 6
4 9
6 4
6 6
5 4
8 4
2 4

output:

0

result:

ok single line: '0'

Test #69:

score: 0
Accepted
time: 536ms
memory: 4064kb

input:

6 16
10 10 10 10 10 10
3 11
6 11
6 2
6 4
1 11
2 1
3 4
2 11
3 4
1 7
4 9
4 8
2 9
2 3
4 7
4 3

output:

0

result:

ok single line: '0'

Test #70:

score: 0
Accepted
time: 416ms
memory: 4064kb

input:

5 16
5 7 6 4 0
1 2
1 22
1 6
1 29
1 30
2 25
1 21
2 17
1 24
2 20
1 12
2 9
2 24
1 1
1 19
2 13

output:

274

result:

ok single line: '274'

Test #71:

score: 0
Accepted
time: 279ms
memory: 3912kb

input:

5 16
3 4 2 2 1
2 28
1 28
3 30
1 26
1 24
1 29
3 10
3 4
4 10
2 12
2 29
1 12
1 30
2 25
1 5
2 19

output:

231

result:

ok single line: '231'

Test #72:

score: 0
Accepted
time: 679ms
memory: 4048kb

input:

5 16
5 4 3 7 3
2 24
3 19
1 13
5 27
1 10
2 24
1 29
1 22
2 22
1 25
2 22
2 15
4 21
4 5
1 15
4 9

output:

252

result:

ok single line: '252'

Test #73:

score: 0
Accepted
time: 211ms
memory: 4044kb

input:

5 16
4 3 3 2 1
2 12
1 30
2 9
2 22
1 11
2 28
5 6
2 7
3 6
4 18
1 22
1 16
1 1
2 26
3 22
2 30

output:

186

result:

ok single line: '186'

Test #74:

score: 0
Accepted
time: 659ms
memory: 3860kb

input:

5 16
3 4 4 5 2
1 1
5 7
4 1
1 10
2 18
1 20
4 8
1 3
1 25
2 13
1 16
2 18
1 9
4 10
4 12
1 19

output:

164

result:

ok single line: '164'

Test #75:

score: 0
Accepted
time: 689ms
memory: 3908kb

input:

5 16
1 3 4 2 3
1 22
2 16
3 6
1 23
1 1
2 26
1 23
1 30
1 6
1 26
1 10
2 30
2 18
3 22
3 1
1 29

output:

237

result:

ok single line: '237'

Test #76:

score: 0
Accepted
time: 688ms
memory: 4064kb

input:

5 16
2 5 5 2 4
1 28
3 11
2 14
1 12
1 18
1 12
4 9
2 21
1 11
2 16
4 23
3 28
1 23
1 26
2 27
5 19

output:

236

result:

ok single line: '236'

Test #77:

score: 0
Accepted
time: 612ms
memory: 3864kb

input:

5 16
0 4 5 3 1
1 25
3 8
1 27
1 5
2 2
1 2
2 27
1 29
1 30
3 2
3 14
1 17
2 17
1 26
1 10
1 1

output:

215

result:

ok single line: '215'

Test #78:

score: 0
Accepted
time: 569ms
memory: 3856kb

input:

5 16
5 4 6 6 0
2 21
1 5
1 23
2 27
2 15
2 13
2 3
2 18
2 28
2 25
1 22
2 19
1 30
4 13
5 10
3 15

output:

248

result:

ok single line: '248'

Test #79:

score: 0
Accepted
time: 624ms
memory: 3916kb

input:

5 16
2 2 4 4 2
2 19
2 21
1 5
2 5
2 30
1 10
1 16
1 1
2 13
1 1
2 13
2 28
4 27
1 16
1 22
3 13

output:

175

result:

ok single line: '175'

Test #80:

score: -100
Wrong Answer
time: 496ms
memory: 3860kb

input:

10 16
4 5 0 1 3 3 6 5 5 3
2 13
3 22
2 8
2 22
2 10
1 19
2 7
3 17
1 5
2 14
6 23
7 27
1 5
1 1
1 24
2 18

output:

0

result:

wrong answer 1st lines differ - expected: '227', found: '0'