From b7800d76e4f49d0e08ad056a68c49c161bb3359c Mon Sep 17 00:00:00 2001 From: Anshika Gupta Date: Wed, 30 Oct 2019 13:44:05 +0530 Subject: [PATCH] added educational 75 --- round-75(educational)/2048_a.cpp | 19 +++++++++++++ round-75(educational)/d.cpp | 35 ++++++++++++++++++++++++ round-75(educational)/knights_b.cpp | 15 ++++++++++ round-75(educational)/perfect_team_c.cpp | 12 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 round-75(educational)/2048_a.cpp create mode 100644 round-75(educational)/d.cpp create mode 100644 round-75(educational)/knights_b.cpp create mode 100644 round-75(educational)/perfect_team_c.cpp diff --git a/round-75(educational)/2048_a.cpp b/round-75(educational)/2048_a.cpp new file mode 100644 index 0000000..31b59c0 --- /dev/null +++ b/round-75(educational)/2048_a.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +int main(){ + int t; cin >> t; + while(t--){ + int n; cin >> n; + int arr[n], ssf = 0; + for(int i = 0; i < n ; i++){ + cin >> arr[i]; + if(arr[i] <= 2048) + ssf += arr[i]; + } + if(ssf >= 2048){ + cout << "YES" << endl; + } + else + cout << "NO" << endl; + } +} \ No newline at end of file diff --git a/round-75(educational)/d.cpp b/round-75(educational)/d.cpp new file mode 100644 index 0000000..edc33ba --- /dev/null +++ b/round-75(educational)/d.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; +#define lli long long int +int main(){ + int t; cin >> t; + while(t--){ + int n; cin >> n; + vector>v(n); + + for(int i = 0; i < n; i++){ + lli x, y; + // cin >> x >> y; + v[i].first = x; + v[i].second = y; + } + + + vector> dp(n, vector(4, INT_MAX)); + for(int i = 1; i < n; i++){ + for(int j = 1; j <= 3; j++){ + for(int k = 0; k <= 2; k++){ + if(v[i-1].first+k != v[i].first+j) + dp[i][j] = min(dp[i][j], dp[i-1][k]); + } + dp[i][j] += j*v[i].second; + } + } + lli minv = 0; + for(int j = 1; j <= 3; j++){ + minv = min(minv, dp[n-1][j]); + } + cout << minv << endl; + return 0; + } +} \ No newline at end of file diff --git a/round-75(educational)/knights_b.cpp b/round-75(educational)/knights_b.cpp new file mode 100644 index 0000000..f0f3fb6 --- /dev/null +++ b/round-75(educational)/knights_b.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int main(){ + int n; cin >> n; + for(int i = 0; i < n; i++){ + for(int j = 0; j < n; j++){ + if(((i+j) % 2 )== 0){ + cout << "W"; + }else{ + cout << "B"; + } + } + cout << endl; + } +} \ No newline at end of file diff --git a/round-75(educational)/perfect_team_c.cpp b/round-75(educational)/perfect_team_c.cpp new file mode 100644 index 0000000..d90b5b2 --- /dev/null +++ b/round-75(educational)/perfect_team_c.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; +int main(){ + int t; cin >> t; + while(t--){ + int c, m,x; + cin >> c >> m >> x; + int avg = (c+m+x)/3; + int ans = min(min(c, m), avg); + cout << ans << endl; + } +} \ No newline at end of file