diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-01-09 10:47:37 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-01-09 10:47:37 +0700 |
commit | 318184dbda0658d8afae6dd3c13a0718382726a1 (patch) | |
tree | 5a62259a03200cd77823431994fe3479e5d7461f /09/TP-HN-2014/cau2.pas | |
parent | 15b38076cc08d89024864252e99e10fe6f597196 (diff) | |
download | cp-318184dbda0658d8afae6dd3c13a0718382726a1.tar.gz |
Add NTU/{pali2,editpic}.c and update README.md
Diffstat (limited to '09/TP-HN-2014/cau2.pas')
-rw-r--r-- | 09/TP-HN-2014/cau2.pas | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/09/TP-HN-2014/cau2.pas b/09/TP-HN-2014/cau2.pas new file mode 100644 index 0000000..aed61ed --- /dev/null +++ b/09/TP-HN-2014/cau2.pas @@ -0,0 +1,31 @@ +var + f: text; + n, i, j: smallint; + d: longint; + v: array of smallint; + t: array of real; + +begin + assign(f, 'CAU2.INP'); + reset(f); + readln(f, n, d); + setlength(v, n); + for i := 0 to n - 1 do + read(f, v[i]); + close(f); + + setlength(t, n); + for i := 0 to n - 1 do + t[i] := i + d / v[i]; + + d := 0; + for i := 1 to n - 1 do + for j := 0 to i - 1 do + if t[i] < t[j] then + inc(d); + + assign(f, 'CAU2.OUT'); + rewrite(f); + writeln(f, d); + close(f) +end. |