207 - PGA Tour Prize Money

All about problems in Volume 2. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

r2ro
New poster
Posts: 38
Joined: Thu Sep 25, 2008 9:26 am

Re: 207 - PGA Tour Prize Money

Post by r2ro »

Hi brianfry713, first of all, thanks.

Now, apparently I see my issue, but I want to know how you approached it. The outputs of my program and your program are exactly the same except for a particular test case

Code: Select all

1

371327.50
1.9000
1.2000
1.4000
2.1000
1.4000
1.3000
1.5000
1.5000
1.2000
1.4000
0.7000
1.4000
1.4000
0.7000
2.2000
1.6000
1.1000
1.7000
0.7000
1.2000
1.7000
1.9000
1.4000
1.1000
1.3000
2.3000
1.3000
1.8000
2.0000
1.0000
1.3000
1.3000
1.6000
1.7000
1.1000
1.3000
1.7000
1.5000
2.1000
1.5000
0.9000
1.9000
2.1000
2.7000
1.6000
1.1000
1.7000
0.4000
1.1000
1.1000
1.1000
0.8000
1.1000
1.4000
1.6000
1.6000
1.3000
1.6000
1.4000
2.1000
1.4000
0.6000
1.5000
1.7000
1.4000
1.5000
1.2000
1.7000
1.2000
0.7000
144
P  1*                49 77 57 64
P  2                 DQ
P  3*                55 72 33 14
P  4                 66 15 13 DQ
P  5                 97 27 73 27
P  6*                DQ
P  7                 52 75 54 29
P  8*                86 72 69 31
P  9                 31 17 41 30
P 10                 50 DQ
P 11                 83 79 DQ
P 12                 62 95 DQ
P 13                 14 45 74 18
P 14                 65 68 56 35
P 15*                DQ
P 16                 65 64 11 94
P 17*                60 44 DQ
P 18*                74 39 31 31
P 19                 39 29 53 DQ
P 20                 DQ
P 21                 87 93 54 94
P 22                 94 50 30 32
P 23                 15 29 48 73
P 24                 34 92 11 94
P 25                 27 DQ
P 26                 86 48 46 DQ
P 27                 68 93 92 36
P 28*                47 DQ
P 29                 92 79 98 66
P 30*                64 69 98 83
P 31*                13 63 DQ
P 32                 78 42 11 16
P 33                 47 69 60 DQ
P 34                 89 27 91 39
P 35                 40 56 71 96
P 36                 59 18 30 99
P 37                 21 45 53 DQ
P 38                 DQ
P 39*                32 33 49 99
P 40*                57 81 87 DQ
P 41                 98 21 45 24
P 42                 44 21 95 43
P 43                 82 70 91 30
P 44                 69 21 DQ
P 45*                12 43 29 58
P 46                 69 13 68 73
P 47*                43 48 39 97
P 48                 70 10 52 63
P 49                 81 DQ
P 50                 99 92 43 88
P 51                 83 86 84 54
P 52*                25 85 37 46
P 53                 79 52 24 22
P 54                 13 59 62 37
P 55                 87 46 78 57
P 56                 85 43 90 91
P 57*                19 11 88 DQ
P 58                 42 28 13 14
P 59                 83 86 57 70
P 60*                60 26 20 18
P 61                 96 41 85 67
P 62                 73 48 75 51
P 63                 DQ
P 64                 32 DQ
P 65                 78 42 99 25
P 66                 DQ
P 67                 57 64 11 37
P 68                 65 94 66 45
P 69*                13 DQ
P 70                 14 94 96 43
P 71                 90 DQ
P 72                 72 77 97 60
P 73                 26 80 58 39
P 74*                44 73 87 11
P 75*                53 80 10 70
P 76*                DQ
P 77*                22 12 79 97
P 78*                18 95 66 48
P 79                 54 83 DQ
P 80                 31 98 44 43
P 81                 45 54 55 28
P 82                 75 27 24 29
P 83                 12 23 71 38
P 84*                52 80 59 DQ
P 85                 45 96 DQ
P 86                 36 22 31 70
P 87                 20 73 95 10
P 88                 24 84 51 51
P 89                 47 38 DQ
P 90*                44 29 58 33
P 91                 59 12 65 42
P 92                 26 86 55 71
P 93                 61 71 21 DQ
P 94                 70 72 73 56
P 95                 22 38 55 58
P 96                 DQ
P 97                 63 12 72 36
P 98                 67 56 57 21
P 99                 48 68 26 52
P100                 DQ
P101                 35 79 27 18
P102                 91 48 85 85
P103                 77 45 10 30
P104                 15 95 32 DQ
P105                 37 23 37 71
P106                 56 42 20 36
P107                 88 58 63 59
P108                 81 DQ
P109*                19 DQ
P110                 67 22 76 18
P111                 80 DQ
P112                 DQ
P113                 15 54 DQ
P114                 40 99 88 70
P115*                74 44 79 17
P116                 84 61 32 27
P117                 33 91 50 51
P118                 89 11 97 49
P119*                60 29 90 55
P120                 62 75 80 78
P121                 73 49 62 57
P122                 95 82 27 55
P123                 18 17 80 83
P124                 29 65 69 DQ
P125                 14 34 41 90
P126                 17 63 DQ
P127                 46 80 65 97
P128                 93 50 68 DQ
P129                 14 95 84 21
P130                 36 35 42 69
P131                 34 99 71 63
P132*                32 86 50 51
P133*                36 42 47 16
P134                 39 70 74 54
P135                 99 56 59 54
P136                 57 95 83 39
P137*                41 35 76 97
P138                 DQ
P139                 61 DQ
P140                 99 47 50 86
P141                 81 97 33 17
P142*                DQ
P143                 88 50 DQ
P144                 48 11 73 DQ
According to your AC output, you produce the following output:

