Skip to content

Commit

Permalink
Merge pull request #76 from Sushank34/master
Browse files Browse the repository at this point in the history
Added my LTIME95B answers in Codechef
  • Loading branch information
manishbisht authored Aug 24, 2021
2 parents 039ad55 + 410e461 commit d705ef8
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 0 deletions.
86 changes: 86 additions & 0 deletions Codechef/LTIME95B/Array Rotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;

public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}

String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt()
{
return Integer.parseInt(next());
}


long nextLong()
{
return Long.parseLong(next());
}

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) throws java.lang.Exception{
FastReader sc=new FastReader();
int n=sc.nextInt();
long[] arr=new long[n];
long sum=0;
for(int i=0;i<n;i++) {
arr[i]=sc.nextLong();
sum=(sum+arr[i])%1000000007;
}

int q=sc.nextInt(),x;
for(int i=0;i<q;i++) {
x=sc.nextInt();
if(sum<0) {
sum=(((sum*2)%1000000007)+1000000007)%1000000007;
}
else {
sum=(sum*2)%1000000007;
}
System.out.print(sum+"\n");
}
}
}
106 changes: 106 additions & 0 deletions Codechef/LTIME95B/Bench Press.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;

public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}

String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt()
{
return Integer.parseInt(next());
}


long nextLong()
{
return Long.parseLong(next());
}

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) throws java.lang.Exception{
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
long w=sc.nextLong();
long wr=sc.nextLong();
long[] wt=new long[n];
Hashtable<Long,Long> d= new Hashtable<>();
long temp;
for(int i=0;i<n;i++) {
wt[i]=sc.nextLong();
if(d.get(wt[i])==null) {
d.put(wt[i],(long) 1);
}
else {
temp=(long) d.get(wt[i]);
d.put(wt[i],temp+1);
}
}
long temp2,resw=0;
for (Enumeration k=d.keys(),ele=d.elements();k.hasMoreElements();)
{
temp=(long) k.nextElement();
temp2=(long) ele.nextElement();
if(temp2>=2) {
if(temp2%2==0) {
resw=resw+temp*temp2;
}
else {
resw=resw+temp*(temp2-1);
}
}
}
if(resw+wr>=w) {
System.out.print("YES\n");
}
else {
System.out.print("NO\n");
}
}
}
}
92 changes: 92 additions & 0 deletions Codechef/LTIME95B/Chef in Heaven.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;

public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}

String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt()
{
return Integer.parseInt(next());
}


long nextLong()
{
return Long.parseLong(next());
}

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) throws java.lang.Exception{
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t-->0) {
int l=sc.nextInt();
String s=sc.next();
int ones=0,zero=0;
int flag=0;
for(int i=0;i<l;i++) {
if(s.charAt(i)=='1') {
ones++;
}
if(s.charAt(i)=='0') {
zero++;
}
if(ones>=zero) {
flag=1;
break;
}
}
if(flag==1) {
System.out.print("YES\n");
}
else {
System.out.print("NO\n");
}
}
}
}

0 comments on commit d705ef8

Please sign in to comment.