QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573790#5563. K.O. KidsV-ioleTAC ✓0ms3856kbC++201.3kb2024-09-18 19:59:512024-09-18 19:59:51

Judging History

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

  • [2024-09-18 19:59:51]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3856kb
  • [2024-09-18 19:59:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define int long long
#define ull unsigned long long
typedef long long ll;
#define lowbit(x) ((x) & -(x))

const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 5, M = 1e5 + 10;
typedef pair<int, int> PII;
double T = 1 >> 30;
// double PI = acos(-1);

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}

void solve()
{
    int i, j;

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s = '?' + s;

    int l = 1, r = 0;
    int sum = 0;
    for (i = 1; i <= n;i++)
    {
        if(l)
        {
            if(s[i]=='R')
            {
                sum++;
            }else{
                r = 1;
                l = 0;
            }
        }else{
            if(s[i]=='L')
            {
                sum++;
            }else{
                r = 0;
                l = 1;
            }
        }
    }

    int ans = max(0ll, k - sum);
    cout << ans;
}

signed main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
    int t = 1;

    //  cin >> t;

    while (t--)
    {
        //  Case++;
        solve();
    }


    return 0;
}

詳細信息

Test #1:

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

input:

3 5
LRL

output:

5

result:

ok single line: '5'

Test #2:

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

input:

3 2
RRR

output:

0

result:

ok single line: '0'

Test #3:

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

input:

3 5
LLL

output:

3

result:

ok single line: '3'

Test #4:

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

input:

8 7
LLRLLLRR

output:

3

result:

ok single line: '3'

Test #5:

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

input:

5 1
LRLRL

output:

1

result:

ok single line: '1'

Test #6:

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

input:

5 1
LRLRR

output:

0

result:

ok single line: '0'

Test #7:

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

input:

5 5
LLRLL

output:

3

result:

ok single line: '3'

Test #8:

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

input:

10 10
LLRRLLRRRR

output:

4

result:

ok single line: '4'

Test #9:

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

input:

10 1
LLLLRRLRRL

output:

0

result:

ok single line: '0'

Test #10:

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

input:

10 20
LLRRLLLRLR

output:

16

result:

ok single line: '16'

Test #11:

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

input:

10 30
RRRLLLLRRL

output:

23

result:

ok single line: '23'

Test #12:

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

input:

10 5
LRRLLRLLRL

output:

2

result:

ok single line: '2'

Test #13:

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

input:

30 30
LRRLRLLLLRRRRRLLRLLLRLLRRLLLLR

output:

14

result:

ok single line: '14'

Test #14:

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

input:

30 50
RLRRRRRLRLLLRRRRRLLLRLLRRLLLLR

output:

32

result:

ok single line: '32'

Test #15:

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

input:

30 10
LLRRRRLLLRLRRRLRLLRLLLRRRLLRRR

output:

0

result:

ok single line: '0'

Test #16:

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

input:

30 500
RLLLRRRRRRLRRLRLRRLLRRLRLRRLLL

output:

485

result:

ok single line: '485'

Test #17:

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

input:

30 1000
RRLRLRRRLLLLLLRLRRRLLLLLRLLRLL

output:

983

result:

ok single line: '983'

Test #18:

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

input:

100 500
LRRRRLRRRRRRLLRRLLRLRLRLRLLRLRRRLRLLRLLRLLRLRLRLLRRRLRLRLRRRLLLRRRLLLLRRLRLLLRLLRLLRLRLRLRRLRLLLRLLL

output:

461

result:

ok single line: '461'

Test #19:

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

input:

100 1000
RLLLLRRRRRRLLRLLLLRLRLRLRRRLRLLRLLLLLLLLRRRLRRLRLRLLRRLRRLLRLLLLLRRRRLRRRRLLLRLLRRRRLLLRLLRLLRRLLRLR

output:

948

result:

ok single line: '948'

Test #20:

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

input:

