QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#722092 | #5420. Inscryption | fieldchaser | WA | 1ms | 3592kb | C++20 | 909b | 2024-11-07 17:47:54 | 2024-11-07 17:47:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#define pb push_back
void solve(){
int n; cin>>n;
vector<int> a(n);
int left=0,num=1,strength=1;
bool flag=true;
for (int i=0;i<n;i++){
cin>>a[i];
if (a[i]==1) num++,strength++;
else if (a[i]==-1){
if (num>1) num--;
else if (left>=1){
left--,num+=2,strength++;
}
else flag=false;
}
else{
if (num>1) num--,left++;
else num++,strength++;
}
}
if (!flag) cout<<-1<<"\n";
else{
int minn=__gcd(num,strength);
num/=minn,strength/=minn;
cout<<strength<<" "<<num<<"\n";
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int t; cin>>t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3592kb
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:
3 2 3 2 -1 1 1 2 1 -1
result:
wrong answer 2nd lines differ - expected: '3 1', found: '3 2'