Submission #1304192


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];

	//ループ回数確認用の変数
	int count = 0;

	//1回目に見たときの投票数を初期値としてるのでi=1でi=Nまでループ
	for (int i = 1; i < N; i++) {
		//カウンタを初期化する
		count = 0;

		//小細工そのいち
		//比が前と一致するなら投票数が変化していないのでwhileをスキップする
		if ((T[i] == T[i - 1]) && (A[i] == A[i - 1]))
			count = -1;

		//小細工そのに
		//1:1なら大きいほうに合わせる
		if ((T[i] == 1) && (A[i] == 1)) {
			if (voteT >= voteA)
				voteA = voteT;
			else
				voteT = voteA;

			count = -1;
		}
		
		//スキップできるように、count==-1ならループに入らないようにしてある
		while (count!=-1) {

			//ループ回数カウンタ(最初のループが1)
			count++;

			//比をカウンタ倍した値がすでに決まってる投票数以上なら、
			//投票数を更新し、ループを抜ける
			//(比を満たす、今より大きな数を出していけば答えは出るだろ)
			if ((T[i] * count >= voteT) && (A[i] * count >= voteA)) {
				voteT = T[i] * count;
				voteA = A[i] * count;
				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 1824 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