Computer Programming Contest Preparation

ToolBox - Source for: naq/2026/b.c



/home/toolbox/public_html/solutions/naq/2026/b.c
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <sys/types.h>
    4 #include <sys/stat.h>
    5 #include <fcntl.h>
    6 #include <stdlib.h>
    7 #include <math.h>
    8 #include <stdint.h>
    9 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 /* fprintf(stderr, "functionName: message", varslist); */
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2026-10-03
   21  * Purpose: fun
   22  * Problem: b - Airtime
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 int seconds;
   30 int t1;
   31 int t2;
   32 int s0;
   33 int s1;
   34 int cnt;
   35 
   36 void init()
   37 {
   38     /* FUNCTION init */
   39     scanf(" %d ", &seconds);
   40     scanf(" %d ", &t1);
   41     scanf(" %d ", &t2);
   42     s1 = t1 - t2;
   43 } /* FUNCTION init */
   44 
   45 void dump()
   46 {
   47     /* FUNCTION dump */
   48 } /* FUNCTION dump */
   49 
   50 void getInput()
   51 {
   52     /* FUNCTION getInput */
   53     t1 = t2;
   54     s0 = s1;
   55     scanf(" %d ", &t2);
   56     s1 = t1 - t2;
   57 } /* FUNCTION getInput */
   58 
   59 void process()
   60 {
   61     /* FUNCTION process */
   62     if (s0 < s1)
   63         {
   64             cnt++;
   65         }
   66 } /* FUNCTION process */
   67 
   68 int main()
   69 {
   70     /* main */
   71     int i;
   72 
   73     init();
   74     for (i=2; i<seconds; i++)
   75         {
   76             /* while */
   77             getInput();
   78             process();
   79         } /* while */
   80     printf("%d\n", cnt);
   81 
   82     return EXIT_SUCCESS;
   83 } /* main */
   84 
   85