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 0a62f6e

Browse files
Add submissions for May16 long challenge
1 parent aeaacb8 commit 0a62f6e

File tree

7 files changed

+711
-0
lines changed

7 files changed

+711
-0
lines changed

‎LongChallenge/May16/may1.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long
3+
#define ull unsigned long long
4+
#define vi vector<ll>
5+
#define pp pair<ll,ll>
6+
#define mp make_pair
7+
#define PI acos(-1.0)
8+
#define all(v) v.begin(),v.end()
9+
#define pb push_back
10+
#define FOR(i,a,b) for(i=a;i<b;i++)
11+
#define FREV(i,a,b) for(i=a;i>=b;i--)
12+
#define INF 1e18
13+
14+
#ifndef ONLINE_JUDGE
15+
#define gc getchar
16+
#define pc putchar
17+
#else
18+
#define gc getchar_unlocked
19+
#define pc putchar_unlocked
20+
#endif
21+
22+
using namespace std;
23+
24+
int read_int() {
25+
char c = gc();
26+
while((c < '0' || c > '9') && c != '-') c = gc();
27+
int ret = 0, neg = 0;
28+
if (c == '-') neg = 1, c = gc();
29+
while(c >= '0' && c <= '9') {
30+
ret = 10 * ret + c - 48;
31+
c = gc();
32+
}
33+
return neg ? -ret : ret;
34+
}
35+
36+
ll read_ll() {
37+
char c = gc();
38+
while((c < '0' || c > '9') && c != '-') c = gc();
39+
ll ret = 0;
40+
int neg = 0;
41+
if (c == '-') neg = 1, c = gc();
42+
while(c >= '0' && c <= '9') {
43+
ret = 10 * ret + c - 48;
44+
c = gc();
45+
}
46+
return neg ? -ret : ret;
47+
}
48+
49+
int main() {
50+
ll i,j,t,n;
51+
char s[200005];
52+
t = read_ll();
53+
while(t--) {
54+
scanf("%s", s);
55+
ll len = strlen(s);
56+
for(i=1; i<len; i++) {
57+
if((s[i] == 'C' && s[i-1] == 'E') || (s[i] == 'C' && s[i-1] == 'S') || (s[i] == 'E' && s[i-1] == 'S')) {
58+
break;
59+
}
60+
}
61+
if (i < len) {
62+
cout<<"no\n";
63+
}
64+
else {
65+
cout<<"yes\n";
66+
}
67+
}
68+
return 0;
69+
}

‎LongChallenge/May16/may2.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long
3+
#define ull unsigned long long
4+
#define vi vector<ll>
5+
#define pp pair<ll,ll>
6+
#define mp make_pair
7+
#define PI acos(-1.0)
8+
#define all(v) v.begin(),v.end()
9+
#define pb push_back
10+
#define FOR(i,a,b) for(i=a;i<b;i++)
11+
#define FREV(i,a,b) for(i=a;i>=b;i--)
12+
#define INF 1e18
13+
14+
#ifndef ONLINE_JUDGE
15+
#define gc getchar
16+
#define pc putchar
17+
#else
18+
#define gc getchar_unlocked
19+
#define pc putchar_unlocked
20+
#endif
21+
22+
using namespace std;
23+
24+
int read_int() {
25+
char c = gc();
26+
while((c < '0' || c > '9') && c != '-') c = gc();
27+
int ret = 0, neg = 0;
28+
if (c == '-') neg = 1, c = gc();
29+
while(c >= '0' && c <= '9') {
30+
ret = 10 * ret + c - 48;
31+
c = gc();
32+
}
33+
return neg ? -ret : ret;
34+
}
35+
36+
ll read_ll() {
37+
char c = gc();
38+
while((c < '0' || c > '9') && c != '-') c = gc();
39+
ll ret = 0;
40+
int neg = 0;
41+
if (c == '-') neg = 1, c = gc();
42+
while(c >= '0' && c <= '9') {
43+
ret = 10 * ret + c - 48;
44+
c = gc();
45+
}
46+
return neg ? -ret : ret;
47+
}
48+
49+
int main() {
50+
ll i,j,t,n;
51+
t = read_ll();
52+
while(t--) {
53+
n = read_ll();
54+
ll maxim = 0;
55+
FOR(i,0,n) {
56+
j = read_ll();
57+
if (j>maxim) {
58+
maxim = j;
59+
}
60+
}
61+
cout<<n-maxim<<"\n";
62+
}
63+
return 0;
64+
}

