Submission #928596
Source Code Expand
#include "stdio.h"
long long int N;
long long int pro[2][1000] = {};
long long int num[2][1000] = {};
long long int cross;
int main() {
scanf("%lld", &N);
scanf("%lld %lld", &pro[0][0], &pro[1][0]);
num[0][0] = pro[0][0];
num[1][0] = pro[1][0];
//printf("%lld %lldになった\n", num[0][0], num[1][0]);
for (int i = 1; i < N; i++) {
scanf("%lld %lld", &pro[0][i], &pro[1][i]);
if (pro[0][i] >= num[0][i - 1] && pro[1][i] >= num[1][i-1]) {
num[0][i] = pro[0][i];
num[1][i] = pro[1][i];
//printf("%lld %lldになった\n", num[0][i], num[1][i]);
}
else {
if (num[0][i - 1] % pro[0][i] == 0)cross = num[0][i - 1] / pro[0][i];
else cross = num[0][i - 1] / pro[0][i] + 1;
if (cross < num[1][i - 1] / pro[1][i] + 1 && num[1][i - 1] % pro[1][i] != 0)cross = num[1][i - 1] / pro[1][i] + 1;
else if (cross < num[1][i - 1] / pro[1][i] && num[1][i - 1] % pro[1][i] == 0)cross = num[1][i - 1] / pro[1][i];
num[0][i] = pro[0][i] * cross;
num[1][i] = pro[1][i] * cross;
//printf("%lld %lldになった\n", num[0][i], num[1][i]);
}
}
printf("%lld\n", num[0][N - 1] + num[1][N - 1]);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - AtCoDeer and Election Report |
User |
olphe |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1163 Byte |
Status |
AC |
Exec Time |
2 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:9:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &N);
^
./Main.cpp:10:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &pro[0][0], &pro[1][0]);
^
./Main.cpp:15:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &pro[0][i], &pro[1][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 |
2 ms |
128 KB |
1_005.txt |
AC |
1 ms |
128 KB |
1_006.txt |
AC |
2 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 |
2 ms |
128 KB |
1_014.txt |
AC |
2 ms |
128 KB |