Code: Select all

Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won
-----------------------------------------------------------------------
P 58                 1         42   28   13   14   97        $  7055.22
P  9                 2         31   17   41   30   119       $  4455.93
P 60*                3         60   26   20   18   124
P133*                4         36   42   47   16   141
P 45*                5         12   43   29   58   142
P 83                 6         12   23   71   38   144       $  5198.58
P 32                 7         78   42   11   16   147       $  7797.88
P 13                 8         14   45   74   18   151       $  5198.58
P106                 9         56   42   20   36   154       $  4827.26
P 82                 10        75   27   24   29   155       $  5569.91
P 86                 11T       36   22   31   70   159       $  5012.92
P101                 11T       35   79   27   18   159       $  5012.92
P103                 13        77   45   10   30   162       $  5198.58
P 90*                14        44   29   58   33   164
P 23                 15        15   29   48   73   165       $  2599.29
P105                 16        37   23   37   71   168       $  5198.58
P 67                 17        57   64   11   37   169       $  5198.58
P 54                 18        13   59   62   37   171       $  2599.29
P 95                 19        22   38   55   58   173       $  8169.21
P 18*                20        74   39   31   31   175
P 91                 21        59   12   65   42   178       $  5941.24
P125                 22        14   34   41   90   179       $  4084.60
P 81                 23T       45   54   55   28   182       $  4455.93
P130                 23T       36   35   42   69   182       $  4455.93
P 97                 25T       63   12   72   36   183       $  5384.25
P110                 25T       67   22   76   18   183       $  5384.25
P 41                 27        98   21   45   24   188       $  7055.22
P 52*                28        25   85   37   46   193
P 99                 29        48   68   26   52   194       $  5198.58
P 48                 30        70   10   52   63   195       $  4084.60
P 87                 31T       20   73   95   10   198       $  6683.89
P123                 31T       18   17   80   83   198       $  6683.89
P 42                 33T       44   21   95   43   203       $  5755.58
P 73                 33T       26   80   58   39   203       $  5755.58
P 36                 35        59   18   30   99   206       $  7426.55
P 77*                36        22   12   79   97   210
P 88                 36        24   84   51   51   210       $  3713.28
P 39*                38        32   33   49   99   213
P115*                39        74   44   79   17   214
P129                 39        14   95   84   21   214       $  4827.26
P 74*                41        44   73   87   11   215
P132*                42        32   86   50   51   219
P 46                 43        69   13   68   73   223       $  4827.26
P 47*                44        43   48   39   97   227
P 78*                44        18   95   66   48   227
P119*                46        60   29   90   55   234
P134                 47        39   70   74   54   237       $  5941.24
P 92                 48        26   86   55   71   238       $  6312.57
P121                 49        73   49   62   57   241       $  4084.60
P 65                 50        78   42   99   25   244       $  4827.26
P 34                 51T       89   27   91   39   246       $  5941.24
P118                 51T       89   11   97   49   246       $  5941.24
P 62                 53T       73   48   75   51   247       $  6683.90
P 70                 53T       14   94   96   43   247       $  6683.90
P137*                55        41   35   76   97   249
P 35                 56        40   56   71   96   263       $  3341.95
P  4                           66   15   13        DQ
P 57*                          19   11   88        DQ
P 37                           21   45   53        DQ
P 19                           39   29   53        DQ
P144                           48   11   73        DQ
P104                           15   95   32        DQ
P124                           29   65   69        DQ
P 33                           47   69   60        DQ
P113                           15   54             DQ
P 31*                          13   63             DQ
P126                           17   63             DQ
P 89                           47   38             DQ
P 44                           69   21             DQ
P 17*                          60   44             DQ
But my WA code produces the following

Code: Select all

Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won
-----------------------------------------------------------------------
P 58                 1         42   28   13   14   97        $  7055.22
P  9                 2         31   17   41   30   119       $  4455.93
P 60*                3         60   26   20   18   124
P133*                4         36   42   47   16   141
P 45*                5         12   43   29   58   142
P 83                 6         12   23   71   38   144       $  5198.59
P 32                 7         78   42   11   16   147       $  7797.88
P 13                 8         14   45   74   18   151       $  5198.59
P106                 9         56   42   20   36   154       $  4827.26
P 82                 10        75   27   24   29   155       $  5569.91
P 86                 11T       36   22   31   70   159       $  5012.92
P101                 11T       35   79   27   18   159       $  5012.92
P103                 13        77   45   10   30   162       $  5198.59
P 90*                14        44   29   58   33   164
P 23                 15        15   29   48   73   165       $  2599.29
P105                 16        37   23   37   71   168       $  5198.59
P 67                 17        57   64   11   37   169       $  5198.59
P 54                 18        13   59   62   37   171       $  2599.29
P 95                 19        22   38   55   58   173       $  8169.21
P 18*                20        74   39   31   31   175
P 91                 21        59   12   65   42   178       $  5941.24
P125                 22        14   34   41   90   179       $  4084.60
P 81                 23T       45   54   55   28   182       $  4455.93
P130                 23T       36   35   42   69   182       $  4455.93
P 97                 25T       63   12   72   36   183       $  5384.25
P110                 25T       67   22   76   18   183       $  5384.25
P 41                 27        98   21   45   24   188       $  7055.22
P 52*                28        25   85   37   46   193
P 99                 29        48   68   26   52   194       $  5198.59
P 48                 30        70   10   52   63   195       $  4084.60
P 87                 31T       20   73   95   10   198       $  6683.89
P123                 31T       18   17   80   83   198       $  6683.89
P 42                 33T       44   21   95   43   203       $  5755.58
P 73                 33T       26   80   58   39   203       $  5755.58
P 36                 35        59   18   30   99   206       $  7426.55
P 77*                36        22   12   79   97   210
P 88                 36        24   84   51   51   210       $  3713.28
P 39*                38        32   33   49   99   213
P115*                39        74   44   79   17   214
P129                 39        14   95   84   21   214       $  4827.26
P 74*                41        44   73   87   11   215
P132*                42        32   86   50   51   219
P 46                 43        69   13   68   73   223       $  4827.26
P 47*                44        43   48   39   97   227
P 78*                44        18   95   66   48   227
P119*                46        60   29   90   55   234
P134                 47        39   70   74   54   237       $  5941.24
P 92                 48        26   86   55   71   238       $  6312.57
P121                 49        73   49   62   57   241       $  4084.60
P 65                 50        78   42   99   25   244       $  4827.26
P 34                 51T       89   27   91   39   246       $  5941.24
P118                 51T       89   11   97   49   246       $  5941.24
P 62                 53T       73   48   75   51   247       $  6683.90
P 70                 53T       14   94   96   43   247       $  6683.90
P137*                55        41   35   76   97   249
P 35                 56        40   56   71   96   263       $  3341.95
P  4                           66   15   13        DQ
P 57*                          19   11   88        DQ
P 37                           21   45   53        DQ
P 19                           39   29   53        DQ
P144                           48   11   73        DQ
P104                           15   95   32        DQ
P124                           29   65   69        DQ
P 33                           47   69   60        DQ
P113                           15   54             DQ
P 31*                          13   63             DQ
P126                           17   63             DQ
P 89                           47   38             DQ
P 44                           69   21             DQ
P 17*                          60   44             DQ
As you can see, our values are exactly the same for everything, with the exception for the following prize numbers. Your AC output displays 5198.58 while my WA output displays 5198.59

Did you perform any particular operation that affected precision? I'm thinking this is what's causing my WA.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 207 - PGA Tour Prize Money

Post by brianfry713 »

I updated http://www.udebug.com/UVa/207
It should be 5198.59
Post your updated code.
Check input and AC output for thousands of problems on uDebug!
r2ro
New poster
Posts: 38
Joined: Thu Sep 25, 2008 9:26 am

Re: 207 - PGA Tour Prize Money

Post by r2ro »

Here's my updated code.

Code: Select all

Accepted
Last edited by r2ro on Sun Sep 28, 2014 2:50 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 207 - PGA Tour Prize Money

Post by brianfry713 »

Input:

Code: Select all

1