100 10
LLLLRLLRLRLRLRLLRRRRLLRLRLRRRRRRLRRRRRRRLRRLRRLRRLLRLLRRLRRRRLLRLLLRLLRLRLRLLRLLLLLLRRLLLRRLLLRLLLRR

output:

0

result:

ok single line: '0'

Test #21:

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

input:

100 50
LLLLRRRLRRRLLLRLLLLRRRLLLLRRLRLRLRRRLLRLRLLRRRRLRRRRRRRLLLLRLRLRLLLLRLRRRRLRLRRRLLLLLLRLRRRRRLLLLLLL

output:

0

result:

ok single line: '0'

Test #22:

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

input:

100 200
LRLLLLLRRLRLRRLRLRRLLRLRLRLLRLLRRRLRRRRLLRLRLRLLRRRLLRRLLRLLLRRLLRLRLLRLRLLRRLLRLLRLRRRLLLRLRRRRRLLR

output:

160

result:

ok single line: '160'

Test #23:

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

input:

100 400
LRLRRLLLLRLLLLRLLRLLLLRRLLRLRLRLLRRRRRRRRLLRLRRRRLLLLRRLLLRRLRLRRLLLLLLLRRRRRRLLRLLRRRRRLRRRRRRLLRRL

output:

343

result:

ok single line: '343'

Test #24:

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

input:

100 150
LLLLRRRLRRLRRLLRRRLLRLRLLLRRLLLRLRLRRLRLLLLLLLRLLLLRRRLLLRLRLLLLRRRLLRLRLLRRRLLRLLLRLRLRLLRLRLRRRRRR

output:

102

result:

ok single line: '102'

Test #25:

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

input:

100 300
RLLRRLLLLRLRLRRRRRLLLRLLLLRLLRRRRLLLRLLLRLLLLLLRRLRLRLRLRLLLRLRLRRRRLLRRRRRLRLLRRRRLLLRRRRLLRRRLRRRL

output:

247

result:

ok single line: '247'

Test #26:

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

input:

100 700
LRLLLRLRRLRRLLLRRRRRRLRRRRLRLLLLLRLLRRLRRRLLLRLRLLLRRRLLRRRLLRRRRRLLLRRRRLRLLLLRRRRRLRLLLRRRRLRLLLRL

output:

645

result:

ok single line: '645'

Test #27:

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

input:

100 80
RLRLRLLLLRRLRRLLRRRRLRRRRRRLRLRRRRRRRLRRLLLRLLRRLRLRLRLLLRRRLRRRRLLLLRRLRRLRLRLLRLRLLRLLRLLRRLLRRLRR

output:

34

result:

ok single line: '34'

Test #28:

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

input:

500 500
LLLLRLLLRLLRRLLLLRRLLRLRLLRRRLRLRLRLLRRRRLRLRLRLLRLRLLRLLLLLLRLLRLRLLRLRRLRLRRRRRRLLRRLLLLLLRRRLRRRRLLRRRRLLLRLLLRLLLLLLRRLRRRLRLRRLLRRLRLLRLLRRRRRRRRRLRRLRLRLLRRLLRRRRLLRLLRLLLLLRRRLLRRLRRLLLRRRRLLRLLLRLLRRRLLRLRRRRLLLRLLRLLRLRLRLRLRLRRLLLLRLRRLRLRRLRRRLLRLLRLLLLRRLLLRRLRLRLRLLLLRLLRLLRLRRL...

output:

269

result:

ok single line: '269'

Test #29:

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

input:

500 100
LRRLLLLLRLRRRLLRRLLRLRLLLRRLLRRLLLRLLRLLRRRLRRRRRRRRLLLRLRRLRRLLRRRLRLRLLRLLLLLLRRLLLLRRLRLLLRRLLLRRRLLRLRRRRLRLLRRRRLRRLLRRLRLRLLRLRLRRLRLRRLRRRLLLLLRLRLLLLRLLLRRLLRRRLRLLLRLLLLLRRRLLLLRLLLRRLRRLRRRLRRRLLRLRRLRRLLLRLLLRLRRRRLLLLLRLRRLRRLLLRLLRLRLRLLLRRRRRRRLLLLRRRRLLLLRLRRLLLLRRRRRLRRRRRRLL...

