QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#110293 | #5420. Inscryption | zhuidao | WA | 212ms | 3428kb | C++20 | 1.6kb | 2023-06-01 14:43:37 | 2023-06-01 14:43:40 |
Judging History
answer
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll>pi;
#define int ll
#define X first
#define Y second
#define fer(i,a,n) for(int i=a;i<=n;i++)
#define ref(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,x) memset(a,x,sizeof a)
#define ac IO;int t;cin>>t;while(t--)solve()
#define AC signed main(){IO;solve();}
#define NO {cout<<"No"<<endl;return;}
#define YES {cout<<"Yes"<<endl;return;}
#define re(a) {cout<<a<<endl;return;}
#define V vector<int>
#define all(v) v.begin(),v.end()
//ofstream fout("out.txt", ios::out);
//ifstream fin("in.txt", ios::in);
//#define cout fout
//#define cin fin
//--------------------瑞神神中神--------------------
//--------------------刘魔魔中魔--------------------
const int N=1e6+10;
int a[N];
int n;
void solve()
{
cin>>n;
fer(i,1,n)
{
cin>>a[i];
}
int sum=1,cnt=1,pre=0;
for(int i=1;i<=n;i++)
{
if(a[i]==-1)
{
if(cnt<=1)re(-1);
cnt--;pre--;
}
else
{
sum++,cnt++;
pre++;
}
}
int suf=0;
for(int i=n;i>=1;i--)
{
if(a[i])
{
suf+=a[i];pre-=a[i];
continue;
}
if(pre-2+suf>=0)
{
suf--;pre--;
cnt-=2;sum--;
}
}
int gd=gcd(sum,cnt);
cout<<sum/gd<<' '<<cnt/gd<<endl;
}
signed main()
{
ac;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3316kb
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 1 -1 1 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