loading...

Daily Coding Challenge #61

wingkwong profile image Wing-Kam ・2 min read

About

This is a series of Daily Coding Challenge. Each day I show a few solutions written in C++. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.


/*
AISing Programming Contest 2019 - A - Bulletin Board
https://atcoder.jp/contests/aising2019/tasks/aising2019_a
*/

#include <bits/stdc++.h>
using namespace std; 

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int h,w,n;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1);
    return 0;
} 

/*
AISing Programming Contest 2019 - B - Contests
https://atcoder.jp/contests/aising2019/tasks/aising2019_b
*/

#include <bits/stdc++.h>
using namespace std; 

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int n,a,b,p,s1=0,s2=0,s3=0;
    cin >> n >> a >> b;
    for(int i=0;i<n;i++) {
        cin >> p;
        if(p<=a) s1++;
        else if(a+1<=p&&p<=b) s2++;
        else if(p>=b+1) s3++;
    }

    cout << min({s1,s2,s3});
    return 0;
} 

// 1st: <= A
// 2nd: A+1 <= s <= B
// 3rd: s >= B+1

/*
Codeforces Round #655 (Div. 2) - A. Omkar and Completion
https://codeforces.com/contest/1372/problem/A
*/

#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()  
{ 
    FAST_INP;
    int t,n;
    cin >> t;
    while(t--){
        cin >> n;
        for(int i=0;i<n;i++){
            // ax+ay!=a 
            // X,Y,Z can be equal
            // hence, print 1 for n times 
            cout << 1 << " ";
        }
        cout << "\n";
    }
    return 0;
} 


The source code is available in corresponding repo below. Star and watch for timely updates!

GitHub logo wingkwong / leetcode

🏆 A Collection of my LeetCode Solutions with Explanations 🏆

GitHub logo wingkwong / hackerrank

🏆 A Collection of my HackerRank Solutions with Explanations 🏆

GitHub logo wingkwong / codeforces

🏆 A Collection of my Codeforces Solutions with Explanations 🏆

GitHub logo wingkwong / atcoder

🏆 A Collection of my AtCoder Solutions with Explanations 🏆

Posted on by:

wingkwong profile

Wing-Kam

@wingkwong

Consultant by day. Developer by night. AWS certified. Exploring #CloudNative currently.

Discussion

markdown guide