output:

0

result:

ok single line: '0'

Test #30:

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

input:

500 1000
LLLLRRRLRRLRRRRRRLRRRLLLLLRRLRRLLRRRLLLRRLLRRRRRLLLRLRLLLRRRLRLRRRRRRRRLLRRRRRLLRLRRLRRRLLRRRLLLLLRRRLRLRLRLLLRRLLRLRRRLRLLLLLRRLRLRLLRRRLRLLRRRRLRLRLRLLRRRRRRRLLLLRRRRLRLLRLLRRLRLLLRRLRLLRRLLRRRRLLRRLLRLRLLRRRRLLLRRRRLLRRLLRRLLLLRLRLLLLRRLRRRRRLLLLLRLLRLRRLRLRLLRLRRRRRLLRRLLRRRLRLRRLRLRRLL...

output:

744

result:

ok single line: '744'

Test #31:

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

input:

500 800
LLRLRRRLRRLRLRRRLLRRLRLLRLRRRRRRLLRLLRRRRRRLRLRRRRLRRRLRLLLRRLRRRLRRLLLLRLRRLLLLLRRLRRRLRLLLLLRRLRRLLRRLRLRLLRRLLLLLRLLRLLRLRRLLLLLLRRRRLLRLRLRLRRRRRRLLRLLRLRRLLLRRLRRLLRRLLLLLRLLLLRRLRRRRLRRLLRLRRLLRLLRLRLLRLLRRLLRRLLLRRRLRRRRRRRRRRRRLLRRRRLLLLLLRRRRLLRRLRRLLLRLRRRRLLRLRLRRLLRRLRRLLLLLLRLRL...

output:

540

result:

ok single line: '540'

Test #32:

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

input:

500 200
LLLLRRRRLLRRLLRRRLRLLRLLRLRRLLRRRLRRRLLRLRLLLRRRLRRLLRLLLRRLRLLLLRLRLLLLLRLRRRRRLLLLLLLLLRRLLRRRLLRLLLRRLRRLRLRLLLRRRLRLLLRLLRRRLLLRLRLRRRRLLRLRLRRRLRLLRLLRRRRRLLLRLRRRRLRRLRLLRRLLRLRLRLRRRRRRLLLLLRLRLLRRRLLLRRLRLRLLRRLRRLRRLRRRLLLRLRLRLLRRRLRLLLLRRRLLRLRRLRLLLRLRRRRRLLRLLRRLRRLRRRRLLRRLLLRL...

output:

0

result:

ok single line: '0'

Test #33:

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

input:

1000 1000
LRLLRLLRLLRRRRRRRRRLLRRLRLRLRRLRRRLLLLLRLLRLRLRLLRLRRRRLLRRRLLLRRRLLRLRRLLLRLLLLRLLLRLRRLLRLRLLRLLRRLLRLRLRLLLRLLRLRRRLRRLRLLLRLLLRRRRLLRLLRLRLRRRRRLRRRLRRLRRLRLLLRRLLLRRRRRLLLRLRRLRRLLRRRLLLLLLLLRRRRLRRLRLRLRLLLLLRLLRRRRRRRRLRLLRRLRRRRRLRRLRRLRLRLRLLLLRLRRRLRRLRRLRRRLLLRLLLRLRRLRRLLLLLRRL...

output:

495

result:

ok single line: '495'

Test #34:

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

input:

