Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d705ef8

Browse files
Merge pull request #76 from Sushank34/master
Added my LTIME95B answers in Codechef
2 parents 039ad55 + 410e461 commit d705ef8

File tree

3 files changed

+284
-0
lines changed

3 files changed

+284
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
import java.io.*;
4+
5+
class Codechef
6+
{
7+
static class FastReader
8+
{
9+
BufferedReader br;
10+
StringTokenizer st;
11+
12+
public FastReader()
13+
{
14+
br = new BufferedReader(new
15+
InputStreamReader(System.in));
16+
}
17+
18+
String next()
19+
{
20+
while (st == null || !st.hasMoreElements())
21+
{
22+
try
23+
{
24+
st = new StringTokenizer(br.readLine());
25+
}
26+
catch (IOException e)
27+
{
28+
e.printStackTrace();
29+
}
30+
}
31+
return st.nextToken();
32+
}
33+
34+
int nextInt()
35+
{
36+
return Integer.parseInt(next());
37+
}
38+
39+
40+
long nextLong()
41+
{
42+
return Long.parseLong(next());
43+
}
44+
45+
double nextDouble()
46+
{
47+
return Double.parseDouble(next());
48+
}
49+
50+
String nextLine()
51+
{
52+
String str = "";
53+
try
54+
{
55+
str = br.readLine();
56+
}
57+
catch (IOException e)
58+
{
59+
e.printStackTrace();
60+
}
61+
return str;
62+
}
63+
}
64+
public static void main(String[] args) throws java.lang.Exception{
65+
FastReader sc=new FastReader();
66+
int n=sc.nextInt();
67+
long[] arr=new long[n];
68+
long sum=0;
69+
for(int i=0;i<n;i++) {
70+
arr[i]=sc.nextLong();
71+
sum=(sum+arr[i])%1000000007;
72+
}
73+
74+
int q=sc.nextInt(),x;
75+
for(int i=0;i<q;i++) {
76+
x=sc.nextInt();
77+
if(sum<0) {
78+
sum=(((sum*2)%1000000007)+1000000007)%1000000007;
79+
}
80+
else {
81+
sum=(sum*2)%1000000007;
82+
}
83+
System.out.print(sum+"\n");
84+
}
85+
}
86+
}

‎Codechef/LTIME95B/Bench Press.java‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
import java.io.*;
4+
5+
class Codechef
6+
{
7+
static class FastReader
8+
{
9+
BufferedReader br;
10+
StringTokenizer st;
11+
12+
public FastReader()
13+
{
14+
br = new BufferedReader(new
15+
InputStreamReader(System.in));
16+
}
17+
18+
String next()
19+
{
20+
while (st == null || !st.hasMoreElements())
21+
{
22+
try
23+
{
24+
st = new StringTokenizer(br.readLine());
25+
}
26+
catch (IOException e)
27+
{
28+
e.printStackTrace();
29+
}
30+
}
31+
return st.nextToken();
32+
}
33+
34+
int nextInt()
35+
{
36+
return Integer.parseInt(next());
37+
}
38+
39+
40+
long nextLong()
41+
{
42+
return Long.parseLong(next());
43+
}
44+
45+
double nextDouble()
46+
{
47+
return Double.parseDouble(next());
48+
}
49+
50+
String nextLine()
51+
{
52+
String str = "";
53+
try
54+
{
55+
str = br.readLine();
56+
}
57+
catch (IOException e)
58+
{
59+
e.printStackTrace();
60+
}
61+
return str;
62+
}
63+
}
64+
public static void main(String[] args) throws java.lang.Exception{
65+
FastReader sc=new FastReader();
66+
int t=sc.nextInt();
67+
while(t-->0) {
68+
int n=sc.nextInt();
69+
long w=sc.nextLong();
70+
long wr=sc.nextLong();
71+
long[] wt=new long[n];
72+
Hashtable<Long,Long> d= new Hashtable<>();
73+
long temp;
74+
for(int i=0;i<n;i++) {
75+
wt[i]=sc.nextLong();
76+
if(d.get(wt[i])==null) {
77+
d.put(wt[i],(long) 1);
78+
}
79+
else {
80+
temp=(long) d.get(wt[i]);
81+
d.put(wt[i],temp+1);
82+
}
83+
}
84+
long temp2,resw=0;
85+
for (Enumeration k=d.keys(),ele=d.elements();k.hasMoreElements();)
86+
{
87+
temp=(long) k.nextElement();
88+
temp2=(long) ele.nextElement();
89+
if(temp2>=2) {
90+
if(temp2%2==0) {
91+
resw=resw+temp*temp2;
92+
}
93+
else {
94+
resw=resw+temp*(temp2-1);
95+
}
96+
}
97+
}
98+
if(resw+wr>=w) {
99+
System.out.print("YES\n");
100+
}
101+
else {
102+
System.out.print("NO\n");
103+
}
104+
}
105+
}
106+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
import java.io.*;
4+
5+
class Codechef
6+
{
7+
static class FastReader
8+
{
9+
BufferedReader br;
10+
StringTokenizer st;
11+
12+
public FastReader()
13+
{
14+
br = new BufferedReader(new
15+
InputStreamReader(System.in));
16+
}
17+
18+
String next()
19+
{
20+
while (st == null || !st.hasMoreElements())
21+
{
22+
try
23+
{
24+
st = new StringTokenizer(br.readLine());
25+
}
26+
catch (IOException e)
27+
{
28+
e.printStackTrace();
29+
}
30+
}
31+
return st.nextToken();
32+
}
33+
34+
int nextInt()
35+
{
36+
return Integer.parseInt(next());
37+
}
38+
39+
40+
long nextLong()
41+
{
42+
return Long.parseLong(next());
43+
}
44+
45+
double nextDouble()
46+
{
47+
return Double.parseDouble(next());
48+
}
49+
50+
String nextLine()
51+
{
52+
String str = "";
53+
try
54+
{
55+
str = br.readLine();
56+
}
57+
catch (IOException e)
58+
{
59+
e.printStackTrace();
60+
}
61+
return str;
62+
}
63+
}
64+
public static void main(String[] args) throws java.lang.Exception{
65+
FastReader sc=new FastReader();
66+
int t=sc.nextInt();
67+
while(t-->0) {
68+
int l=sc.nextInt();
69+
String s=sc.next();
70+
int ones=0,zero=0;
71+
int flag=0;
72+
for(int i=0;i<l;i++) {
73+
if(s.charAt(i)=='1') {
74+
ones++;
75+
}
76+
if(s.charAt(i)=='0') {
77+
zero++;
78+
}
79+
if(ones>=zero) {
80+
flag=1;
81+
break;
82+
}
83+
}
84+
if(flag==1) {
85+
System.out.print("YES\n");
86+
}
87+
else {
88+
System.out.print("NO\n");
89+
}
90+
}
91+
}
92+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /