Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 998244353;
signed main() {
int n,m;
cin >> n >> m;
vector<int> a(n),b(m);
for(int i=0; i<n; i++)
cin >> a[i];
for(int i=0; i<m; i++)
cin >> b[i];
int ans = 0;
sort(a.begin(),a.end());
sort(b.begin(),b.end());
for(int i=0; i<m; i++)
{
if(b[i] < a[0])
ans += n;
else
break;
}
cout << ans;
}
#include<bits/stdc++.h>
#define ll long long int
#define llu unsigned long long int
#define FOR(i, t) for(int i = 0;i < (t);i++)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
//
//
int main()
{
int n, m;
cin >> n >> m;
vector<int> a;
vector<int> b;
vector<int> :: iterator itr;
for(int i = 0;i < n;i++)
{
int x;
cin >> x;
a.push_back(x);
}
for(int i = 0;i < m;i++)
{
int x;
cin >> x;
b.push_back(x);
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
ll ans = 0;
for(int i = 0;i < m;i++)
{
if(b[i] < a[0])
{
ans+=n;
}
}
cout << ans << endl;
return 0;
}
# cook your dish here
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ma = min(A)
x = 0
for i in B:
if i < ma:
x += N
print(x)
#include <stdio.h>
int main()
{
long n,m;
scanf("%lu %lu",&n,&m);
long a[n],b[m];
long i=1,j=1,z=0,min;
while(i<=n)
{
scanf("%lu",&a[i]);
if(i==1)
min=a[1];
else
if(a[i]<min)
min=a[i];
i++;
}
while(j<=m)
{
scanf("%lu",&b[j]);
if(b[j]>=min)
z++;
j++;
}
if(z)
printf("%lu",(m-z)*n);
else
printf("%lu",m*n);
return 0;
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static long M = 1000000007;
//FOR PAIR PROGRAMMING, DM ME IN LINKEDIN: https://www.linkedin.com/in/pravin-mudaliyar-022498224/
public static void main (String[] args) throws java.lang.Exception
{
FastReader s = new FastReader();
BufferedWriter output = new BufferedWriter(
new OutputStreamWriter(System.out));
int N = s.nextInt();
int M = s.nextInt();
int min = Integer.MAX_VALUE;
for(int i = 0; i < N; i++) {
min = Math.min(min, s.nextInt());
}
long ans = 0;
for (int i = 0; i < M; i++) {
int val = s.nextInt();
if (val < min) {
ans += N;
}
}
output.write(ans + "\n");
output.flush();
}
private static int[] takeArrInput(FastReader fr, int N) {
int[] arr = new int[N];
for (int i = 0; i < N; i++) {
arr[i] = fr.nextInt();
}
return arr;
}
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
#Created by Pradeep
def solve():
n,m=map(int, input().split())
arr=list(map(int, input().split()))
brr=list(map(int, input().split()))
mi=min(arr)
brr.sort()
ans=0
for i in brr:
if i<mi:
ans+=n
print(ans)
solve()
st = raw_input().split()
N = int(st[0])
M = int(st[1])
st = raw_input().split()
sm = int(st[0])
for x in st:
n = int(x)
if n < sm:
sm = n
# endif
# endfor x
st = raw_input().split()
tot = 0
for x in st:
n = int(x)
if n < sm:
tot += 1
# endif
# endfor x
r = tot*N
print r
using System;
using System.Collections.Generic;
public class Test
{
private static void Fill(IList<long> list, ref string str)
{
checked
{
list.Clear();
var strIdx = 0;
long sign = 1;
long curr = 0;
while (strIdx < str.Length)
{
if (str[strIdx] == ' ')
{
list.Add(sign * curr);
curr = 0;
sign = 1;
}
else if (str[strIdx] == '-')
{
sign = -1;
curr = 0;
}
else
{
curr *= 10;
curr += (long)(str[strIdx] - '0');
}
strIdx++;
}
list.Add(sign * curr);
}
}
private interface IInputReader
{
string ReadInput();
}
private class ConsoleReader : IInputReader
{
public string ReadInput() => Console.ReadLine().Trim();
}
public static void Main()
{
checked
{
//var reader = new DebugReader();
var reader = new ConsoleReader();
// var tests = int.Parse(reader.ReadInput());
List<long> nm = new List<long>(2);
List<long> a = new List<long>();
List<long> b = new List<long>();
//for (int test = 0; test < tests; test++)
{
var str = reader.ReadInput();
Fill(nm, ref str);
var n = (int) nm[0];
var m = (int) nm[1];
str = reader.ReadInput();
Fill(a, ref str);
str = reader.ReadInput();
Fill(b, ref str);
b.Sort();
a.Sort();
long res = 0;
var min = a[0];
for (int i = 0; i < m; i++)
{
if (b[i] < min)
{
res += n;
}
else
{
min = b[i];
}
}
Console.WriteLine(res);
}
}
}
}
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
n, m := readTwoNums(reader)
A := readNNums(reader, n)
B := readNNums(reader, m)
fmt.Println(solve(A, B))
}
func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}
func readNum(reader *bufio.Reader) (a int) {
bs, _ := reader.ReadBytes('\n')
readInt(bs, 0, &a)
return
}
func readTwoNums(reader *bufio.Reader) (a int, b int) {
res := readNNums(reader, 2)
a, b = res[0], res[1]
return
}
func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
res := readNNums(reader, 3)
a, b, c = res[0], res[1], res[2]
return
}
func readNNums(reader *bufio.Reader, n int) []int {
res := make([]int, n)
x := 0
bs, _ := reader.ReadBytes('\n')
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
x = readInt(bs, x, &res[i])
}
return res
}
func readUint64(bytes []byte, from int, val *uint64) int {
i := from
var tmp uint64
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + uint64(bytes[i]-'0')
i++
}
*val = tmp
return i
}
func solve(A []int, B []int) int64 {
var num = A[0]
for i := 1; i < len(A); i++ {
if A[i] < num {
num = A[i]
}
}
var res int64
n := int64(len(A))
for i := 0; i < len(B); i++ {
if B[i] < num {
res += n
}
}
return res
}
func search(n int, fn func(int) bool) int {
left, right := 0, n
for left < right {
mid := (left + right) / 2
if fn(mid) {
right = mid
} else {
left = mid + 1
}
}
return right
}
func reverse(arr []int) {
for i, j := 0, len(arr)-1; i < j; i, j = i+1, j-1 {
arr[i], arr[j] = arr[j], arr[i]
}
}
In our experience, we suggest you solve this Array Swaps CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Array Swaps CodeChef Solution.
I hope this Array Swaps CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.
Keep Learning!