1000 500
LLRRLLLLRRRLRRLRRLRLRLRRLLLLRRRRLLRLRLLLRRRRRRLRRLRRLLLLLLLLLRRRLRRRLLRLRRLRRRRLLLRLRRRRRRLRLRRRLLLRLRRLRRLRLRRRRLLRLRLRRRRRLRRLLLLRRRRLLRRRLLRRRRLRLRLRLRLRLLLRLRRLLLLLLRLLLLRRRLRRRLLRLLRRLRLRLLLLLRLRLLRRRLRLRLRLRLLRRLRLLLRRRRRRRLRRRRLLRLLLLRLRLLRRRRRRLLRLRLLRLLRLLLLRRLRLLLRLRRRLRLLRLRRRRLL...

output:

0

result:

ok single line: '0'

Test #35:

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

input:

1000 300
LLLLLLLLLLLLRLLLLLRRRRLRLLRRLLRLLLRLRLRRRRRRLLLLRLLLLLRLRLRRLRLLRRLLRRLRLRRRRRRRLRLRLLLLLRRLLRRRLLLLLRLLRRLLRLRLRRLRLLLLRLLLLLLRLRLLLLLLLLLRLRLLLRLLLLRRLRLRRLRRRRRRRLLLLLLLRRRLRRLRLRLLLLRLLLRLRRRLLLRRRRRRLRRLRLRLLLRRLLRRRLLRLLRLLLLLRLRRLLRLRLLRRLLRRRLLLLRLLLRRRLLLLLLRLLRLLLRRRRLRLLLLLLLRRLL...

output:

0

result:

ok single line: '0'

Test #36:

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

input:

1000 100
RRLRRLLLRRLRLRLLRRRRRRRLLRLRRLLLLLLRLRLRLLRLLLRRLRLLRRRRRRLLRLRRLLRRLLRLRLRRLRLLRLRRRRRLRLRRRRLLLLRRLLRRLLRLLLRRRRRRLLRLRLRRRLLLRRRLRRRLLRRRRLRRRLRRLLRLRLRLRRRRRLRLLLRLRRLLLRLLRRLRRRRLRRLLLLRLLLRLLRRRRLLRRRLLRRRLRRLRRRLLLLRRRLLLLLLRRLLLRRRRRLRRLLRLRRRLRRLLLRRRRLRLRLLLLRRRLLRRLRLRLLRRRRLRLLL...

output:

0

result:

ok single line: '0'

Test #37:

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

input:

1000 10
LLLRRRLLRRRLRLLLLRLLRRLLLRRLLRLLRRRRRLLRRLLLLRLLLLRLLRRLLRRRLLRRRRLLLRLLRLLLRRRRLLLRLRRRLLLRRLRRLLRLRLLLLLLLLLLRLRRRLLLLLRLRLLLLRLLLRRLLRLRRLLRRRRLRLRLRRRLLRLRLRRRRLLRRLRLRRRLRLLLLLLRRRLLLLRLRLLLRRLLLRLLLLRRRLRRLRRLLRRRRLRRLLRLLRRRRRRLRRRLRLLRLRLRLLLRLRLRLRLRLLRLLRRLRLRLLLLRRRRLRLLLLLRLRLLRL...

output:

0

result:

ok single line: '0'

Test #38:

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

input:

1000 1000
RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL...

output:

999

result:

ok single line: '999'

Test #39:

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

input:

1000 1000
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

1000

result:

ok single line: '1000'

Test #40:

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

input:

1000 250
RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

249

result:

ok single line: '249'

Test #41:

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

input:

1000 250
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL...

output:

250

result:

ok single line: '250'

Test #42:

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

input:

1000 50
RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL...

output:

49

result:

ok single line: '49'

Test #43:

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

input:

1000 50
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

50

result:

ok single line: '50'

Test #44:

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

input:

1000 250
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...

output:

0

result:

ok single line: '0'

Test #45:

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

input:

1000 50
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

0

result:

ok single line: '0'

Test #46:

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

input:

1000 50
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...

output:

0

result:

ok single line: '0'