663133.91
1.3000
1.1000
1.3000
2.1000
1.3000
1.8000
1.8000
1.2000
1.4000
1.6000
1.2000
1.4000
0.8000
1.6000
0.8000
1.7000
0.8000
2.0000
1.2000
0.9000
2.0000
2.1000
1.8000
1.4000
1.8000
1.1000
1.1000
1.8000
1.3000
1.4000
0.8000
1.5000
2.4000
1.1000
0.9000
1.8000
1.3000
0.9000
1.7000
1.4000
1.4000
0.9000
1.2000
1.6000
2.3000
1.2000
1.6000
2.0000
1.7000
1.1000
1.0000
1.2000
1.5000
1.9000
1.8000
1.3000
1.4000
1.7000
1.5000
1.2000
1.2000
1.9000
1.5000
1.1000
1.7000
1.2000
1.2000
1.4000
1.1000
1.3000
82
P  1                 DQ
P  2                 63 39 58 DQ
P  3                 37 25 90 59
P  4                 DQ
P  5                 43 19 81 41
P  6                 24 64 21 12
P  7                 69 75 DQ
P  8                 50 50 57 45
P  9                 DQ
P 10                 12 78 55 83
P 11                 94 34 64 46
P 12                 83 56 32 DQ
P 13                 17 88 51 DQ
P 14                 99 35 39 38
P 15*                DQ
P 16                 74 63 DQ
P 17                 36 29 31 15
P 18                 28 80 19 99
P 19                 90 67 33 32
P 20                 85 63 DQ
P 21                 DQ
P 22                 91 32 27 17
P 23                 78 94 68 28
P 24                 51 DQ
P 25                 36 92 88 22
P 26*                13 73 59 50
P 27                 29 27 69 74
P 28                 77 96 DQ
P 29                 85 51 21 98
P 30                 71 DQ
P 31                 60 84 42 87
P 32                 DQ
P 33                 56 41 45 15
P 34*                19 10 DQ
P 35*                61 DQ
P 36*                61 76 40 98
P 37                 78 96 60 90
P 38*                58 15 56 17
P 39                 31 82 46 43
P 40                 51 68 20 34
P 41*                24 32 97 DQ
P 42                 57 33 DQ
P 43*                65 21 92 82
P 44*                23 85 23 82
P 45                 83 92 DQ
P 46                 96 70 23 74
P 47*                47 49 37 10
P 48                 47 42 70 17
P 49                 99 39 43 74
P 50                 73 39 DQ
P 51                 69 59 DQ
P 52                 69 88 87 DQ
P 53                 25 56 42 95
P 54                 19 97 96 85
P 55                 64 50 40 59
P 56*                98 70 29 49
P 57                 99 73 47 83
P 58                 24 16 47 65
P 59*                37 70 52 32
P 60                 96 74 45 37
P 61                 28 61 80 74
P 62                 20 37 DQ
P 63                 70 84 10 37
P 64                 63 DQ
P 65*                49 80 76 87
P 66*                61 32 78 33
P 67                 55 90 57 26
P 68                 79 80 66 77
P 69                 70 24 DQ
P 70*                44 19 57 62
P 71                 DQ
P 72                 17 71 80 DQ
P 73                 DQ
P 74                 89 56 98 32
P 75*                12 16 11 76
P 76                 DQ
P 77                 35 44 31 98
P 78*                97 25 40 86
P 79                 96 20 75 14
P 80                 29 10 72 83
P 81                 97 92 78 10
P 82*                33 41 10 DQ
AC output:

Code: Select all

Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won
-----------------------------------------------------------------------
P 17                 1         36   29   31   15   111       $  8620.74
P 75*                2         12   16   11   76   115
P  6                 3         24   64   21   12   121       $  7294.47
P 47*                4         47   49   37   10   143
P 38*                5         58   15   56   17   146
P 58                 6         24   16   47   65   152       $  8620.74
P 33                 7         56   41   45   15   157       $ 13925.81
P 22                 8         91   32   27   17   167       $  8620.74
P 40                 9         51   68   20   34   173       $ 11936.41
P 48                 10        47   42   70   17   176       $ 11936.41
P 70*                11        44   19   57   62   182
P  5                 12        43   19   81   41   184       $  7957.61
P 59*                13        37   70   52   32   191
P 80                 14        29   10   72   83   194       $  9283.87
P 26*                15        13   73   59   50   195
P 27                 16        29   27   69   74   199       $ 10610.14
P 63                 17        70   84   10   37   201       $  7957.61
P  8                 18T       50   50   57   45   202       $  7294.47
P 39                 18T       31   82   46   43   202       $  7294.47
P 66*                20        61   32   78   33   204
P 79                 21        96   20   75   14   205       $ 10610.14
P 77                 22        35   44   31   98   208       $  5305.07
P  3                 23T       37   25   90   59   211       $  8289.17
P 14                 23T       99   35   39   38   211       $  8289.17
P 44*                25        23   85   23   82   213
P 55                 25        64   50   40   59   213       $ 13262.68
P 53                 27        25   56   42   95   218       $  7957.61
P 19                 28        90   67   33   32   222       $  5968.21
P 18                 29        28   80   19   99   226       $ 13262.68
P 10                 30T       12   78   55   83   228       $ 12931.11
P 67                 30T       55   90   57   26   228       $ 12931.11
P 11                 32T       94   34   64   46   238       $ 10610.14
P 25                 32T       36   92   88   22   238       $ 10610.14
P 61                 34        28   61   80   74   243       $  7294.47
P 56*                35        98   70   29   49   246
P 78*                36        97   25   40   86   248
P 60                 37        96   74   45   37   252       $  7294.47
P 29                 38T       85   51   21   98   255       $ 10278.58
P 49                 38T       99   39   43   74   255       $ 10278.58
P 43*                40        65   21   92   82   260
P 46                 41        96   70   23   74   263       $  9283.87
P 23                 42        78   94   68   28   268       $  5305.07
P 31                 43        60   84   42   87   273       $  9947.01
P 36*                44        61   76   40   98   275
P 74                 44        89   56   98   32   275       $ 15915.21
P 81                 46        97   92   78   10   277       $  7294.47
P 65*                47        49   80   76   87   292
P 54                 48        19   97   96   85   297       $  5968.21
P 57                 49T       99   73   47   83   302       $ 10278.58
P 68                 49T       79   80   66   77   302       $ 10278.58
P 37                 51        78   96   60   90   324       $  5968.21
P 82*                          33   41   10        DQ
P 41*                          24   32   97        DQ
P 13                           17   88   51        DQ
P  2                           63   39   58        DQ
P 72                           17   71   80        DQ
P 12                           83   56   32        DQ
P 52                           69   88   87        DQ
P 34*                          19   10             DQ
P 62                           20   37             DQ
P 42                           57   33             DQ
P 69                           70   24             DQ
P 50                           73   39             DQ
P 51                           69   59             DQ
P 16                           74   63             DQ
P  7                           69   75             DQ
P 20                           85   63             DQ
P 28                           77   96             DQ
P 45                           83   92             DQ
Your code is seg faulting on line 298, lp = 69, heap[69] = NULL.
Check input and AC output for thousands of problems on uDebug!
r2ro
New poster
Posts: 38
Joined: Thu Sep 25, 2008 9:26 am

Re: 207 - PGA Tour Prize Money

Post by r2ro »

I found my mistake...It was a very stupid one indeed.

Thanks for your help, brianfry713. :)
odinni
New poster
Posts: 5
Joined: Tue Feb 03, 2015 1:28 pm

Re: 207 - PGA Tour Prize Money

Post by odinni »

