結果
問題 | No.1041 直線大学 |
ユーザー | jp_ste |
提出日時 | 2020-05-09 23:07:49 |
言語 | JavaScript (node v21.7.1) |
結果 |
AC
|
実行時間 | 117 ms / 2,000 ms |
コード長 | 2,998 bytes |
コンパイル時間 | 48 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 43,244 KB |
最終ジャッジ日時 | 2024-04-28 00:15:33 |
合計ジャッジ時間 | 3,803 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
38,656 KB |
testcase_01 | AC | 53 ms
39,296 KB |
testcase_02 | AC | 52 ms
38,528 KB |
testcase_03 | AC | 53 ms
38,784 KB |
testcase_04 | AC | 54 ms
38,400 KB |
testcase_05 | AC | 52 ms
38,784 KB |
testcase_06 | AC | 51 ms
38,656 KB |
testcase_07 | AC | 57 ms
38,528 KB |
testcase_08 | AC | 56 ms
38,656 KB |
testcase_09 | AC | 58 ms
38,528 KB |
testcase_10 | AC | 117 ms
42,856 KB |
testcase_11 | AC | 81 ms
43,108 KB |
testcase_12 | AC | 76 ms
43,244 KB |
testcase_13 | AC | 59 ms
38,912 KB |
testcase_14 | AC | 71 ms
42,368 KB |
testcase_15 | AC | 65 ms
42,368 KB |
testcase_16 | AC | 66 ms
42,496 KB |
testcase_17 | AC | 58 ms
39,424 KB |
testcase_18 | AC | 69 ms
42,240 KB |
testcase_19 | AC | 68 ms
43,008 KB |
testcase_20 | AC | 57 ms
39,040 KB |
testcase_21 | AC | 64 ms
43,136 KB |
testcase_22 | AC | 54 ms
38,912 KB |
testcase_23 | AC | 69 ms
43,008 KB |
testcase_24 | AC | 65 ms
42,496 KB |
testcase_25 | AC | 65 ms
42,752 KB |
testcase_26 | AC | 55 ms
38,528 KB |
testcase_27 | AC | 64 ms
42,240 KB |
testcase_28 | AC | 52 ms
39,168 KB |
testcase_29 | AC | 52 ms
38,656 KB |
testcase_30 | AC | 58 ms
38,912 KB |
testcase_31 | AC | 56 ms
38,912 KB |
testcase_32 | AC | 58 ms
38,912 KB |
testcase_33 | AC | 55 ms
38,784 KB |
testcase_34 | AC | 56 ms
39,296 KB |
testcase_35 | AC | 53 ms
38,656 KB |
testcase_36 | AC | 55 ms
39,168 KB |
testcase_37 | AC | 54 ms
39,040 KB |
testcase_38 | AC | 71 ms
43,112 KB |
testcase_39 | AC | 62 ms
42,496 KB |
ソースコード
function main(input) { let [N] = getIntegers(input, " "); let L = []; for(let i=0; i<N; i++) { let [X, Y] = getIntegers(input, " "); L.push({x:X, y:Y}); } let max = 0; for(let i=0; i<N-1; i++) { for(let j=i+1; j<N; j++) { let dx = L[i].x - L[j].x; let dy = L[i].y - L[j].y; let count = 0; for(let k=0; k<N; k++) { let dx2 = L[i].x - L[k].x; let dy2 = L[i].y - L[k].y; if(dx * dy2 == dy * dx2) count++; } max = Math.max(max, count); } } console.log(max); } //-- functions ------------------------------------ function getIntegers(lines, sep) { if(sep === undefined) { return lines.map(function(e) { return Number(e); }); } else { return lines.shift().split(sep).map(function(e) { return Number(e); }); } } function getStrings(lines, sep=" ") { return lines.shift().split(sep); } function twoDimenArrayByValue(h, w, value) { const list = new Array(h); for(let i=0; i<h; i++) { list[i] = new Array(w).fill().map(function(e) { return value.constructor == Array ? Array.from(value) : value; }); } return list; } function twoDimenArrayByStrings(h, strings) { const list = new Array(h); for(let i=0; i<h; i++) { list[i] = strings.shift().split(""); } return list; } function distance(x1, y1, x2, y2) { return Math.sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1)); } function gcd(a, b) { return b === 0 ? a : gcd(b, a % b); } //-- Array ------------------------------------------- Array.prototype.sortByIntegerA = function() { this.sort(function(a, b) { return a - b; }); }; Array.prototype.sortByIntegerD = function() { this.sort(function(a, b) { return b - a; }); }; Array.prototype.orLess = function(V, l=0, r=this.length) { l--; while(r - l > 1) { let x = Math.floor((r + l) / 2); this[x] > V ? r = x : l = x; } return r; }; Array.prototype.lessThen = function(V, l=0, r=this.length) { l--; while(r - l > 1) { let x = Math.floor((r + l) / 2); this[x] >= V ? r = x : l = x; } return r; }; Array.prototype.orHigher = function(V, l, r) { return this.length - this.lessThen(V, l, r); }; Array.prototype.greaterThan = function(V, l, r) { return this.length - this.orLess(V, l, r); }; Array.prototype.deepCopy = function(list) { let retList = []; for(let i=0; i<list.length; i++) { retList[i] = list[i].constructor == Array ? Array.from(list[i]) : list[i]; } return retList; }; Array.prototype.out = function() { let outList = []; if(this[0].constructor == Array) { for(let i=0; i<this.length; i++) { outList.push(this[i].join(" ")); } } else { outList.push(this.join(" ")); } console.log(outList.join("\n")); }; Array.prototype.pushNoSameValue = function(...values) { values.forEach(function(e) { if(!this.includes(e)) { this.push(e); } }, this); }; main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));