diff --git a/README.md b/README.md index 86bea84..e8cd93a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,23 @@ # kotlin-heroes-solutions Solutions to Codeforces' Kotlin Heroes Contests + +___ + + +### Practice Rounds + +|Contest|Problems|Solutions| +|:-:|:-:|:-:| +| Practice-1 | [Link](https://codeforces.com/contest/1171) | [NA]() | +| Practice-2 | [Link](https://codeforces.com/contest/1212) | [NA]() | +| Practice-3 | [Link](https://codeforces.com/contest/1298) | [NA]() | +| Practice-4 | [Link](https://codeforces.com/contest/1347) | [NA]() | +| Practice-5 | [Link](https://codeforces.com/contest/1432) | [NA]() | +| Practice-6 | [Link](https://codeforces.com/contest/1489) | [NA]() | +| Practice-7 | [Link](https://codeforces.com/contest/1532) | [Link](./practice-7/) | + +
+ +___ +> Pull Requests are welcome, thank you! :) +___ \ No newline at end of file diff --git a/practice-7/README.md b/practice-7/README.md new file mode 100644 index 0000000..3bbab93 --- /dev/null +++ b/practice-7/README.md @@ -0,0 +1,20 @@ +# kotlin-heroes-solutions/practice-7/ +Solutions to [Kotlin Heroes: Practice 1](https://codeforces.com/contest/1171) + +___ + +### Problems + +|#|Problem Statement|Solution| +|:-:|:-:|:-:| +| A | [Link](https://codeforces.com/contest/1532/problem/A) | [Link](./a.kt) | +| B | [Link](https://codeforces.com/contest/1532/problem/B) | [Link](./b.kt) | +| C | [Link](https://codeforces.com/contest/1532/problem/C) | [Link](./c.kt) | +| D | [Link](https://codeforces.com/contest/1532/problem/D) | [Link](./d.kt) | +| E | [Link](https://codeforces.com/contest/1532/problem/E) | [Link](./e.kt) | + +
+ +___ +> Pull Requests are welcome, thank you! :) +___ \ No newline at end of file diff --git a/practice-7/a.kt b/practice-7/a.kt new file mode 100644 index 0000000..4c905f6 --- /dev/null +++ b/practice-7/a.kt @@ -0,0 +1,12 @@ + +import java.util.Scanner +fun main(){ + val read=Scanner(System.`in`) + var t=read.nextInt() + while(t>0){ + var a:Int = read.nextInt() + var b:Int = read.nextInt() + println(a + b) + t=t-1 + } +} \ No newline at end of file diff --git a/practice-7/b.kt b/practice-7/b.kt new file mode 100644 index 0000000..8294d8d --- /dev/null +++ b/practice-7/b.kt @@ -0,0 +1,21 @@ +import java.util.Scanner +fun main(){ + val read = Scanner(System.`in`) + var t=read.nextLong() + while(t>0){ + var a:Long = read.nextLong() + var b:Long = read.nextLong() + var k:Long = read.nextLong() + var ans:Long = 0 + if((k%2)==1L){ + ans=ans+a*((k+1)/2) + ans=ans-b*((k-1)/2) + } + else{ + ans=ans+a*(k/2) + ans=ans-b*(k/2) + } + println(ans) + t=t-1 + } +} \ No newline at end of file diff --git a/practice-7/c.kt b/practice-7/c.kt new file mode 100644 index 0000000..4d55317 --- /dev/null +++ b/practice-7/c.kt @@ -0,0 +1,25 @@ + +import java.util.Scanner +fun main(){ + val read = Scanner(System.`in`) + var t=read.nextLong() + while(t>0){ + var n:Int = read.nextInt() + var k:Int = read.nextInt() + var s:String = "" + var cnt:Int = n/k + for(i in 1..cnt){ + for(j in 1..k){ + var m:Char = 'a'-1+j + s+=m + } + } + cnt=n%k + for(i in 1..cnt){ + var m:Char = 'a'-1+i + s+=m + } + println(s) + t=t-1 + } +} \ No newline at end of file diff --git a/practice-7/d.kt b/practice-7/d.kt new file mode 100644 index 0000000..cff1b36 --- /dev/null +++ b/practice-7/d.kt @@ -0,0 +1,23 @@ + +import java.util.* +fun main(){ + val read = Scanner(System.`in`) + var t=1 + while(t>0){ + var n:Int = read.nextInt() + var skills = Vector() + for(i in 1..n){ + var ins:Int = read.nextInt() + skills.add(ins) + } + skills.sort() + var ans:Int = 0 + var i:Int = 0 + while(i0){ + var n:Int = read.nextInt() + var v = Vector() + var sum:Long = 0L + var greatest:Int = 0 + var gind:Int = 0 + var sg:Int = 0 + var sgind:Int = 0 + var ans = Vector() + for(i in 0..n-1){ + var ins:Int = read.nextInt() + v.add(ins) + if(ins>=greatest){ + greatest=ins + gind=i + } + sum=sum+(ins.toLong()) + } + for(i in 0..n-1){ + if(i!=gind){ + if(v[i]>sg){ + sg=v[i] + sgind=i + } + } + } + sum=sum-(greatest.toLong()); + if((sum-(sg.toLong()))==(sg.toLong())){ + ans.add(gind) + } + for(i in 0..n-1){ + if(i!=gind){ + if((sum-(v[i].toLong()))==(greatest.toLong())){ + ans.add(i) + } + } + } + println(ans.size) + for(i in ans){ + print(i+1) + print(" ") + } + t=t-1 + } +} \ No newline at end of file