NCPC26 final practice - py

This commit is contained in:
Zacharias committed 2026-09-29 17:09:30 +02:00
1 parent f9af40293e
commit 3f62e35eb0
4 files changed
+191

No files matched your search

+152
View File
@@ -0,0 +1,152 @@
#include <stdio.h>
#include <string.h>
int main()
{
int array[26];
int time = 0;
char problem;
char RightOrWrong[10];
int sum = 0;
int solved = 0;
int is_solved[26];
for (int i = 0 ; i < 26; i++){
is_solved[i] = 0;
}
for(int i = 0; i < 26; i++)
{
array[i] = 0;
}
while(scanf("%d %c %s", &time, &problem, &RightOrWrong) == 3 && time != -1){
switch (problem){
case 'A':
if (strcmp(RightOrWrong, "wrong")==0){
array[0] += 20;
}else{
array[0] += time;
solved += 1;
is_solved[0] = 1;
}
break;
case 'B':
if (strcmp(RightOrWrong, "wrong")==0){
array[1] += 20;
}else{
array[1] += time;
solved += 1;
is_solved[1] = 1;
}
break;
case 'C':
if (strcmp(RightOrWrong, "wrong")==0){
array[2] += 20;
}else{
array[2] += time;
solved += 1;
is_solved[2] = 1;
}
break;
case 'D':
if (strcmp(RightOrWrong, "wrong")==0){
array[3] += 20;
}else{
array[3] += time;
solved += 1;
is_solved[3] = 1;
}
break;
case 'E':
if (strcmp(RightOrWrong, "wrong")==0){
array[4] += 20;
}else{
array[4] += time;
solved += 1;
is_solved[4] = 1;
}
break;
case 'F':
if (strcmp(RightOrWrong, "wrong")==0){
array[5] += 20;
}else{
array[5] += time;
solved += 1;
is_solved[5] = 1;
}
break;
case 'G':
if (strcmp(RightOrWrong, "wrong")==0){
array[6] += 20;
}else{
array[6] += time;
solved += 1;
is_solved[6] = 1;
}
break;
case 'H':
if (strcmp(RightOrWrong, "wrong")==0){
array[7] += 20;
}else{
array[7] += time;
solved += 1;
is_solved[7] = 1;
}
break;
case 'I':
if (strcmp(RightOrWrong, "wrong")==0){
array[8] += 20;
}else{
array[8] += time;
solved += 1;
is_solved[8] = 1;
}
break;
case 'J':
if (strcmp(RightOrWrong, "wrong")==0){
array[9] += 20;
}else{
array[9] += time;
solved += 1;
is_solved[9] = 1;
}
break;
case 'K':
if (strcmp(RightOrWrong, "wrong")==0){
array[10] += 20;
}else{
array[10] += time;
solved += 1;
is_solved[10] = 1;
}
break;
default:
return 0;
break;
}
}
for(int i = 0; i <= 26; i++)
{
if(is_solved[i]==1){
sum += array[i];
}
}
printf("%d %d", solved, sum);
return 0;
}