QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#635390#5420. Inscryptionwzxtsl#WA 296ms3656kbC++231.2kb2024-10-12 19:39:532024-10-12 19:39:53

Judging History

你现在查看的是最新测评结果

  • [2024-10-12 19:39:53]
  • 评测
  • 测评结果:WA
  • 用时:296ms
  • 内存:3656kb
  • [2024-10-12 19:39:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
#define For(i,a,aa) for(int i=a;i<=aa;i++)
int n,m;
const int N=2e6+7;
int sum1,sum2,sum3,cnt;
int a,zi,mu;
double ans;
void solve(){
    cnt=ans=sum1=sum2=sum3=0;
	cin>>n;
    int flg=0;
    For(i,1,n)
    {
        cin>>a;
        if(a==1) sum1++;
        else if(a==0) 
        {
            if(sum1+sum3==sum2) cnt++;
            sum3++;
        }
        else
        {
            sum2++;
            if(sum1+sum3<sum2)
            {
                flg=1;
            }
        }
    } //cout<<flg<<"!";    
    if(flg) {
        cout<<-1<<endl;return ;
    }
    For(i,cnt,sum3)
    {
        if(1+sum1+2*i-sum2-sum3<=0) continue;
        if((sum1+1+i)/(1+sum1+2*i-sum2-sum3)>ans) 
        {
            ans=(sum1+1+i)/(1+sum1+2*i-sum2-sum3);
            int g=__gcd((sum1+1+i),(1+sum1+2*i-sum2-sum3));
            zi=(sum1+1+i)/g,mu=(1+sum1+2*i-sum2-sum3)/g;
        }
    }
    cout<<zi<<" "<<mu<<endl;

}
signed main(){
    fast;
	int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
	

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3656kb

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 1
2 1
-1

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 296ms
memory: 3608kb

input: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
3 2
-1
-1
-1
-1
2 1
5 3
-1
5 4
2 1
-1
3 2
5 1
1 1
-1
3 2
-1
1 1
-1
2 1
1 1
-1
1 1
-1
1 1
3 2
-1
-1
-1
-1
3 2
5 2
1 1
-1
3 1
-1
-1
1 1
-1
6 1
3 2
-1
3 2
4 3
2 1
-1
5 3
3 1
6 1
-1
2 1
2 1
-1
1 1
-1
3 1
-1
-1
4 1
1 1
2 1
5 2
-1
3 1
4 3...

result:

wrong answer 71st lines differ - expected: '5 4', found: '2 1'