Skip to content

Commit d8c67c0

Browse files
committed
Round 640
1 parent a2c7977 commit d8c67c0

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
int main(){
6+
int t;
7+
cin >> t;
8+
while(t--){
9+
int n;
10+
cin >> n;
11+
long long a;
12+
deque<long long> arr;
13+
cin >> a;
14+
long long AS = a, BS = 0;
15+
long long AC = a, BC = 0;
16+
for(long long i = 2; i <= n; i++){
17+
cin >> a;
18+
arr.push_back(a);
19+
}
20+
long long count = 1, last = 0;
21+
while(!arr.empty()){
22+
if(last == 0){
23+
while(!arr.empty() && BC <= AC){
24+
BC += arr.at(arr.size() - 1);
25+
arr.pop_back();
26+
}
27+
BS += BC;
28+
last = 1;
29+
AC = 0;
30+
count++;
31+
}else{
32+
while(!arr.empty() && AC <= BC){
33+
AC += arr.at(0);
34+
arr.pop_front();
35+
}
36+
AS += AC;
37+
last = 0;
38+
BC = 0;
39+
count++;
40+
}
41+
}
42+
cout << count << " " << AS << " " << BS << endl;
43+
}
44+
return 0;
45+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int t;
8+
cin >> t;
9+
while(t--){
10+
int n, k;
11+
cin >> n >> k;
12+
int ans = k + (k / (n - 1));
13+
if(ans % n == 0){
14+
cout << ans - 1 << endl;
15+
}else{
16+
cout << ans << endl;
17+
}
18+
}
19+
return 0;
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int t;
8+
cin >> t;
9+
while(t--){
10+
int n;
11+
cin >> n;
12+
int temp = n;
13+
int i = 1;
14+
vector<int> a;
15+
while(n){
16+
int temp = n % 10;
17+
if(temp != 0){
18+
a.push_back(temp * i);
19+
}
20+
i *= 10;
21+
n /= 10;
22+
}
23+
cout << a.size() << endl;
24+
for(int x : a){
25+
cout << x << " ";
26+
}
27+
cout << endl;
28+
}
29+
return 0;
30+
}

0 commit comments

Comments
 (0)