QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#413805 | #5652. Controllers | thesupermarketisgoingtome# | WA | 1ms | 3600kb | C++20 | 938b | 2024-05-18 08:59:45 | 2024-05-18 08:59:46 |
Judging History
answer
/*
* author: ADMathNoob
* created: 05/17/24 20:37:58
* problem: https://qoj.ac/problem/5652
*/
/*
Comments about problem:
*/
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...) 42
#endif
bool Solve(int p, int m, int a, int b) {
int c = a - b;
int rhs = (m - p) * b;
if (rhs == 0) {
return true;
}
if (c == 0) {
return false;
}
if (rhs % c != 0) {
return false;
}
int d = rhs / c;
return -m <= d && d <= p;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int p = 0, m = 0;
for (int i = 0; i < n; i++) {
char c;
cin >> c;
if (c == '+') {
p += 1;
} else {
m += 1;
}
}
int tt;
cin >> tt;
while (tt--) {
int a, b;
cin >> a >> b;
cout << (Solve(p, m, a, b) ? "YES" : "NO") << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
input:
8 +-+---+- 5 2 1 10 3 7 9 10 10 5 3
output:
YES NO NO NO YES
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
6 +-++-- 2 9 7 1 1
output:
YES YES
result:
ok 2 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3540kb
input:
20 +-----+--+--------+- 2 1000000000 99999997 250000000 1000000000
output:
NO NO
result:
wrong answer 2nd lines differ - expected: 'YES', found: 'NO'