Submission #1074503


Source Code Expand

#include<cstdio>
#include<iostream>
using namespace std;

const int max_n = 100000; 
int main(){
	long int n;
	long long int a[max_n];long long int b[max_n];
	long int i,j;
	int counter=0;
	
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%lld %lld",&a[i],&b[i]);
		//printf("%lld %lld\n",a[i],b[i]);
	}

	for(i=n-1;i>=0;i--){
		//printf("when i = %d, a[%d],b[%d] = %d,%d\n",i,i,i,a[i],b[i]);
		int module = a[i] % b[i];
		//printf("module=%d\n",module);
		int times = b[i] - module;
		//printf("times=%d\n",times);
		if(module!=0)
		counter += times;
		//printf("counter=%d\n",counter);
		if(i!=0){
			for(j=i-1;j>=0;j--){
				a[j] += times;
			}
		}
	}

	printf("%d\n",counter);
	return 0;
}

Submission Info

Submission Time
Task A - Multiple Array
User utsumi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 728 Byte
Status TLE
Exec Time 2102 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%ld",&n);
                 ^
./Main.cpp:14:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&a[i],&b[i]);
                                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 4
TLE × 14
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt TLE 2102 ms 1792 KB
02.txt TLE 2102 ms 1792 KB
03.txt TLE 2102 ms 1792 KB
04.txt TLE 2102 ms 1792 KB
05.txt TLE 2102 ms 1792 KB
06.txt TLE 2102 ms 1792 KB
07.txt TLE 2102 ms 1792 KB
08.txt TLE 2102 ms 1792 KB
09.txt TLE 2102 ms 1792 KB
10.txt TLE 2102 ms 1792 KB
11.txt TLE 2102 ms 1792 KB
12.txt TLE 2102 ms 1792 KB
13.txt TLE 2102 ms 1792 KB
14.txt TLE 2102 ms 1792 KB
15.txt AC 3 ms 256 KB
16.txt AC 3 ms 256 KB
s1.txt AC 2 ms 256 KB
s2.txt AC 3 ms 256 KB