QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#124754 | #5420. Inscryption | chinguun_0301# | WA | 1ms | 3544kb | C++14 | 950b | 2023-07-15 15:13:46 | 2023-07-15 15:15:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
void solve(){
cin >> n;
int x;
int sum = 0, b = 0;
int ttl1 = 0, ttl0 = 0, ttlm1 = 0;
for(int i = 0; i < n; i++){
cin >> x;
if(x == 1) ttl1++;
if(x == -1) ttlm1++;
if(x == 0) ttl0++;
if(x == -1) sum--;
else sum++;
if(sum < 0) b = 1;
}
if(b == 1){
cout << -1 << "\n";
return;
}
int ttl = ttl0 + ttlm1 - ttl1;
if(ttl % 2 == 0) ttl = ttl / 2;
else ttl = ttl / 2 + 1;
ttl1 += ttl;
ttlm1 += (ttl0 - ttl);
int s1 = ttl1 + 1;
int s2 = s1 - ttlm1;
if(s1 == 0 && s2 == 0) {
cout << "-1\n";
return;
}
int a = __gcd(s1, s2);
cout << s1 << " " << s2 << "\n";
}
int main(){
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3544kb
input:
6 7 1 1 1 -1 1 1 -1 4 1 0 -1 0 4 0 -1 -1 0 1 0 2 0 0 1 -1
output:
6 4 3 1 -1 2 2 2 1 -1
result:
wrong answer 1st lines differ - expected: '3 2', found: '6 4'