Submission #1304295
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]; //ループ回数確認用の変数 long long 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; } //ループに入るのであれば事前にカウンタを動かしておきたいコーナー if (count != -1) { //比の示す一番近い値に投票数から近づいて、見つけたらカウントをそこにジャンプさせる //まあ比が投票数より大きかったら意味ないんだけども if (voteT >= T[i]) { for (int j = 0; j < T[i]; j++) { if ((voteT - j) % T[i] == 0) { count = voteT / T[i]; break; } } } //Aでも同じことをやる if (voteA >= A[i]) { for (int j = 0; j < A[i]; j++) { if ((voteA - j) % A[i] == 0) { //もしAのほうがカウンタ大きくなるんだったらこっちに合わせるよ //合わせなくていいんだったらそのまんま if (count < voteA / A[i]) count = voteA / A[i]; else break; } } } } //スキップできるように、count==-1ならループに入らないようにしてある while (count!=-1) { //比をカウンタ倍した値がすでに決まってる投票数以上なら、 //投票数を更新し、ループを抜ける //(比を満たす、今より大きな数を出していけば答えは出るだろ) if ((T[i] * count >= voteT) && (A[i] * count >= voteA)) { voteT = T[i] * count; voteA = A[i] * count; break; } //ループ回数カウンタ count++; } } //結果を表示する 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 | 300 |
Code Size | 2718 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 256 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 | 300 / 300 | ||||
Status |
|
|
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 | AC | 1 ms | 128 KB |
1_006.txt | AC | 1 ms | 128 KB |
1_007.txt | AC | 1 ms | 128 KB |
1_008.txt | AC | 1 ms | 128 KB |
1_009.txt | AC | 1 ms | 128 KB |
1_010.txt | AC | 1 ms | 128 KB |
1_011.txt | AC | 1 ms | 128 KB |
1_012.txt | AC | 1 ms | 128 KB |
1_013.txt | AC | 1 ms | 128 KB |
1_014.txt | AC | 13 ms | 256 KB |