Hi there,
I'm trying to solve problem 207, but got many WA.
My code could produce exactly the same output of all test input I found here and uDebug.

Code: Select all

#include<stdio.h>
//#include<conio.h>
#include<string.h>
int parseInt(char *shot)
{
	int a,b,c=0;

	if(*shot!='D')
		for(a=strlen(shot)-1,b=1;a>-1;a--,b*=10)
			c+=(*(shot+a)-48)*b;
	else c=-1;

	return c;
}

int isAmateur(char *name)
{
	int a;

	for(a=19;*(name+a)==' ';a--);

	if(*(name+a)=='*')
		return 1;
	else return 0;
}

int main()
{
	//clrscr();

	//FILE *fp=fopen("p207.txt","r");
	int caseNumber,a,b,playerNumber,lp,c,temp,d,numberPerRank[145],
		e,scores[144][4],rc[144],fh[144],total[144],isa[144],rank[144];
	double purse,rankMoneyRatio[70],tempDb,rankMoney[145];
	char shot[3],name[144][21],tn[21];

	//fscanf(fp,"%d",&caseNumber);
		  scanf("%d",&caseNumber);

	for(a=0;a<caseNumber;a++)
	{
		lp=0;

		if(a>0)
			printf("\n");

		//fscanf(fp,"%lf",&purse);
			  scanf("%lf",&purse);

		for(b=0;b<70;b++)
			//fscanf(fp,"%lf",&rankMoneyRatio[b]);
				  scanf("%lf",&rankMoneyRatio[b]);

		//fscanf(fp,"%d\n",&playerNumber);
			  scanf("%d\n",&playerNumber);

		for(b=0;b<playerNumber;b++)
		{
			for(c=0;c<20;c++)
				//fscanf(fp,"%c",&name[lp][c]);
					  scanf("%c",&name[lp][c]);
			name[lp][20]='\0';

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				continue;
			}
			scores[lp][0]=fh[lp]=total[lp]=c;
			rc[lp]=1;

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				continue;
			}
			scores[lp][1]=c;
			rc[lp]=2;
			fh[lp]+=c;
			total[lp]+=c;

			isa[lp]=isAmateur(name[lp]);

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				lp++;
				continue;
			}
			scores[lp][2]=c;
			rc[lp]=3;
			total[lp]+=c;

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			//fscanf(fp,"%c",&shot[0]);
				  scanf("%c",&shot[0]);
			if(c==-1)
			{
				lp++;
				continue;
			}
			scores[lp][3]=c;
			rc[lp]=4;
			total[lp++]+=c;
		}

		for(b=0;b<lp-1;b++)
			for(c=b+1;c<lp;c++)
				if(fh[b]>fh[c])
				{
					strcpy(tn,name[b]);
					strcpy(name[b],name[c]);
					strcpy(name[c],tn);

					for(e=0;e<4;e++)
					{
						d=scores[b][e];
						scores[b][e]=scores[c][e];
						scores[c][e]=d;
					}

					d=rc[b];
					rc[b]=rc[c];
					rc[c]=d;

					d=fh[b];
					fh[b]=fh[c];
					fh[c]=d;

					d=total[b];
					total[b]=total[c];
					total[c]=d;

					d=isa[b];
					isa[b]=isa[c];
					isa[c]=d;
				}

		if(lp>70)
		{
			for(b=70;b<lp&&fh[b]==fh[69];b++);
			lp=b;
		}

		for(b=0;b<lp-1;b++)
			for(c=b+1;c<lp;c++)
				if(rc[b]<rc[c]||
				   (rc[b]==rc[c]&&total[b]>total[c])||
				   (rc[b]==rc[c]&&total[b]==total[c]&&
					strcmp(name[b],name[c])>0))
				{
					strcpy(tn,name[b]);
					strcpy(name[b],name[c]);
					strcpy(name[c],tn);

					for(e=0;e<4;e++)
					{
						d=scores[b][e];
						scores[b][e]=scores[c][e];
						scores[c][e]=d;
					}

					d=rc[b];
					rc[b]=rc[c];
					rc[c]=d;

					d=total[b];
					total[b]=total[c];
					total[c]=d;

					d=isa[b];
					isa[b]=isa[c];
					isa[c]=d;
				}

		rank[0]=e=1;
		temp=d=0;
		if(!isa[0])
		{
			tempDb=rankMoneyRatio[0];
			temp=d=1;
		}
		for(b=1,c=2;b<lp;b++,c++)
			if(rc[b]==4)
				if(total[b]!=total[b-1])
				{
					rank[b]=e=c;
					numberPerRank[rank[b-1]]=temp;
					if(temp>0)
						rankMoney[rank[b-1]]=tempDb/temp*purse/100;
					temp=tempDb=0;

					if(d<70&&!isa[b])
					{
						temp=1;
						tempDb=rankMoneyRatio[d++];
					}
				}
				else
				{
					rank[b]=rank[b-1];
					if(!isa[b])
					{
						temp++;
						if(d<70)
							tempDb+=rankMoneyRatio[d++];
					}
				}
		numberPerRank[e]=temp;
		if(temp>0)
			rankMoney[e]=tempDb/temp*purse/100;

		printf("Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won\n");
		printf("-----------------------------------------------------------------------\n");

		for(b=0;b<lp;b++)
		{
			printf("%s ",name[b]);

			if(rc[b]==4)
			{
				printf("%d",rank[b]);
				temp=c=0;
				if(numberPerRank[rank[b]]>1&&!isa[b])
				{
					printf("T");
					temp=1;
				}
				c=rank[b];
				while(c!=0)
				{
					c/=10;
					temp++;
				}
				for(c=temp;c<10;c++)
					printf(" ");
			}
			else printf("          ");

			for(d=0;d<4;d++)
				if(d<rc[b])
				{
					printf("%d ",scores[b][d]);
					if(scores[b][d]>99)
						printf(" ");
					else if(scores[b][d]>9)
						printf("  ");
					else printf("   ");
				}
				else printf("     ");

			if(rc[b]==4)
			{
				printf("%d",total[b]);

				if(numberPerRank[rank[b]]>0&&!isa[b])
				{
					temp=0;
					c=total[b];
					while(c!=0)
					{
						c/=10;
						temp++;
					}
					for(c=temp;c<10;c++)
						printf(" ");
					printf("$%9.2lf\n",rankMoney[rank[b]]);
				}
				else printf("\n");
			}
			else printf("DQ\n");
		}
	}

	//fclose(fp);

	return 0;
}
Could anyone please give me some suggestions??
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 207 - PGA Tour Prize Money

Post by brianfry713 »

I see some small differences between our outputs for the random uDebug input.
My code prints a space at the end of a line when the total score < 100.
It looks like your code also has some precision errors. Try adding a small number like 1e-8 to a floating point value when you print it.
Check input and AC output for thousands of problems on uDebug!
odinni
New poster
Posts: 5
Joined: Tue Feb 03, 2015 1:28 pm

Re: 207 - PGA Tour Prize Money

Post by odinni »

Hi, brianfry713, thanks~~
I added 1e-8(=0.0000001f) to the floating value before printed.
But still got WA... :-?

Code: Select all

