QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#430026#5420. InscryptionmangoooWA 1ms3612kbC++201.0kb2024-06-03 11:37:362024-06-03 11:37:36

Judging History

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

  • [2024-06-03 11:37:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3612kb
  • [2024-06-03 11:37:36]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std; 

typedef long long i64;
typedef pair<int, int> PII;

void solve()
{
	int n;
	cin >> n;
	
	int c1 = 0, c2 = 0, c3 = 0;
	int is = 0;
	
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		
		if(x == 1) c1++;
		else if(x == -1) c2++;
		else c3++;
		
		if(c2 >= c1 + c3 && c2) is = 1;	
	} 
	
	if(is) cout << "-1\n";
	else
	{
		int x = c1 + 1, y = c1 - c2 + 1;
		if(y <= 0)
		{
			c3 += y - 1;
			y = 1;
			
			if(c3 % 2)
			{
				x++;
				y++;
				c3--;
			}
			x += c3 / 2;
			if(y != 1 && x % y == 0)
			{
				y = 1;
				x /= y;
			}
			cout << x << ' ' << y << '\n';
		}
		else
		{
			if(c3 % 2)
			{
				x++;
				y++;
				c3--;
			}
			x += c3 / 2;
			if(y != 1 && x % y == 0)
			{
				y = 1;
				x /= y;
			}
			cout << x << ' ' << y << '\n';
		}
	}
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1;
    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: 3612kb

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

result:

wrong answer 1st lines differ - expected: '3 2', found: '6 4'