QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22417#2356. Partition of QueriesSuzt_ilymtics#AC ✓71ms39932kbC++142.5kb2022-03-09 17:36:162022-04-30 01:02:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:02:48]
  • 评测
  • 测评结果:AC
  • 用时:71ms
  • 内存:39932kb
  • [2022-03-09 17:36:16]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define int long long
#define orz cout << "tyy YYDS!\n"
using namespace std;
const int MAXN = 1e6 + 1000;
const int INF = 1e9 + 7;
const int mod = 998244353;

int n, y;
char s[MAXN];
int a[MAXN], b[MAXN], c[MAXN];
int f[MAXN];
int q[MAXN], head = 1, tail = 0;

int read() {
    int s = 0, f = 0;
    char ch = getchar();
    while(!isdigit(ch)) f |= (ch == '-'), ch = getchar();
    while(isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return f ? -s : s;
}

int F(int x) { return f[x] - a[x] + b[x] * c[x]; }

double K(int x_1, int x_2) {
    if(b[x_1] == b[x_2]) return INF;
    return (1.0 * (F(x_1) - F(x_2))) / (1.0 * (b[x_1] - b[x_2]));
}

void Delete(int pos){ while(head < tail && 1.0 * c[pos] >= K(q[head], q[head + 1])) head ++; }

void Insert(int pos) {
    while(head < tail && K(q[tail - 1], q[tail]) > K(q[tail], pos)) tail --;
    q[++ tail] = pos;
}

signed main() {
    n = read(), y = read();
    cin >> s + 1;
//    s[++n] = '+', s[n + 1] = '\0';
    int x = 0;
    for(int i = 1; i <= n; ++i) {
        if(s[i] == '+') x ++;
        if(s[i] == '?') a[i] = x;
    }
    for(int i = 1; i <= n; ++i) a[i] += a[i - 1];
    for(int i = 1; i <= n; ++i) if(s[i] == '?') c[i] ++;
    for(int i = 1; i <= n; ++i) c[i] += c[i - 1];
    for(int i = 1; i <= n; ++i) if(s[i] == '+') b[i] ++;
    for(int i = 1; i <= n; ++i) b[i] += b[i - 1]; 
//    for(int i = 1; i <= n; ++i) cout << a[i] << " "; puts("");
//    for(int i = 1; i <= n; ++i) cout << b[i] << " "; puts("");
//    for(int i = 1; i <= n; ++i) cout << c[i] << " "; puts("");
    Insert(0);
    for(int i = 1; i <= n; ++i) {
//        if(s[i] == '+') continue;
        Delete(i);
        int j = q[head];
        f[i] = f[j] + a[i] - a[j] - (c[i] - c[j]) * b[j] + y;
//        cout << i << " " << j << " " << f[i] << "\n";
        Insert(i);
    }
    printf("%lld\n", f[n] - y);
    return 0;
}

/*

6 5
++??+?

6 8
++??+?

5 1
+++++

*/
//    for(int i = 1; i <= n; ++i) {
//        b[i] = b[i - 1] + (s[i] == '+');
//        if(s[i] == '?') a[i] = b[i];
//    }
//    for(int i = 1; i <= n; ++i) a[i] += a[i - 1];
//    for(int i = 1; i <= n; ++i) c[i] = c[i - 1] + (s[i] == '?');

//    for(int i = 1; i <= n; ++i) b[i] = s[i] == '+', c[i] = s[i] == '?';
//    for(int i = 1; i <= n; ++i) b[i] += b[i - 1], c[i] += c[i - 1];
//    for(int i = 1; i <= n; ++i) a[i] = a[i - 1] + b[i] * (s[i] == '?');

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 5
++??+?

output:

6

result:

ok single line: '6'

Test #2:

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

input:

6 8
++??+?

output:

7

result:

ok single line: '7'

Test #3:

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

input:

5 1
+++++

output:

0

result:

ok single line: '0'

Test #4:

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

input:

10 0
++?+??++??

output:

0

result:

ok single line: '0'

Test #5:

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

input:

12 100
+?+++??+??++

output:

19

result:

ok single line: '19'

Test #6:

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

input:

1 1
?

output:

0

result:

ok single line: '0'

Test #7:

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

input:

9 7
++++++++?

output:

7

result:

ok single line: '7'

Test #8:

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

input:

9 8
++++++++?

output:

8

result:

ok single line: '8'

Test #9:

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

input:

10 15
++++++++??

output:

15

result:

ok single line: '15'

Test #10:

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

input:

5 3
+?+?+

output:

3

result:

ok single line: '3'

Test #11:

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

input:

10 5
+?+?+??+??

output:

10

result:

ok single line: '10'

Test #12:

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

input:

10 7
+?+?+??+??

output:

12

result:

ok single line: '12'

Test #13:

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

input:

15 4
+?+?+??+??+??+?

output:

14

result:

ok single line: '14'

Test #14:

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

input:

15 6
+?+?+??+??+??+?

output:

18

result:

ok single line: '18'

Test #15:

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

input:

19 8
+?+?+??+??+??+?++??

output:

28

result:

ok single line: '28'

Test #16:

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

input:

20 9
+?+?+??+??+??+?++???

output:

30

result:

ok single line: '30'

Test #17:

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

input:

500 100
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????++++...

output:

2710

result:

ok single line: '2710'

Test #18:

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

input:

10000 100
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????++...

output:

56616

result:

ok single line: '56616'

Test #19:

score: 0
Accepted
time: 25ms
memory: 20016kb

input:

500000 3000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????...

output:

17820759

result:

ok single line: '17820759'

Test #20:

score: 0
Accepted
time: 61ms
memory: 36164kb

input:

1000000 3000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++????...

output:

35626062

result:

ok single line: '35626062'

Test #21:

score: 0
Accepted
time: 49ms
memory: 36228kb

input:

1000000 1000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++????...

output:

19934461

result:

ok single line: '19934461'

Test #22:

score: 0
Accepted
time: 53ms
memory: 36084kb

input:

1000000 10000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++???...

output:

66661466

result:

ok single line: '66661466'

Test #23:

score: 0
Accepted
time: 59ms
memory: 36000kb

input:

1000000 30000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++???...

output:

117384143

result:

ok single line: '117384143'

Test #24:

score: 0
Accepted
time: 49ms
memory: 36016kb

input:

1000000 500000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++??...

output:

490361116

result:

ok single line: '490361116'

Test #25:

score: 0
Accepted
time: 71ms
memory: 35940kb

input:

1000000 1000000
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?...

output:

695515718

result:

ok single line: '695515718'

Test #26:

score: 0
Accepted
time: 31ms
memory: 39840kb

input:

1000000 924
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

924

result:

ok single line: '924'

Test #27:

score: 0
Accepted
time: 44ms
memory: 39844kb

input:

1000000 69971
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

69971

result:

ok single line: '69971'

Test #28:

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

input:

1000000 275229
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

275229

result:

ok single line: '275229'

Test #29:

score: 0
Accepted
time: 39ms
memory: 39724kb

input:

1000000 275886
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

275886

result:

ok single line: '275886'

Test #30:

score: 0
Accepted
time: 46ms
memory: 36052kb

input:

1000000 55
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

2750

result:

ok single line: '2750'

Test #31:

score: 0
Accepted
time: 43ms
memory: 35908kb

input:

1000000 55
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

27500

result:

ok single line: '27500'

Test #32:

score: 0
Accepted
time: 31ms
memory: 39880kb

input:

1000000 0
++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++??????????++++++++++...

output:

0

result:

ok single line: '0'

Test #33:

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

input:

1000000 4
+++++++++++++++++++++++++++++++++?????????????????????????????????+++++++++++++++++++++++++++++++++?????????????????????????????????+++++++++++++++++++++++++++++++++?????????????????????????????????+++++++++++++++++++++++++++++++++?????????????????????????????????++++++++++++++++++++++++++...

output:

60608

result:

ok single line: '60608'

Test #34:

score: 0
Accepted
time: 34ms
memory: 39868kb

input:

1000000 1
+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?...

output:

500000

result:

ok single line: '500000'

Test #35:

score: 0
Accepted
time: 37ms
memory: 39832kb

input:

1000000 1000000
+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?+?...

output:

705858800

result:

ok single line: '705858800'

Test #36:

score: 0
Accepted
time: 42ms
memory: 36708kb

input:

1000000 822
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

7398

result:

ok single line: '7398'

Test #37:

score: 0
Accepted
time: 13ms
memory: 35980kb

input:

1000000 924
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

179256

result:

ok single line: '179256'

Test #38:

score: 0
Accepted
time: 34ms
memory: 39932kb

input:

1000000 0
++++++++++??????????+++++++++++++++++++++++++++++++++++???????????????????????????????????++++++++++++++++++++????????????????????+++++++++++++++++++++++++++++++++?????????????????????????????????++++++++++++++++++++++++++++++++++++????????????????????????????????????++++????++++++++++++++...

output:

0

result:

ok single line: '0'

Test #39:

score: 0
Accepted
time: 45ms
memory: 35904kb

input:

1000000 69971
?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++????...

output:

180870046

result:

ok single line: '180870046'

Test #40:

score: 0
Accepted
time: 62ms
memory: 36036kb

input:

1000000 69971
?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++????...

output:

180835657

result:

ok single line: '180835657'

Test #41:

score: 0
Accepted
time: 56ms
memory: 36204kb

input:

1000000 822
?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????+...

output:

17939203

result:

ok single line: '17939203'

Test #42:

score: 0
Accepted
time: 40ms
memory: 36200kb

input:

1000000 924
?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????+...

output:

19239363

result:

ok single line: '19239363'

Test #43:

score: 0
Accepted
time: 54ms
memory: 36120kb

input:

1000000 924
?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+...

output:

17839350

result:

ok single line: '17839350'

Test #44:

score: 0
Accepted
time: 37ms
memory: 36520kb

input:

1000000 822
?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++?+?+??+??+??+?++?????++??+?+????????????...

output:

18116120

result:

ok single line: '18116120'

Test #45:

score: 0
Accepted
time: 45ms
memory: 35972kb

input:

1000000 972519
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++??...

output:

685792922

result:

ok single line: '685792922'

Test #46:

score: 0
Accepted
time: 32ms
memory: 19868kb

input:

500000 570465
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++???...

output:

261665426

result:

ok single line: '261665426'

Test #47:

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

input:

100000 74846
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++????...

output:

18660523

result:

ok single line: '18660523'

Test #48:

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

input:

2879 999609
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????...

output:

999126

result:

ok single line: '999126'

Test #49:

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

input:

2879 999609
+?+?+??+??+??+?++?????++??+?+????????????+++?+?+???++?+?+++++++????++??+??+++??++++?++??+??+??+?????++++???+??++?+?++?++???++++???????+??????????++?+??+?+++???+?+???++?++?++++???++?++?????+??????+?++???++??+?++?+??+??++??++??++?+?+?+++??+??++????+?++?++?++??+?+++?+?+???+?+++?++?++++?????...

output:

999126

result:

ok single line: '999126'

Test #50:

score: 0
Accepted
time: 38ms
memory: 36600kb

input:

1000000 822
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

8220

result:

ok single line: '8220'

Test #51:

score: 0
Accepted
time: 30ms
memory: 36004kb

input:

1000000 924
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1848000

result:

ok single line: '1848000'

Test #52:

score: 0
Accepted
time: 59ms
memory: 36740kb

input:

1000000 55
+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+?????????+????????...

output:

2724973

result:

ok single line: '2724973'

Test #53:

score: 0
Accepted
time: 16ms
memory: 35976kb

input:

1000000 822
+++++???????????????????????????????????????????????????????????????????????????????????????????????+++++???????????????????????????????????????????????????????????????????????????????????????????????+++++???????????????????????????????????????????????????????????????????????????????????...

output:

6485000

result:

ok single line: '6485000'

Test #54:

score: 0
Accepted
time: 38ms
memory: 36052kb

input:

1000000 55
+++++++++++++++++++++++++++++++++++++++++++++?????+++++++++++++++++++++++++++++++++++++++++++++?????+++++++++++++++++++++++++++++++++++++++++++++?????+++++++++++++++++++++++++++++++++++++++++++++?????+++++++++++++++++++++++++++++++++++++++++++++?????+++++++++++++++++++++++++++++++++++++++...

output:

1100000

result:

ok single line: '1100000'

Test #55:

score: 0
Accepted
time: 32ms
memory: 35968kb

input:

1000000 3681
++++++++++?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

368100

result:

ok single line: '368100'

Test #56:

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

input:

1000000 73257
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

output:

48789162

result:

ok single line: '48789162'

Test #57:

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

input:

32 8
+??+?++??++?+??+?++?+??++??+?++?

output:

45

result:

ok single line: '45'

Test #58:

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

input:

1024 20
+??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??++??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??++??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??++??+...

output:

2726

result:

ok single line: '2726'

Test #59:

score: 0
Accepted
time: 29ms
memory: 21608kb

input:

524288 1000
+??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??++??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??++??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??+...

output:

11461382

result:

ok single line: '11461382'

Test #60:

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

input:

524288 10000
+??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??++??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??++??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++??++?+??++??+?++?+??+?++??++?+??+?++?+??++??+?++?+??+?++??++?+??...

output:

36801050

result:

ok single line: '36801050'