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 f9f6673

Browse files
update
1 parent 5266bfb commit f9f6673

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed

‎Collections Notes.odt‎

3.24 MB
Binary file not shown.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import java.io.BufferedReader;
2+
import java.io.DataInputStream;
3+
import java.io.FileInputStream;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.ArrayList;
7+
import java.util.Arrays;
8+
9+
10+
11+
/**
12+
* @author Mustansir
13+
*
14+
*/
15+
public class trying {
16+
17+
/**
18+
* @param args
19+
*/
20+
21+
22+
static class Reader
23+
{
24+
final private int BUFFER_SIZE = 1 << 16;
25+
private DataInputStream din;
26+
private byte[] buffer;
27+
private int bufferPointer, bytesRead;
28+
29+
public Reader()
30+
{
31+
din = new DataInputStream(System.in);
32+
buffer = new byte[BUFFER_SIZE];
33+
bufferPointer = bytesRead = 0;
34+
}
35+
public Reader(String file_name) throws IOException
36+
{
37+
din = new DataInputStream(new FileInputStream(file_name));
38+
buffer = new byte[BUFFER_SIZE];
39+
bufferPointer = bytesRead = 0;
40+
}
41+
public String readLine() throws IOException
42+
{
43+
byte[] buf = new byte[64]; // line length
44+
int cnt = 0, c;
45+
while ((c = read()) != -1)
46+
{
47+
if (c == '\n')
48+
break;
49+
buf[cnt++] = (byte) c;
50+
}
51+
return new String(buf, 0, cnt);
52+
}
53+
public int nextInt() throws IOException
54+
{
55+
int ret = 0;
56+
byte c = read();
57+
while (c <= ' ')
58+
c = read();
59+
boolean neg = (c == '-');
60+
if (neg)
61+
c = read();
62+
do
63+
{
64+
ret = ret * 10 + c - '0';
65+
} while ((c = read()) >= '0' && c <= '9');
66+
if (neg)
67+
return -ret;
68+
return ret;
69+
}
70+
public long nextLong() throws IOException
71+
{
72+
long ret = 0;
73+
byte c = read();
74+
while (c <= ' ')
75+
c = read();
76+
boolean neg = (c == '-');
77+
if (neg)
78+
c = read();
79+
do {
80+
ret = ret * 10 + c - '0';
81+
}
82+
while ((c = read()) >= '0' && c <= '9');
83+
if (neg)
84+
return -ret;
85+
return ret;
86+
}
87+
public double nextDouble() throws IOException
88+
{
89+
double ret = 0, div = 1;
90+
byte c = read();
91+
while (c <= ' ')
92+
c = read();
93+
boolean neg = (c == '-');
94+
if (neg)
95+
c = read();
96+
do {
97+
ret = ret * 10 + c - '0';
98+
}
99+
while ((c = read()) >= '0' && c <= '9');
100+
if (c == '.')
101+
{
102+
while ((c = read()) >= '0' && c <= '9')
103+
{
104+
ret += (c - '0') / (div *= 10);
105+
}
106+
}
107+
if (neg)
108+
return -ret;
109+
return ret;
110+
}
111+
private void fillBuffer() throws IOException
112+
{
113+
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
114+
if (bytesRead == -1)
115+
buffer[0] = -1;
116+
}
117+
private byte read() throws IOException
118+
{
119+
if (bufferPointer == bytesRead)
120+
fillBuffer();
121+
return buffer[bufferPointer++];
122+
}
123+
public void close() throws IOException
124+
{
125+
if (din == null)
126+
return;
127+
din.close();
128+
}
129+
}
130+
131+
public static void main(String[] args)throws IOException {
132+
// TODO Auto-generated method stub
133+
Reader s = new Reader();
134+
long n=s.nextLong();
135+
136+
}
137+
}

‎codeforces/K_Largest_Value.java‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.math.BigInteger;
5+
import java.util.*;
6+
7+
public class K_Largest_Value {
8+
//https://codeforces.com/contest/1491/problem/A
9+
public static void main(String[] args)throws IOException {
10+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
11+
12+
String[] st=br.readLine().split(" ");
13+
int n = Integer.parseInt(st[0]);
14+
int q = Integer.parseInt(st[1]);
15+
String[] aa =br.readLine().split(" ");
16+
ArrayList<Integer> al = new ArrayList<>();
17+
for(String e : aa)
18+
{
19+
al.add(Integer.parseInt(e));
20+
}
21+
22+
while(q-->0)
23+
{
24+
String[] st2=br.readLine().split(" ");
25+
if(Integer.parseInt(st[0])%2==0)
26+
{ int k = Integer.parseInt(st[1]);
27+
Collections.sort(al, Collections.reverseOrder());
28+
System.out.println(al.get(k));
29+
}
30+
else{
31+
int x = Integer.parseInt(st[1]);
32+
al.set(x,1-al.get(x));
33+
System.out.println(al.get(x));
34+
}
35+
}
36+
}
37+
}
38+

0 commit comments

Comments
(0)

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