rankMoney[e]=tempDb/temp*purse/100+.0000001f;
BTW, I use an ancient runtime: Borland Turbo C++ 3.0 ,
and whether 1e-8 added or not, it always gives exactly the same output as uDebug output.
Could you please paste the whole output of my code executed by your environment.
To let me know where the precision error occured... :)
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 207 - PGA Tour Prize Money

Post by brianfry713 »

http://ideone.com/YpgWzo

Remove the change you suggested on line 234 and change line 290 to:
printf("$%9.2lf\n",rankMoney[rank] + 1e-8);

Also change your code to print a space at the end of a line when the total score < 100.

Post your full code with these updates.
Check input and AC output for thousands of problems on uDebug!
odinni
New poster
Posts: 5
Joined: Tue Feb 03, 2015 1:28 pm

Re: 207 - PGA Tour Prize Money

Post by odinni »

Hi brianfry713,
Thanks for your help again.
Here is my updated code.

...but still WA...

Code: Select all

#include<stdio.h>
//#include<conio.h>
#include<string.h>
int parseInt(char *shot)
{
	int a,b,c=0;

	if(*shot!='D')
		for(a=strlen(shot)-1,b=1;a>-1;a--,b*=10)
			c+=(*(shot+a)-48)*b;
	else c=-1;

	return c;
}

int isAmateur(char *name)
{
	int a;

	for(a=19;*(name+a)==' ';a--);

	if(*(name+a)=='*')
		return 1;
	else return 0;
}

int main()
{
	//clrscr();

	//FILE *fp=fopen("p207.txt","r");
	int caseNumber,a,b,playerNumber,lp,c,temp,d,numberPerRank[145],
		e,scores[144][4],rc[144],fh[144],total[144],isa[144],rank[144];
	double purse,rankMoneyRatio[70],tempDb,rankMoney[145];
	char shot[3],name[144][21],tn[21];

	//fscanf(fp,"%d",&caseNumber);
		  scanf("%d",&caseNumber);

	for(a=0;a<caseNumber;a++)
	{
		lp=0;

		if(a>0)
			printf("\n");

		//fscanf(fp,"%lf",&purse);
			  scanf("%lf",&purse);

		for(b=0;b<70;b++)
			//fscanf(fp,"%lf",&rankMoneyRatio[b]);
				  scanf("%lf",&rankMoneyRatio[b]);

		//fscanf(fp,"%d\n",&playerNumber);
			  scanf("%d\n",&playerNumber);

		for(b=0;b<playerNumber;b++)
		{
			for(c=0;c<20;c++)
				//fscanf(fp,"%c",&name[lp][c]);
					  scanf("%c",&name[lp][c]);
			name[lp][20]='\0';

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				continue;
			}
			scores[lp][0]=fh[lp]=total[lp]=c;
			rc[lp]=1;

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				continue;
			}
			scores[lp][1]=c;
			rc[lp]=2;
			fh[lp]+=c;
			total[lp]+=c;

			isa[lp]=isAmateur(name[lp]);

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				lp++;
				continue;
			}
			scores[lp][2]=c;
			rc[lp]=3;
			total[lp]+=c;

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			//fscanf(fp,"%c",&shot[0]);
				  scanf("%c",&shot[0]);
			if(c==-1)
			{
				lp++;
				continue;
			}
			scores[lp][3]=c;
			rc[lp]=4;
			total[lp++]+=c;
		}

		for(b=0;b<lp-1;b++)
			for(c=b+1;c<lp;c++)
				if(fh[b]>fh[c])
				{
					strcpy(tn,name[b]);
					strcpy(name[b],name[c]);
					strcpy(name[c],tn);

					for(e=0;e<4;e++)
					{
						d=scores[b][e];
						scores[b][e]=scores[c][e];
						scores[c][e]=d;
					}

					d=rc[b];
					rc[b]=rc[c];
					rc[c]=d;

					d=fh[b];
					fh[b]=fh[c];
					fh[c]=d;

					d=total[b];
					total[b]=total[c];
					total[c]=d;

					d=isa[b];
					isa[b]=isa[c];
					isa[c]=d;
				}

		if(lp>70)
		{
			for(b=70;b<lp&&fh[b]==fh[69];b++);
			lp=b;
		}

		for(b=0;b<lp-1;b++)
			for(c=b+1;c<lp;c++)
				if(rc[b]<rc[c]||
				   (rc[b]==rc[c]&&total[b]>total[c])||
				   (rc[b]==rc[c]&&total[b]==total[c]&&
					strcmp(name[b],name[c])>0))
				{
					strcpy(tn,name[b]);
					strcpy(name[b],name[c]);
					strcpy(name[c],tn);

					for(e=0;e<4;e++)
					{
						d=scores[b][e];
						scores[b][e]=scores[c][e];
						scores[c][e]=d;
					}

					d=rc[b];
					rc[b]=rc[c];
					rc[c]=d;

					d=total[b];
					total[b]=total[c];
					total[c]=d;

					d=isa[b];
					isa[b]=isa[c];
					isa[c]=d;
				}

		rank[0]=e=1;
		temp=d=0;
		if(!isa[0])
		{
			tempDb=rankMoneyRatio[0];
			temp=d=1;
		}
		for(b=1,c=2;b<lp;b++,c++)
			if(rc[b]==4)
				if(total[b]!=total[b-1])
				{
					rank[b]=e=c;
					numberPerRank[rank[b-1]]=temp;
					if(temp>0)
						rankMoney[rank[b-1]]=tempDb/temp*purse/100;
					temp=tempDb=0;

					if(d<70&&!isa[b])
					{
						temp=1;
						tempDb=rankMoneyRatio[d++];
					}
				}
				else
				{
					rank[b]=rank[b-1];
					if(!isa[b])
					{
						temp++;
						if(d<70)
							tempDb+=rankMoneyRatio[d++];
					}
				}
		numberPerRank[e]=temp;
		if(temp>0)
			rankMoney[e]=tempDb/temp*purse/100;

		printf("Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won\n");
		printf("-----------------------------------------------------------------------\n");

		for(b=0;b<lp;b++)
		{
			printf("%s ",name[b]);

			if(rc[b]==4)
			{
				printf("%d",rank[b]);
				temp=c=0;
				if(numberPerRank[rank[b]]>1&&!isa[b])
				{
					printf("T");
					temp=1;
				}
				c=rank[b];
				while(c!=0)
				{
					c/=10;
					temp++;
				}
				for(c=temp;c<10;c++)
					printf(" ");
			}
			else printf("          ");

			for(d=0;d<4;d++)
				if(d<rc[b])
				{
					printf("%d ",scores[b][d]);
					if(scores[b][d]>99)
						printf(" ");
					else if(scores[b][d]>9)
						printf("  ");
					else printf("   ");
				}
				else printf("     ");

			if(rc[b]==4)
			{
				printf("%d",total[b]);

				if(total[b]<100)
					printf(" ");

				if(numberPerRank[rank[b]]>0&&!isa[b])
				{
					temp=0;
					c=total[b];
					while(c!=0)
					{
						c/=10;
						temp++;
					}
					for(c=temp;c<10;c++)
						printf(" ");
					printf("$%9.2lf\n",rankMoney[rank[b]]+1e-8);
				}
				else printf("\n");
			}
			else printf("DQ\n");
		}
	}

	//fclose(fp);

	return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 207 - PGA Tour Prize Money

Post by brianfry713 »

If the total score is under 100 and the player did not win money my AC code prints a space at the end of the line.
If the total score is under 100 and the player did win money your code is printing one space too many between the total score and the $.
Check input and AC output for thousands of problems on uDebug!
odinni
New poster
Posts: 5
Joined: Tue Feb 03, 2015 1:28 pm

Re: 207 - PGA Tour Prize Money

Post by odinni »

Hi brianfry713,
I fixed the mistake of trailing space when total score under 100.
But still WA.....
Here is my updated code.

Code: Select all

#include<stdio.h>
//#include<conio.h>
#include<string.h>
int parseInt(char *shot)
{
	int a,b,c=0;

	if(*shot!='D')
		for(a=strlen(shot)-1,b=1;a>-1;a--,b*=10)
			c+=(*(shot+a)-48)*b;
	else c=-1;

	return c;
}

int isAmateur(char *name)
{
	int a;

	for(a=19;*(name+a)==' ';a--);

	if(*(name+a)=='*')
		return 1;
	else return 0;
}

int main()
{
	//clrscr();

	//FILE *fp=fopen("p207.txt","r");
	int caseNumber,a,b,playerNumber,lp,c,temp,d,numberPerRank[145],
		e,scores[144][4],rc[144],fh[144],total[144],isa[144],rank[144];
	double purse,rankMoneyRatio[70],tempDb,rankMoney[145];
	char shot[3],name[144][21],tn[21];

	//fscanf(fp,"%d",&caseNumber);
		  scanf("%d",&caseNumber);

	for(a=0;a<caseNumber;a++)
	{
		lp=0;

		if(a>0)
			printf("\n");

		//fscanf(fp,"%lf",&purse);
			  scanf("%lf",&purse);

		for(b=0;b<70;b++)
			//fscanf(fp,"%lf",&rankMoneyRatio[b]);
				  scanf("%lf",&rankMoneyRatio[b]);

		//fscanf(fp,"%d\n",&playerNumber);
			  scanf("%d\n",&playerNumber);

		for(b=0;b<playerNumber;b++)
		{
			for(c=0;c<20;c++)
				//fscanf(fp,"%c",&name[lp][c]);
					  scanf("%c",&name[lp][c]);
			name[lp][20]='\0';

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				continue;
			}
			scores[lp][0]=fh[lp]=total[lp]=c;
			rc[lp]=1;

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				continue;
			}
			scores[lp][1]=c;
			rc[lp]=2;
			fh[lp]+=c;
			total[lp]+=c;

			isa[lp]=isAmateur(name[lp]);

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			if(c==-1)
			{
				do
				{
					//fscanf(fp,"%c",&shot[0]);
						  scanf("%c",&shot[0]);
				}while(shot[0]!='\n');
				lp++;
				continue;
			}
			scores[lp][2]=c;
			rc[lp]=3;
			total[lp]+=c;

			//fscanf(fp,"%s",shot);
				  scanf("%s",shot);
			c=parseInt(shot);
			//fscanf(fp,"%c",&shot[0]);
				  scanf("%c",&shot[0]);
			if(c==-1)
			{
				lp++;
				continue;
			}
			scores[lp][3]=c;
			rc[lp]=4;
			total[lp++]+=c;
		}

		for(b=0;b<lp-1;b++)
			for(c=b+1;c<lp;c++)
				if(fh[b]>fh[c])
				{
					strcpy(tn,name[b]);
					strcpy(name[b],name[c]);
					strcpy(name[c],tn);

					for(e=0;e<4;e++)
					{
						d=scores[b][e];
						scores[b][e]=scores[c][e];
						scores[c][e]=d;
					}

					d=rc[b];
					rc[b]=rc[c];
					rc[c]=d;

					d=fh[b];
					fh[b]=fh[c];
					fh[c]=d;

					d=total[b];
					total[b]=total[c];
					total[c]=d;

					d=isa[b];
					isa[b]=isa[c];
					isa[c]=d;
				}

		if(lp>70)
		{
			for(b=70;b<lp&&fh[b]==fh[69];b++);
			lp=b;
		}

		for(b=0;b<lp-1;b++)
			for(c=b+1;c<lp;c++)
				if(rc[b]<rc[c]||
				   (rc[b]==rc[c]&&total[b]>total[c])||
				   (rc[b]==rc[c]&&total[b]==total[c]&&
					strcmp(name[b],name[c])>0))
				{
					strcpy(tn,name[b]);
					strcpy(name[b],name[c]);
					strcpy(name[c],tn);

					for(e=0;e<4;e++)
					{
						d=scores[b][e];
						scores[b][e]=scores[c][e];
						scores[c][e]=d;
					}

					d=rc[b];
					rc[b]=rc[c];
					rc[c]=d;

					d=total[b];
					total[b]=total[c];
					total[c]=d;

					d=isa[b];
					isa[b]=isa[c];
					isa[c]=d;
				}

		rank[0]=e=1;
		temp=d=0;
		if(!isa[0])
		{
			tempDb=rankMoneyRatio[0];
			temp=d=1;
		}
		for(b=1,c=2;b<lp;b++,c++)
			if(rc[b]==4)
				if(total[b]!=total[b-1])
				{
					rank[b]=e=c;
					numberPerRank[rank[b-1]]=temp;
					if(temp>0)
						rankMoney[rank[b-1]]=tempDb/temp*purse/100;
					temp=tempDb=0;

					if(d<70&&!isa[b])
					{
						temp=1;
						tempDb=rankMoneyRatio[d++];
					}
				}
				else
				{
					rank[b]=rank[b-1];
					if(!isa[b])
					{
						temp++;
						if(d<70)
							tempDb+=rankMoneyRatio[d++];
					}
				}
		numberPerRank[e]=temp;
		if(temp>0)
			rankMoney[e]=tempDb/temp*purse/100;

		printf("Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won\n");
		printf("-----------------------------------------------------------------------\n");

		for(b=0;b<lp;b++)
		{
			printf("%s ",name[b]);

			if(rc[b]==4)
			{
				printf("%d",rank[b]);
				temp=c=0;
				if(numberPerRank[rank[b]]>1&&!isa[b])
				{
					printf("T");
					temp=1;
				}
				c=rank[b];
				while(c!=0)
				{
					c/=10;
					temp++;
				}
				for(c=temp;c<10;c++)
					printf(" ");
			}
			else printf("          ");

			for(d=0;d<4;d++)
				if(d<rc[b])
				{
					printf("%d ",scores[b][d]);
					if(scores[b][d]>99)
						printf(" ");
					else if(scores[b][d]>9)
						printf("  ");
					else printf("   ");
				}
				else printf("     ");

			if(rc[b]==4)
			{
				printf("%d",total[b]);

				if(numberPerRank[rank[b]]>0&&!isa[b])
				{
					temp=0;
					c=total[b];
					while(c!=0)
					{
						c/=10;
						temp++;
					}
					for(c=temp;c<10;c++)
						printf(" ");
					printf("$%9.2lf\n",rankMoney[rank[b]]+1e-8);
				}
				else
				{
					if(total[b]<100)
						printf(" ");
					printf("\n");
				}
			}
			else printf("DQ\n");
		}
	}

	//fclose(fp);

	return 0;
}
odinni
New poster
Posts: 5
Joined: Tue Feb 03, 2015 1:28 pm

