/home/toolbox/public_html/solutions/12/1260/a.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
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /* fprintf(stderr, "functionName: message", varslist); */
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2020-04-07
20 * Purpose: fun
21 * Problem: 1260 - sales
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 #define MAX_SOLD 5005
29
30 int numberOfTimes;
31 int num[MAX_SOLD];
32 int cnt;
33
34
35 void init()
36 {
37 /* FUNCTION init */
38 scanf("%d ", &numberOfTimes);
39 } /* FUNCTION init */
40
41 void dump()
42 {
43 /* FUNCTION dump */
44 } /* FUNCTION dump */
45
46 void getInput()
47 {
48 /* FUNCTION getInput */
49 int i;
50
51 scanf(" %d ", &cnt);
52 for (i=0; cnt>i; i++)
53 {
54 /* or */
55 scanf(" %d ", &num[i]);
56 } /* or */
57 } /* FUNCTION getInput */
58
59 void process()
60 {
61 /* FUNCTION process */
62 int i;
63 int j;
64 int tot = 0;
65
66 for (i=1; cnt>i; i++)
67 {
68 /* for i */
69 for (j=0; j<i; j++)
70 {
71 /* for j */
72 if (num[j] <= num[i])
73 {
74 tot++;
75 }
76 } /* for j */
77 } /* for i */
78 printf("%d\n", tot);
79 } /* FUNCTION process */
80
81 int main()
82 {
83 /* main */
84 int i;
85
86 init();
87 for (i=0; i<numberOfTimes; i++)
88 {
89 /* while */
90 getInput();
91 process();
92 } /* while */
93
94 return EXIT_SUCCESS;
95 } /* main */
96
97