Submission #3024618


Source Code Expand

#include<stdio.h>

int abs(int a){
  if(a<0)a = -a;
  return a;
}

int main(){
  int A[3];

  int max=0, min=101;
  int maxi;

  for(int i=0; i<3; i++){
    scanf("%d", &A[i]);
    if(max<A[i]){
      max = A[i];
      maxi = i;
    }
  }

  int cost = 0;
  int cmin = 1000;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(j==i)continue;
      for(int k=0; k<3; k++){
	if(k==j || k==i)continue;
	cost = abs(A[j]-A[i]) + abs(A[k]-A[j]);
	if(cmin>cost)cmin = cost;
      }
    }
  }
  
  printf("%d\n", cmin);

  return 0;
}

Submission Info

Submission Time
Task A - Task Scheduling Problem
User htkaaa
Language C++14 (GCC 5.4.1)
Score 100
Code Size 576 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &A[i]);
                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 13
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All 0_small_rand_0, 0_small_rand_1, 0_small_rand_2, 0_small_rand_3, 1_rand_0, 1_rand_1, 1_rand_2, 1_rand_3, 2_hand_0, 2_hand_1, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_small_rand_0 AC 1 ms 128 KB
0_small_rand_1 AC 1 ms 128 KB
0_small_rand_2 AC 1 ms 128 KB
0_small_rand_3 AC 1 ms 128 KB
1_rand_0 AC 1 ms 128 KB
1_rand_1 AC 1 ms 128 KB
1_rand_2 AC 1 ms 128 KB
1_rand_3 AC 1 ms 128 KB
2_hand_0 AC 1 ms 128 KB
2_hand_1 AC 1 ms 128 KB
sample_01 AC 1 ms 128 KB
sample_02 AC 1 ms 128 KB
sample_03 AC 1 ms 128 KB