CF EDU 130, finished a and b
This commit is contained in:
37
codeforces/educational_rounds/130/a.cpp
Normal file
37
codeforces/educational_rounds/130/a.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void test_case(int tc){
|
||||||
|
int n, m;
|
||||||
|
cin >> n >> m;
|
||||||
|
|
||||||
|
int distance = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < n; ++i){
|
||||||
|
int a;
|
||||||
|
cin >> a;
|
||||||
|
|
||||||
|
distance += a;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << max(0, distance - m) << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(0);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
for(int tc = 1; tc <= t; ++tc){
|
||||||
|
test_case(tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << flush;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
38
codeforces/educational_rounds/130/b.cpp
Normal file
38
codeforces/educational_rounds/130/b.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(0);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int n, q;
|
||||||
|
cin >> n >> q;
|
||||||
|
|
||||||
|
vector<int> p(n);
|
||||||
|
for(int i = 0; i < n; ++i){
|
||||||
|
cin >> p[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(p.begin(), p.end());
|
||||||
|
|
||||||
|
vector<uint64_t> bottom_sums(n+1);
|
||||||
|
|
||||||
|
uint64_t sum = 0;
|
||||||
|
for(int i = 0; i <= n; ++i){
|
||||||
|
bottom_sums[i] = sum;
|
||||||
|
sum += p[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < q; ++i){
|
||||||
|
int x, y;
|
||||||
|
cin >> x >> y;
|
||||||
|
|
||||||
|
uint64_t ans = bottom_sums[n - x + y] - bottom_sums[n - x];
|
||||||
|
cout << ans << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << flush;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
36
codeforces/educational_rounds/130/c.cpp
Normal file
36
codeforces/educational_rounds/130/c.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void test_case(int tc){
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
vector<char> s(n), t(n);
|
||||||
|
for(int i = 0; i < n; ++i){
|
||||||
|
cin >> s[i];
|
||||||
|
}
|
||||||
|
for(int i = 0; i < n; ++i){
|
||||||
|
cin >> t[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(0);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
for(int tc = 1; tc <= t; ++tc){
|
||||||
|
test_case(tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << flush;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
25
codeforces/educational_rounds/130/d.cpp
Normal file
25
codeforces/educational_rounds/130/d.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void test_case(int tc){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(0);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
for(int tc = 1; tc <= t; ++tc){
|
||||||
|
test_case(tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << flush;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
25
codeforces/educational_rounds/130/e.cpp
Normal file
25
codeforces/educational_rounds/130/e.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void test_case(int tc){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(0);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
for(int tc = 1; tc <= t; ++tc){
|
||||||
|
test_case(tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << flush;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
25
codeforces/educational_rounds/130/f.cpp
Normal file
25
codeforces/educational_rounds/130/f.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void test_case(int tc){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(0);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
for(int tc = 1; tc <= t; ++tc){
|
||||||
|
test_case(tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << flush;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user