QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137362 | #2356. Partition of Queries | 4k2kok# | WA | 1ms | 3584kb | C++20 | 1.1kb | 2023-08-10 11:14:46 | 2023-08-10 11:14:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(a,b) memset((a),(b),sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
#define int long long
#define db long double
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int n, y, bck[1001000];
string str;
void solve() {
cin >> n >> y;
if (y == 0) {
cout << "0\n";
return ;
}
cin >> str; str = " " + str;
for (int i = n; i >= 1; i--) {
bck[i] = bck[i + 1] + (str[i] == '?');
}
int cnt = 0, ans = 0;
for (int i = 1; i <= n; i++) {
if (str[i] == '?') {
if (cnt * bck[i] > y) {
cnt = 0;
ans += y;
}
ans += cnt;
}
if (str[i] == '+') {
cnt++;
}
// cerr << i << ' ' << cnt << ' ' << ans << '\n';
}
cout << ans << '\n';
}
signed main(){
io;
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3524kb
input:
6 5 ++??+?
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
6 8 ++??+?
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
5 1 +++++
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
10 0 ++?+??++??
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
12 100 +?+++??+??++
output:
19
result:
ok single line: '19'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
1 1 ?
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
9 7 ++++++++?
output:
7
result:
ok single line: '7'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
9 8 ++++++++?
output:
8
result:
ok single line: '8'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
10 15 ++++++++??
output:
15
result:
ok single line: '15'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
5 3 +?+?+
output:
3
result:
ok single line: '3'
Test #11:
score: -100
Wrong Answer
time: 1ms
memory: 3472kb
input:
10 5 +?+?+??+??
output:
13
result:
wrong answer 1st lines differ - expected: '10', found: '13'