Submission #1304111


Source Code Expand

#include "stdio.h"

int main()
{
	//変数を立てて初期化
	//それぞれ、見た回数、比の高橋側と青木側、票数の高橋側と青木側
	int N = 0;
	int T[1010], A[1010];
	long long int voteT = 0, voteA = 0;
	for (int i = 0; i < 1010; i++) {
		T[i] = 0;
		A[i] = 0;
	}

	//見た回数と比を入力
	scanf("%d",&N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &T[i], &A[i]);
	}

	//投票数の初期値は1回目に見たときの票数
	//→比を最小で満たすように投票数を動かせばいいのでは
	//→比を整数倍した値になる&投票数は減らないので、前の値より大きくなる
	voteT = T[0];
	voteA = A[0];

	//i回目の比を確認するための変数とループ回数確認用の変数
	int nowT = 0, nowA = 0, count = 0;
	//そしてループの中で適合するか考えられている値
	long long int nowvoteT = 0, nowvoteA = 0;

	for (int i = 0; i < N; i++) {
		//i回目の比を確認する。
		nowT = T[i];
		nowA = A[i];
		
		while (1) {
			//ループ回数カウンタ(最初のループが1)
			count++;

			//比をカウンタ倍した値を考えてみる
			nowvoteT = nowT * count;
			nowvoteA = nowA * count;

			//今考えてる値がすでに決まってる投票数以上ならOK。
			//投票数を更新し、カウントを初期化してループを抜ける
			if ((nowvoteT >= voteT) && (nowvoteA >= voteA)) {
				voteT = nowvoteT;
				voteA = nowvoteA;
				count = 0;
				break;
			}
		}
	}

	//結果を表示する
	printf("%lld",voteT+voteA);

    return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User takenoko440
Language C (GCC 5.4.1)
Score 0
Code Size 1645 Byte
Status TLE
Exec Time 2103 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:17:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ^
./Main.c:19:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &T[i], &A[i]);
   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 6
TLE × 9
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 128 KB
0_001.txt AC 1 ms 128 KB
0_002.txt AC 1 ms 128 KB
1_003.txt AC 1 ms 128 KB
1_004.txt AC 1 ms 128 KB
1_005.txt TLE 2103 ms 128 KB
1_006.txt TLE 2103 ms 128 KB
1_007.txt TLE 2103 ms 128 KB
1_008.txt TLE 2103 ms 128 KB
1_009.txt TLE 2103 ms 128 KB
1_010.txt TLE 2103 ms 128 KB
1_011.txt TLE 2103 ms 128 KB
1_012.txt TLE 2103 ms 128 KB
1_013.txt TLE 2103 ms 128 KB
1_014.txt AC 1 ms 128 KB