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 |
---|---|---|---|---|---|---|---|---|---|
#137319 | #2356. Partition of Queries | 4k2kok# | WA | 1ms | 3500kb | C++20 | 989b | 2023-08-10 10:22:14 | 2023-08-10 10:22:17 |
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;
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 * bck[n];
}
if (str[i] == '+') {
cnt++;
}
}
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: 3476kb
input:
6 5 ++??+?
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3500kb
input:
6 8 ++??+?
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
5 1 +++++
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
10 0 ++?+??++??
output:
0
result:
ok single line: '0'
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3492kb
input:
12 100 +?+++??+??++
output:
0
result:
wrong answer 1st lines differ - expected: '19', found: '0'