Re: 207 - PGA Tour Prize Money

Post by odinni »

Hi brianfry713,
I got AC finally..... :D

But I want to reveal something wrong with the uDebug.
I tried the input I created:

Code: Select all

1

686211.33
2.2000
1.0000
1.0000
1.9000
1.5000
1.2000
1.2000
0.9000
1.1000
2.4000
1.3000
2.0000
1.8000
1.6000
1.5000
1.9000
1.1000
0.8000
0.9000
0.9000
1.8000
2.0000
1.0000
1.0000
0.9000
2.2000
1.3000
1.1000
1.5000
1.3000
1.4000
1.5000
1.0000
1.1000
1.5000
1.3000
1.0000
1.8000
1.2000
1.4000
1.6000
1.7000
1.8000
1.5000
1.1000
1.4000
1.3000
1.5000
1.1000
1.0000
1.7000
1.8000
1.3000
1.3000
1.1000
1.1000
0.9000
1.7000
1.7000
1.7000
1.4000
1.4000
1.5000
1.6000
1.5000
1.9000
1.2000
2.1000
1.5000
2.1000
80
P  1                 10 10 10 10
P  2                 11 11 11 11
P  3                 12 12 12 12
P  4                 13 13 13 13
P  5                 14 14 14 14
P  6                 15 15 15 15
P  7                 16 16 16 16
P  8                 17 17 17 17
P  9                 18 18 18 18
P 10                 19 19 19 19
P 11                 20 20 20 20
P 12                 21 21 21 21
P 13                 22 22 22 22
P 14                 23 23 23 23
P 15                 24 24 24 24
P 16                 25 25 25 25
P 17                 26 26 26 26
P 18                 27 27 27 27
P 19                 28 28 28 28
P 20                 29 29 29 29
P 21                 30 30 30 30
P 22                 31 31 31 31
P 23                 32 32 32 32
P 24                 33 33 33 33
P 25                 34 34 34 34
P 26                 35 35 35 35
P 27                 36 36 36 36
P 28                 37 37 37 37
P 29                 38 38 38 38
P 30                 39 39 39 39
P 31                 40 40 40 40
P 32                 41 41 41 41
P 33                 42 42 42 42
P 34                 43 43 43 43
P 35                 44 44 44 44
P 36                 45 45 45 45
P 37                 46 46 46 46
P 38                 47 47 47 47
P 39                 48 48 48 48
P 40                 49 49 49 49
P 41                 49 49 49 50
P 42                 49 49 49 51
P 43                 49 49 49 52
P 44                 49 49 49 53
P 45                 49 49 49 54
P 46                 49 49 49 55
P 47                 49 49 49 56
P 48                 49 49 49 57
P 49                 49 49 49 58
P 50                 49 49 49 59
P 51                 49 49 49 60
P 52                 49 49 49 61
P 53                 49 49 49 62
P 54                 49 49 49 63
P 55                 49 49 49 64
P 56                 49 49 49 65
P 57                 49 49 49 66
P 58                 49 49 49 67
P 59                 49 49 49 68
P 60                 49 49 49 69
P 61                 49 49 49 70
P 62                 49 49 49 71
P 63                 49 49 49 72
P 64                 49 49 49 73
P 65                 49 49 49 74
P 66                 49 49 49 75
P 67                 49 49 49 76
P 68                 49 49 49 77
P 69                 49 49 49 78
P 70                 49 49 49 79
P 71                 49 49 49 79
P 72                 49 49 49 80
P 73                 49 49 49 80
P 74                 49 49 49 81
P 75                 49 49 49 82
P 76                 49 49 49 83
P 77                 49 49 49 83
P 78                 49 49 49 84
P 79                 49 49 49 84
P 80                 49 49 49 84
Then, uDebug gave this output:

Code: Select all

Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won
-----------------------------------------------------------------------
P  1                 1         10   10   10   10   40        $ 15096.65
P  2                 2         11   11   11   11   44        $  6862.11
P  3                 3         12   12   12   12   48        $  6862.11
P  4                 4         13   13   13   13   52        $ 13038.02
P  5                 5         14   14   14   14   56        $ 10293.17
P  6                 6         15   15   15   15   60        $  8234.54
P  7                 7         16   16   16   16   64        $  8234.54
P  8                 8         17   17   17   17   68        $  6175.90
P  9                 9         18   18   18   18   72        $  7548.32
P 10                 10        19   19   19   19   76        $ 16469.07
P 11                 11        20   20   20   20   80        $  8920.75
P 12                 12        21   21   21   21   84        $ 13724.23
P 13                 13        22   22   22   22   88        $ 12351.80
P 14                 14        23   23   23   23   92        $ 10979.38
P 15                 15        24   24   24   24   96        $ 10293.17
P 16                 16        25   25   25   25   100       $ 13038.02
P 17                 17        26   26   26   26   104       $  7548.32
P 18                 18        27   27   27   27   108       $  5489.69
P 19                 19        28   28   28   28   112       $  6175.90
P 20                 20        29   29   29   29   116       $  6175.90
P 21                 21        30   30   30   30   120       $ 12351.80
P 22                 22        31   31   31   31   124       $ 13724.23
P 23                 23        32   32   32   32   128       $  6862.11
P 24                 24        33   33   33   33   132       $  6862.11
P 25                 25        34   34   34   34   136       $  6175.90
P 26                 26        35   35   35   35   140       $ 15096.65
P 27                 27        36   36   36   36   144       $  8920.75
P 28                 28        37   37   37   37   148       $  7548.32
P 29                 29        38   38   38   38   152       $ 10293.17
P 30                 30        39   39   39   39   156       $  8920.75
P 31                 31        40   40   40   40   160       $  9606.96
P 32                 32        41   41   41   41   164       $ 10293.17
P 33                 33        42   42   42   42   168       $  6862.11
P 34                 34        43   43   43   43   172       $  7548.32
P 35                 35        44   44   44   44   176       $ 10293.17
P 36                 36        45   45   45   45   180       $  8920.75
P 37                 37        46   46   46   46   184       $  6862.11
P 38                 38        47   47   47   47   188       $ 12351.80
P 39                 39        48   48   48   48   192       $  8234.54
P 40                 40        49   49   49   49   196       $  9606.96
P 41                 41        49   49   49   50   197       $ 10979.38
P 42                 42        49   49   49   51   198       $ 11665.59
P 43                 43        49   49   49   52   199       $ 12351.80
P 44                 44        49   49   49   53   200       $ 10293.17
P 45                 45        49   49   49   54   201       $  7548.32
P 46                 46        49   49   49   55   202       $  9606.96
P 47                 47        49   49   49   56   203       $  8920.75
P 48                 48        49   49   49   57   204       $ 10293.17
P 49                 49        49   49   49   58   205       $  7548.32
P 50                 50        49   49   49   59   206       $  6862.11
P 51                 51        49   49   49   60   207       $ 11665.59
P 52                 52        49   49   49   61   208       $ 12351.80
P 53                 53        49   49   49   62   209       $  8920.75
P 54                 54        49   49   49   63   210       $  8920.75
P 55                 55        49   49   49   64   211       $  7548.32
P 56                 56        49   49   49   65   212       $  7548.32
P 57                 57        49   49   49   66   213       $  6175.90
P 58                 58        49   49   49   67   214       $ 11665.59
P 59                 59        49   49   49   68   215       $ 11665.59
P 60                 60        49   49   49   69   216       $ 11665.59
P 61                 61        49   49   49   70   217       $  9606.96
P 62                 62        49   49   49   71   218       $  9606.96
P 63                 63        49   49   49   72   219       $ 10293.17
P 64                 64        49   49   49   73   220       $ 10979.38
P 65                 65        49   49   49   74   221       $ 10293.17
P 66                 66        49   49   49   75   222       $ 13038.02
P 67                 67        49   49   49   76   223       $  8234.54
P 68                 68        49   49   49   77   224       $ 14410.44
P 69                 69        49   49   49   78   225       $ 10293.17
P 70                 70T       49   49   49   79   226       $  7205.22
P 71                 70T       49   49   49   79   226       $  7205.22
P 72                 72T       49   49   49   80   227       $     0.00
P 73                 72T       49   49   49   80   227       $     0.00
P 74                 74        49   49   49   81   228       $     0.00
P 75                 75        49   49   49   82   229       $     0.00
P 76                 76T       49   49   49   83   230       $     0.00
P 77                 76T       49   49   49   83   230       $     0.00
P 78                 78T       49   49   49   84   231       $     0.00
P 79                 78T       49   49   49   84   231       $     0.00
P 80                 78T       49   49   49   84   231       $     0.00
But my AC code gave this output:

