Submission #13881928


Source Code Expand

/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL unsigned long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
LL a[100000+2];
LL resu=1;
int main(){
	fastio;
	cin>>n;
	rb(i,1,n)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	rb(i,1,n)
	{
		
		int Wei1,Wei2;
		Wei1=Wei2=0;
		LL A,B;
		A=resu,B=a[i];
		while(A>=10){
			A/=10;
			Wei1++;
		}
		while(B>=10){
			B/=10;
			Wei2++;
		}
		if(Wei1+Wei2>18){
			cout<<-1<<endl;
			return 0;
		}
		resu*=a[i];
		if(resu>(LL)(1e18)){
			cout<<-1<<endl;
			return 0;
		}
		if(resu<0){
			cout<<-1<<endl;
			return 0;
		}
	}
	if(resu>(LL)(1e18)){
		cout<<-1<<endl;
	}
	else{
		cout<<resu;
	}
	return 0;
}

Submission Info

Submission Time
Task B - Multiplication 2
User Gary
Language C++ (GCC 9.2.1)
Score 0
Code Size 1359 Byte
Status WA
Exec Time 31 ms
Memory 4400 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:62:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
   62 |   if(resu<0){
      |      ~~~~^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 3
AC × 23
WA × 1
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, max_01.txt, max_02.txt, random_01.txt, random_02.txt, random_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, small11_02.txt, small11_03.txt, small11_04.txt, small12_02.txt, small12_03.txt, small12_04.txt, small21_01.txt, small21_02.txt, small21_03.txt, small22_01.txt, small22_02.txt, small22_03.txt, zero_01.txt, zero_02.txt
Case Name Status Exec Time Memory
hand_01.txt WA 6 ms 3496 KiB
hand_02.txt AC 2 ms 3616 KiB
max_01.txt AC 24 ms 4304 KiB
max_02.txt AC 11 ms 4328 KiB
random_01.txt AC 20 ms 4000 KiB
random_02.txt AC 19 ms 3996 KiB
random_03.txt AC 25 ms 3968 KiB
sample_01.txt AC 2 ms 3540 KiB
sample_02.txt AC 2 ms 3544 KiB
sample_03.txt AC 2 ms 3644 KiB
small11_02.txt AC 2 ms 3624 KiB
small11_03.txt AC 2 ms 3492 KiB
small11_04.txt AC 2 ms 3588 KiB
small12_02.txt AC 4 ms 3588 KiB
small12_03.txt AC 2 ms 3592 KiB
small12_04.txt AC 2 ms 3616 KiB
small21_01.txt AC 13 ms 4368 KiB
small21_02.txt AC 15 ms 4400 KiB
small21_03.txt AC 13 ms 4372 KiB
small22_01.txt AC 16 ms 4396 KiB
small22_02.txt AC 13 ms 4392 KiB
small22_03.txt AC 15 ms 4396 KiB
zero_01.txt AC 29 ms 4396 KiB
zero_02.txt AC 31 ms 4400 KiB