Skip to content

Commit

Permalink
Add new submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonber committed Feb 27, 2020
1 parent a775b1b commit 0e1ca3a
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 1 deletion.
40 changes: 40 additions & 0 deletions codeforces/Codeforces Round #618 (Div. 2)/A.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// http://codeforces.com/contest/1300/problem/A

'use strict'

const readInts = () => {
return readline().split(' ').map(num => parseInt(num))
}

const readInt = () => readInts()[0]

let t = readInt()

while (t --> 0) {
const n = readInt()
const arr = readInts()

let ans = 0
let sum = 0
for (let i in arr) sum += arr[i]

for (let i in arr) {
if (!arr[i]) {
arr[i] ++
ans ++
sum ++
}
}

if (!sum) {
for (let i in arr) {
if (arr[i] + 1 !== 0) {
arr[i] ++
ans ++
break
}
}
}

print(ans)
}
22 changes: 22 additions & 0 deletions codeforces/Codeforces Round #624 (Div. 3)/A.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// http://codeforces.com/contest/1311/problem/A

'use strict'

let t = parseInt(readline())

while (t --> 0) {
const arr = readline().split(' ').map(n => parseInt(n))
const a = arr[0]
const b = arr[1]

let ans = 0
const diff = Math.abs(a - b)
if (a < b) {
if (diff % 2) ans = 1
else ans = 2
} else if (a > b) {
if (diff % 2) ans = 2
else ans = 1
}
print(ans)
}
36 changes: 36 additions & 0 deletions codeforces/Codeforces Round #624 (Div. 3)/B.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// http://codeforces.com/contest/1311/problem/B

'use strict'

let t = parseInt(readline())
const readInts = () => readline().split(' ').map(n => parseInt(n))
const readInt = () => readInts[0]

while (t --> 0) {
const nm = readInts()
const arr = readInts()
const p = readInts()

let found = true
while (found) {
found = false
for (let i in p) {
const pos = p[i]
if (arr[pos - 1] > arr[pos]) {
const tmp = arr[pos - 1]
arr[pos - 1] = arr[pos]
arr[pos] = tmp
found = true
}
}
}

let ok = true
for (let i = 1; i < arr.length; ++i) {
if (arr[i - 1] > arr[i]) {
ok = false
break
}
}
print(ok ? 'YES' : 'NO')
}
40 changes: 40 additions & 0 deletions codeforces/Codeforces Round #624 (Div. 3)/C.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// http://codeforces.com/contest/1311/problem/C

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]

main()

function main () {
let t = getInt()
while (t --> 0) {
const params = getInts()
const s = getLine()[0]
const mistakes = getInts()
solve(...params, s, mistakes)
}
}

function solve (n, m, s, mistakes) {
const freq = Array(n + 1).fill(0)
const ans = Array(26).fill(0)
let accumulate = 0

mistakes.push(n)

for (const i of mistakes) {
freq[0] ++
freq[i] --
}

for (let i = 0; i < n; ++i) {
const ind = s[i].charCodeAt() - 'a'.charCodeAt()
accumulate += freq[i]
ans[ind] += accumulate
}

print(ans.join(' '))
}
8 changes: 7 additions & 1 deletion codeforces/data.db
Original file line number Diff line number Diff line change
Expand Up @@ -1067,4 +1067,10 @@
32161457
31878123
31910741
32605600
32605600
71946383
71824279
71185827
71822449
71822118
71946544

0 comments on commit 0e1ca3a

Please sign in to comment.