Code: Select all

Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won
-----------------------------------------------------------------------
P  1                 1         10   10   10   10   40        $ 15096.65
P  2                 2         11   11   11   11   44        $  6862.11
P  3                 3         12   12   12   12   48        $  6862.11
P  4                 4         13   13   13   13   52        $ 13038.02
P  5                 5         14   14   14   14   56        $ 10293.17
P  6                 6         15   15   15   15   60        $  8234.54
P  7                 7         16   16   16   16   64        $  8234.54
P  8                 8         17   17   17   17   68        $  6175.90
P  9                 9         18   18   18   18   72        $  7548.32
P 10                 10        19   19   19   19   76        $ 16469.07
P 11                 11        20   20   20   20   80        $  8920.75
P 12                 12        21   21   21   21   84        $ 13724.23
P 13                 13        22   22   22   22   88        $ 12351.80
P 14                 14        23   23   23   23   92        $ 10979.38
P 15                 15        24   24   24   24   96        $ 10293.17
P 16                 16        25   25   25   25   100       $ 13038.02
P 17                 17        26   26   26   26   104       $  7548.32
P 18                 18        27   27   27   27   108       $  5489.69
P 19                 19        28   28   28   28   112       $  6175.90
P 20                 20        29   29   29   29   116       $  6175.90
P 21                 21        30   30   30   30   120       $ 12351.80
P 22                 22        31   31   31   31   124       $ 13724.23
P 23                 23        32   32   32   32   128       $  6862.11
P 24                 24        33   33   33   33   132       $  6862.11
P 25                 25        34   34   34   34   136       $  6175.90
P 26                 26        35   35   35   35   140       $ 15096.65
P 27                 27        36   36   36   36   144       $  8920.75
P 28                 28        37   37   37   37   148       $  7548.32
P 29                 29        38   38   38   38   152       $ 10293.17
P 30                 30        39   39   39   39   156       $  8920.75
P 31                 31        40   40   40   40   160       $  9606.96
P 32                 32        41   41   41   41   164       $ 10293.17
P 33                 33        42   42   42   42   168       $  6862.11
P 34                 34        43   43   43   43   172       $  7548.32
P 35                 35        44   44   44   44   176       $ 10293.17
P 36                 36        45   45   45   45   180       $  8920.75
P 37                 37        46   46   46   46   184       $  6862.11
P 38                 38        47   47   47   47   188       $ 12351.80
P 39                 39        48   48   48   48   192       $  8234.54
P 40                 40        49   49   49   49   196       $  9606.96
P 41                 41        49   49   49   50   197       $ 10979.38
P 42                 42        49   49   49   51   198       $ 11665.59
P 43                 43        49   49   49   52   199       $ 12351.80
P 44                 44        49   49   49   53   200       $ 10293.17
P 45                 45        49   49   49   54   201       $  7548.32
P 46                 46        49   49   49   55   202       $  9606.96
P 47                 47        49   49   49   56   203       $  8920.75
P 48                 48        49   49   49   57   204       $ 10293.17
P 49                 49        49   49   49   58   205       $  7548.32
P 50                 50        49   49   49   59   206       $  6862.11
P 51                 51        49   49   49   60   207       $ 11665.59
P 52                 52        49   49   49   61   208       $ 12351.80
P 53                 53        49   49   49   62   209       $  8920.75
P 54                 54        49   49   49   63   210       $  8920.75
P 55                 55        49   49   49   64   211       $  7548.32
P 56                 56        49   49   49   65   212       $  7548.32
P 57                 57        49   49   49   66   213       $  6175.90
P 58                 58        49   49   49   67   214       $ 11665.59
P 59                 59        49   49   49   68   215       $ 11665.59
P 60                 60        49   49   49   69   216       $ 11665.59
P 61                 61        49   49   49   70   217       $  9606.96
P 62                 62        49   49   49   71   218       $  9606.96
P 63                 63        49   49   49   72   219       $ 10293.17
P 64                 64        49   49   49   73   220       $ 10979.38
P 65                 65        49   49   49   74   221       $ 10293.17
P 66                 66        49   49   49   75   222       $ 13038.02
P 67                 67        49   49   49   76   223       $  8234.54
P 68                 68        49   49   49   77   224       $ 14410.44
P 69                 69        49   49   49   78   225       $ 10293.17
P 70                 70T       49   49   49   79   226       $  7205.22
P 71                 70T       49   49   49   79   226       $  7205.22
P 72                 72        49   49   49   80   227
P 73                 72        49   49   49   80   227
P 74                 74        49   49   49   81   228
P 75                 75        49   49   49   82   229
P 76                 76        49   49   49   83   230
P 77                 76        49   49   49   83   230
P 78                 78        49   49   49   84   231
P 79                 78        49   49   49   84   231
P 80                 78        49   49   49   84   231
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 207 - PGA Tour Prize Money

Post by brianfry713 »

Check input and AC output for thousands of problems on uDebug!
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 207 - PGA Tour Prize Money

Post by metaphysis »

I got AC, just for clarity:
You need't to print a space after scores which less than 100;
You need't to add an epsilon to output money, just using setprecision(2) is fine for C++ user.
The test data on UVa OJ cotains non tricky input, make sure your algorithm is right.
Post Reply

Return to “Volume 2 (200-299)”