From 20d5b52452ce846c33b5e137598805792a2451ff Mon Sep 17 00:00:00 2001 From: Aman Chandra <112195895+amanchandra395@users.noreply.github.com> Date: Sat, 7 Jan 2023 15:46:58 +0530 Subject: [PATCH 01/19] Math --- 703A Mishka and Game.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 703A Mishka and Game.cpp diff --git a/703A Mishka and Game.cpp b/703A Mishka and Game.cpp new file mode 100644 index 0000000..1411d6a --- /dev/null +++ b/703A Mishka and Game.cpp @@ -0,0 +1,38 @@ +#include +using namespace std; + +int main() +{ + int n; + cin>>n; + int m,c; + int wM=0; + int wC=0; + int draw=0; + + for(int i=0; i>m>>c; + + if(m>c) + wM++; + else if(mwC) + { + cout<<"Mishka"< Date: Sun, 8 Jan 2023 15:03:04 +0530 Subject: [PATCH 02/19] Implementation --- 427A_Police_Recruits.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 427A_Police_Recruits.cpp diff --git a/427A_Police_Recruits.cpp b/427A_Police_Recruits.cpp new file mode 100644 index 0000000..ee2eac6 --- /dev/null +++ b/427A_Police_Recruits.cpp @@ -0,0 +1,40 @@ +#include +using namespace std; + +int main(){ + + int police = 0; + int ans = 0; + + int n; + cin>>n; + + int arr[n]; + for(int i = 0; i>arr[i]; + } + + for(int i = 0; i= 1) + { + police--; + } + else + { + ans++; + } + } + else + { + police += arr[i]; + } + + } + + cout< Date: Mon, 9 Jan 2023 15:10:12 +0530 Subject: [PATCH 03/19] Implementation --- 268A_Games.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 268A_Games.cpp diff --git a/268A_Games.cpp b/268A_Games.cpp new file mode 100644 index 0000000..217c3b7 --- /dev/null +++ b/268A_Games.cpp @@ -0,0 +1,31 @@ +#include +#include + +using namespace std; + +int main() +{ + int n; + cin >> n; + + int number = 0; + vectorh(n); + vectora(n); + for (int i = 0; i < n; ++i) + { + cin >> h[i] >> a[i]; + for (int j = 0; j < i; ++j) + { + if (h[i] == a[j]) + { + number += 1; + } + if (a[i] == h[j]) + { + number += 1; + } + } + } + cout << number << endl; + return 0; +} \ No newline at end of file From 37902130b86ab9521dabbf410ed18eaf82c62376 Mon Sep 17 00:00:00 2001 From: Aman Chandra <112195895+amanchandra395@users.noreply.github.com> Date: Fri, 13 Jan 2023 22:44:56 +0530 Subject: [PATCH 04/19] Math --- 479A_Expression.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 479A_Expression.cpp diff --git a/479A_Expression.cpp b/479A_Expression.cpp new file mode 100644 index 0000000..bad44fc --- /dev/null +++ b/479A_Expression.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +using namespace std; + +int main(){ + + int a,b,c; + cin>>a>>b>>c; + + int ans = 0; + + + int x = a+b+c; + ans = max(ans,x); + + int y = a*b*c; + ans = max(ans,y); + + int z = (a+b)*c; + ans = max(ans,z); + + int t = a*(b+c); + ans = max(ans,t); + + int u = a+(b*c); + ans = max(ans,u); + + int v = (a*b)+c; + ans = max(ans,v); + + cout< Date: Sat, 14 Jan 2023 21:35:39 +0530 Subject: [PATCH 05/19] String --- 208A_Dubstep.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 208A_Dubstep.cpp diff --git a/208A_Dubstep.cpp b/208A_Dubstep.cpp new file mode 100644 index 0000000..044c64a --- /dev/null +++ b/208A_Dubstep.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +int main() { + string s; + int flag=1; + cin>>s; + for(int i=0;i Date: Mon, 16 Jan 2023 15:14:36 +0530 Subject: [PATCH 06/19] Implementation --- 339B_Xenia_and_Ringroad.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 339B_Xenia_and_Ringroad.cpp diff --git a/339B_Xenia_and_Ringroad.cpp b/339B_Xenia_and_Ringroad.cpp new file mode 100644 index 0000000..1a12c83 --- /dev/null +++ b/339B_Xenia_and_Ringroad.cpp @@ -0,0 +1,32 @@ +#include +using namespace std; + +int main(){ + + int n; + int m; + cin>>n>>m; + + long long int arr[m]; + for(int i = 0; i>arr[i]; + } + + long long int ans = arr[0]-1; + + for(int i = 1; i= arr[i-1]) + { + ans += arr[i]-arr[i-1]; + } + else + { + ans += n - arr[i-1]; + ans += arr[i]; + } + } + cout< Date: Wed, 18 Jan 2023 23:09:32 +0530 Subject: [PATCH 07/19] Implementation --- 230A_Dragons.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 230A_Dragons.cpp diff --git a/230A_Dragons.cpp b/230A_Dragons.cpp new file mode 100644 index 0000000..f83a9a9 --- /dev/null +++ b/230A_Dragons.cpp @@ -0,0 +1,45 @@ + +#include +using namespace std; + +int main(){ + + int s,n; + cin>>s>>n; + bool win = true; + + int d,p; + + + vector>m; + for(int i = 0; i>d>>p; + m.push_back({d,p}); + } + + sort(m.begin(),m.end()); + + for(auto x : m) + { + if(s > x.first) + { + s += x.second; + } + else + { + win = false; + break; + } + } + + if(win) + { + cout<<"YES"< Date: Thu, 19 Jan 2023 11:11:41 +0530 Subject: [PATCH 08/19] Impleentation --- 451A_Game_With_Sticks.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 451A_Game_With_Sticks.cpp diff --git a/451A_Game_With_Sticks.cpp b/451A_Game_With_Sticks.cpp new file mode 100644 index 0000000..3b7a51c --- /dev/null +++ b/451A_Game_With_Sticks.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; + + + +int main() +{ + int n,m; + cin>>n>>m; + bool win = true; + + while(n>0 and m > 0) + { + if(win == true) + { + win = false; + } + else + { + win = true; + } + n--; + m--; + } + if(win) + { + cout<<"Malvika"< Date: Mon, 23 Jan 2023 19:27:41 +0530 Subject: [PATCH 09/19] Sorting --- 1760A_Medium_Number.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 1760A_Medium_Number.cpp diff --git a/1760A_Medium_Number.cpp b/1760A_Medium_Number.cpp new file mode 100644 index 0000000..0f8eeaa --- /dev/null +++ b/1760A_Medium_Number.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main(){ + + int t; + cin>>t; + + while(t--) + { + int arr[3]; + for(int i = 0; i<3; i++) + { + cin>>arr[i]; + } + sort(arr,arr+3); + cout< Date: Tue, 24 Jan 2023 13:47:54 +0530 Subject: [PATCH 10/19] Sorting --- 405A_Gravity_Flip.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 405A_Gravity_Flip.cpp diff --git a/405A_Gravity_Flip.cpp b/405A_Gravity_Flip.cpp new file mode 100644 index 0000000..19de2c7 --- /dev/null +++ b/405A_Gravity_Flip.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main(){ + int n; + cin>>n; + + int arr[n]; + for(int i = 0; i>arr[i]; + } + + sort(arr,arr+n); + for(int i = 0; i Date: Sun, 29 Jan 2023 11:28:02 +0530 Subject: [PATCH 11/19] Sorting --- 1353B_Two_Arrays_and_Swaps.cpp | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 1353B_Two_Arrays_and_Swaps.cpp diff --git a/1353B_Two_Arrays_and_Swaps.cpp b/1353B_Two_Arrays_and_Swaps.cpp new file mode 100644 index 0000000..e1bcad8 --- /dev/null +++ b/1353B_Two_Arrays_and_Swaps.cpp @@ -0,0 +1,48 @@ +#include +using namespace std; + +int main() +{ + int t; + cin>>t; + + while(t--) + { + int n,m; + cin>>n; + cin>>m; + + int a[n]; + int b[n]; + for(int i = 0; i>a[i]; + } + for(int i = 0; i>b[i]; + } + + sort(a,a+n); + sort(b,b+n); + + int i = 0; + int j = n-1; + while(b[j] > a[i] and m>0) + { + swap(b[j],a[i]); + j--; + i++; + m--; + } + + int ans = 0; + for(int k = 0; k Date: Mon, 30 Jan 2023 12:15:48 +0530 Subject: [PATCH 12/19] Add files via upload --- 432A_Choosing_Teams.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 432A_Choosing_Teams.cpp diff --git a/432A_Choosing_Teams.cpp b/432A_Choosing_Teams.cpp new file mode 100644 index 0000000..93bf9c1 --- /dev/null +++ b/432A_Choosing_Teams.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; + +int main() +{ + int n,k; + cin>>n>>k; + + int arr[n]; + int x; + int ans = 0; + for(int i = 0;i>x; + arr[i]=x; + if(x+k <= 5) + { + ans++; + } + } + cout< Date: Wed, 1 Feb 2023 17:31:12 +0530 Subject: [PATCH 13/19] Sorting, Implementation --- 490A_Team_Olympiad.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 490A_Team_Olympiad.cpp diff --git a/490A_Team_Olympiad.cpp b/490A_Team_Olympiad.cpp new file mode 100644 index 0000000..7718af2 --- /dev/null +++ b/490A_Team_Olympiad.cpp @@ -0,0 +1,82 @@ +#include +using namespace std; + +int main() +{ + int n; + cin>>n; + + int arr[n]; + for(int i = 0; i>arr[i]; + } + + int i = 0; + int j = 0; + int k = 0; + + for(int l = 0; l Date: Thu, 2 Feb 2023 12:38:38 +0530 Subject: [PATCH 14/19] String & Implementation --- 1520A_Do_Not_Be_Distracted.cpp | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 1520A_Do_Not_Be_Distracted.cpp diff --git a/1520A_Do_Not_Be_Distracted.cpp b/1520A_Do_Not_Be_Distracted.cpp new file mode 100644 index 0000000..852482a --- /dev/null +++ b/1520A_Do_Not_Be_Distracted.cpp @@ -0,0 +1,47 @@ +#include +using namespace std; + +int main() +{ + int t; + cin>>t; + while(t--) + { + int n; + cin>>n; + + string s; + cin>>s; + bool ans = true; + + unordered_mapm; + for(int i = 0; i Date: Fri, 3 Feb 2023 19:10:05 +0530 Subject: [PATCH 15/19] Math & Implementation --- 1343A_Candies.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 1343A_Candies.cpp diff --git a/1343A_Candies.cpp b/1343A_Candies.cpp new file mode 100644 index 0000000..4fec849 --- /dev/null +++ b/1343A_Candies.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; +int main() +{ + int t; + cin>>t; + while(t--) + { + int n; + cin>>n; + + for(int i=2; i<10e9; i++) + { + int p = pow(2,i) - 1; + if(n%p==0) + { + cout< Date: Sat, 4 Feb 2023 13:01:17 +0530 Subject: [PATCH 16/19] Sorting --- 1669B_Triple.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 1669B_Triple.cpp diff --git a/1669B_Triple.cpp b/1669B_Triple.cpp new file mode 100644 index 0000000..985454d --- /dev/null +++ b/1669B_Triple.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; + +int main() +{ + int t; + cin>>t; + while(t--) + { + int n; + cin>>n; + unordered_mapm; + for(int i = 0; i>x; + m[x]++; + } + + int ans = -1; + for(auto x : m) + { + if(x.second>2) + { + ans = x.first; + break; + } + } + cout< Date: Mon, 6 Feb 2023 11:58:49 +0530 Subject: [PATCH 17/19] Greedy --- 337A_Puzzles.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 337A_Puzzles.cpp diff --git a/337A_Puzzles.cpp b/337A_Puzzles.cpp new file mode 100644 index 0000000..836c825 --- /dev/null +++ b/337A_Puzzles.cpp @@ -0,0 +1,25 @@ +#include +#include + +using namespace std; + +int main() +{ + int n, m, f[1000]; + cin >> n >> m; + for (int i = 0; i < m; ++i) + { + cin >> f[i]; + } + sort(f, f + m); + int least = f[n-1] - f[0]; + for (int i = 1; i <= m - n; ++i) + { + if (f[i+n-1] - f[i] < least) + { + least = f[i+n-1] - f[i]; + } + } + cout << least << endl; + return 0; +} \ No newline at end of file From 6fa73476f227121852a00b2f0196e6e445d8c5c1 Mon Sep 17 00:00:00 2001 From: Aman Chandra <112195895+amanchandra395@users.noreply.github.com> Date: Wed, 8 Feb 2023 00:11:22 +0530 Subject: [PATCH 18/19] Implementation --- 1671C_Dolce_Vita.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 1671C_Dolce_Vita.cpp diff --git a/1671C_Dolce_Vita.cpp b/1671C_Dolce_Vita.cpp new file mode 100644 index 0000000..1552377 --- /dev/null +++ b/1671C_Dolce_Vita.cpp @@ -0,0 +1,36 @@ +#include +#include +using namespace std; + +int main(void) +{ + int tests, n, x; + cin >> tests; + for (int test = 0; test < tests; test++) + { + cin >> n >> x; + int *arr = new int[n]; + for (int i = 0; i < n; i++) + cin >> arr[i]; + sort(arr, arr + n); + int bags = 0; + long long totalCost = 0; + for (int i = 0; i < n; i++) + { + if (totalCost + arr[i] > x) + break; + totalCost += arr[i]; + bags++; + } + long long ans = 0, lastDays = 0; + for (int i = bags; i > 0; i--) + { + long long days = ((x - totalCost) / i) + 1; + ans += (days - lastDays) * i; + lastDays = days; + totalCost -= arr[i - 1]; + } + cout << ans << endl; + } + return 0; +} \ No newline at end of file From 56ebedab76443f40e31d2f3d6ff70489428b05c6 Mon Sep 17 00:00:00 2001 From: Aman Chandra <112195895+amanchandra395@users.noreply.github.com> Date: Sat, 1 Apr 2023 00:46:28 +0530 Subject: [PATCH 19/19] Add files via upload --- 476A_Dreamoon_and_Stairs.cpp | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 476A_Dreamoon_and_Stairs.cpp diff --git a/476A_Dreamoon_and_Stairs.cpp b/476A_Dreamoon_and_Stairs.cpp new file mode 100644 index 0000000..e5317bb --- /dev/null +++ b/476A_Dreamoon_and_Stairs.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; + +int main() +{ + int n,m; + cin>>n>>m; + + int ans = 0; + int h = 0; + + if(n%2 == 1) + { + h = n/2; + h++; + } + else + { + h = n/2; + } + + for(int i = h; i<=n; i++) + { + if(i%m == 0) + { + ans = i; + break; + } + } + + if(ans > 0) + { + cout<