‎LongChallenge/May16/may3.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long
3+
#define ull unsigned long long
4+
#define vi vector<ll>
5+
#define pp pair<ll,ll>
6+
#define mp make_pair
7+
#define PI acos(-1.0)
8+
#define all(v) v.begin(),v.end()
9+
#define pb push_back
10+
#define FOR(i,a,b) for(i=a;i<b;i++)
11+
#define FREV(i,a,b) for(i=a;i>=b;i--)
12+
#define INF 1e18
13+
14+
#ifndef ONLINE_JUDGE
15+
#define gc getchar
16+
#define pc putchar
17+
#else
18+
#define gc getchar_unlocked
19+
#define pc putchar_unlocked
20+
#endif
21+
22+
using namespace std;
23+
24+
int read_int() {
25+
char c = gc();
26+
while((c < '0' || c > '9') && c != '-') c = gc();
27+
int ret = 0, neg = 0;
28+
if (c == '-') neg = 1, c = gc();
29+
while(c >= '0' && c <= '9') {
30+
ret = 10 * ret + c - 48;
31+
c = gc();
32+
}
33+
return neg ? -ret : ret;
34+
}
35+
36+
ll read_ll() {
37+
char c = gc();
38+
while((c < '0' || c > '9') && c != '-') c = gc();
39+
ll ret = 0;
40+
int neg = 0;
41+
if (c == '-') neg = 1, c = gc();
42+
while(c >= '0' && c <= '9') {
43+
ret = 10 * ret + c - 48;
44+
c = gc();
45+
}
46+
return neg ? -ret : ret;
47+
}
48+
49+
int main() {
50+
ll i,j,t,n;
51+
t = read_ll();
52+
while(t--) {
53+
n = read_ll();
54+
vector<ll> a(2*n+1);
55+
FOR(i,1,2*n+1) {
56+
a[i] = read_ll();
57+
}
58+
sort(all(a));
59+
j = n + (n/2) + 1;
60+
cout<<a[j]<<"\n";
61+
FOR(i,1,n+1) {
62+
cout<<a[i]<<" "<<a[n+i]<<" ";
63+
}
64+
cout<<"\n";
65+
}
66+
return 0;
67+
}

‎LongChallenge/May16/may4.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long
3+
#define ull unsigned long long
4+
#define vi vector<ll>
5+
#define pp pair<ll,ll>
6+
#define mp make_pair
7+
#define PI acos(-1.0)
8+
#define all(v) v.begin(),v.end()
9+
#define pb push_back
10+
#define FOR(i,a,b) for(i=a;i<b;i++)
11+
#define FREV(i,a,b) for(i=a;i>=b;i--)
12+
#define INF 1e18
13+
14+
#ifndef ONLINE_JUDGE
15+
#define gc getchar
16+
#define pc putchar
17+
#else
18+
#define gc getchar_unlocked
19+
#define pc putchar_unlocked
20+
#endif
21+
22+
using namespace std;
23+
24+
int read_int() {
25+
char c = gc();
26+
while((c < '0' || c > '9') && c != '-') c = gc();
27+
int ret = 0, neg = 0;
28+
if (c == '-') neg = 1, c = gc();
29+
while(c >= '0' && c <= '9') {
30+
ret = 10 * ret + c - 48;
31+
c = gc();
32+
}
33+
return neg ? -ret : ret;
34+
}
35+
36+
ll read_ll() {
37+
char c = gc();
38+
while((c < '0' || c > '9') && c != '-') c = gc();
39+
ll ret = 0;
40+
int neg = 0;
41+
if (c == '-') neg = 1, c = gc();
42+
while(c >= '0' && c <= '9') {
43+
ret = 10 * ret + c - 48;
44+
c = gc();
45+
}
46+
return neg ? -ret : ret;
47+
}
48+
49+
void build_rangemax_tree(ll* t_max, ll n) {
50+
ll i;
51+
for(i=n-1; i>0; i--) {
52+
t_max[i] = max(t_max[i<<1], t_max[i<<1|1]);
53+
}
54+
/*for(i=1; i,2*n; i++)
55+
cout<<t_max[i]<<" ";
56+
cout<<endl;*/
57+
}
58+
59+
ll range_max(ll* t, ll n, ll l, ll r) {
60+
ll maxim = INT_MIN;
61+
for(l+=n, r+=n; l<r; l>>=1, r>>=1) {
62+
if(l & 1)
63+
maxim = max(maxim, t[l++]);
64+
if(r & 1)
65+
maxim = max(maxim, t[--r]);
66+
}
67+
return maxim;
68+
}
69+
70+
int main() {
71+
ll i,j,n,k,p;
72+
char query[100005];
73+
n = read_ll();
74+
k = read_ll();
75+
p = read_ll();
76+
k = min(n,k);
77+
vector<int> a(2*n), count(2*n);
78+
ll t_max[4*n];
79+
FOR(i,0,n) {
80+
j = read_int();
81+
a[n-i-1] = a[2*n-i-1] = j;
82+
}
83+
scanf("%s", query);
84+
FOR(i,0,k) {
85+
count[0] += a[i];
86+
}
87+
t_max[2*n] = count[0];
88+
FOR(i,1,n) {
89+
count[i] = count[i-1] + a[i+k-1] - a[i-1];
90+
t_max[i+2*n] = count[i];
91+
}
92+
FOR(i,n,2*n) {
93+
count[i] = count[i-n];
94+
t_max[i+2*n] = count[i];
95+
}
96+
// FOR(i,0,2*n) {
97+
// cout<<count[i]<<" ";
98+
// }
99+
// cout<<"\n";
100+
ll start_index = 0;
101+
build_rangemax_tree(t_max, 2*n);
102+
for(i=0; query[i]; i++) {
103+
if(query[i] == '!') {
104+
start_index = (start_index + 1)%n;
105+
}
106+
else {
107+
cout<<range_max(t_max, 2*n, start_index, start_index + n - k + 1)<<"\n";
108+
}
109+
}
110+
return 0;
111+
}

0 commit comments

Comments
(0)

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