๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long solve(vector<int>& A) {
int N = A.size();
vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0));
for (int L = 1; L <= N; ++L) {
stack<int> stack;
int trees = 0;
for (int R = L; R <= N; ++R) {
while (!stack.empty() && A[stack.top() - 1] < A[R - 1]) {
stack.pop();
}
if (stack.empty()) {
trees++;
}
stack.push(R);
int max_trees = trees;
if (R > L) {
if (stack.size() > 1) {
max_trees = max(max_trees, trees - 1);
} else {
max_trees = max(max_trees, trees);
}
if (R - L > trees) {
max_trees = max(max_trees, trees + 1);
}
}
dp[L][R] = max_trees;
}
}
long long result = 0;
for (int i = 1; i <= N; ++i) {
for (int j = i; j <= N; ++j) {
result = (result + dp[i][j]) % MOD;
}
}
return result;
}
int main() {
int n; cin>>n;
vector<int> A;
for(int i = 0; i < n; ++i) cin>>A[i];
cout << solve(A) << endl;
return 0;
}
//So many trees
using namespace std;
const int MOD = 1e9 + 7;
long long solve(vector<int>& A) {
int N = A.size();
vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0));
for (int L = 1; L <= N; ++L) {
stack<int> stack;
int trees = 0;
for (int R = L; R <= N; ++R) {
while (!stack.empty() && A[stack.top() - 1] < A[R - 1]) {
stack.pop();
}
if (stack.empty()) {
trees++;
}
stack.push(R);
int max_trees = trees;
if (R > L) {
if (stack.size() > 1) {
max_trees = max(max_trees, trees - 1);
} else {
max_trees = max(max_trees, trees);
}
if (R - L > trees) {
max_trees = max(max_trees, trees + 1);
}
}
dp[L][R] = max_trees;
}
}
long long result = 0;
for (int i = 1; i <= N; ++i) {
for (int j = i; j <= N; ++j) {
result = (result + dp[i][j]) % MOD;
}
}
return result;
}
int main() {
int n; cin>>n;
vector<int> A;
for(int i = 0; i < n; ++i) cin>>A[i];
cout << solve(A) << endl;
return 0;
}
//So many trees
import java.util.Scanner;
public class Miain {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String S = scanner.nextLine();
StringBuilder S1 = new StringBuilder();
StringBuilder S2 = new StringBuilder();
for (int i = 0; i < S.length(); i++) {
if ((i + 1) % 2 == 0) {
S1.append(S.charAt(i));
} else {
S2.append(S.charAt(i));
}
}
System.out.println(S2.toString());
System.out.println(S1.toString());
scanner.close();
}
}
public class Miain {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String S = scanner.nextLine();
StringBuilder S1 = new StringBuilder();
StringBuilder S2 = new StringBuilder();
for (int i = 0; i < S.length(); i++) {
if ((i + 1) % 2 == 0) {
S1.append(S.charAt(i));
} else {
S2.append(S.charAt(i));
}
}
System.out.println(S2.toString());
System.out.println(S1.toString());
scanner.close();
}
}
vector<string> areAlmostEquivalent(vector<string>& s, vector<string>& t) {
vector<string> result;
auto countCharacters = [](const string& str) {
vector<int> count(26, 0);
for (char c : str) {
count[c - 'a']++;
}
return count;
};
for (size_t i = 0; i < s.size(); ++i) {
const string& str_s = s[i];
const string& str_t = t[i];
vector<int> count_s = countCharacters(str_s);
vector<int> count_t = countCharacters(str_t);
bool isAlmostEquivalent = true;
for (int j = 0; j < 26; ++j) {
if (abs(count_s[j] - count_t[j]) > 3) {
isAlmostEquivalent = false;
break;
}
}
if (isAlmostEquivalent) {
result.push_back("YES");
} else {
result.push_back("NO");
}
}
return result;
}
// Almost equivalent String โ
vector<string> result;
auto countCharacters = [](const string& str) {
vector<int> count(26, 0);
for (char c : str) {
count[c - 'a']++;
}
return count;
};
for (size_t i = 0; i < s.size(); ++i) {
const string& str_s = s[i];
const string& str_t = t[i];
vector<int> count_s = countCharacters(str_s);
vector<int> count_t = countCharacters(str_t);
bool isAlmostEquivalent = true;
for (int j = 0; j < 26; ++j) {
if (abs(count_s[j] - count_t[j]) > 3) {
isAlmostEquivalent = false;
break;
}
}
if (isAlmostEquivalent) {
result.push_back("YES");
} else {
result.push_back("NO");
}
}
return result;
}
// Almost equivalent String โ
๐1
SELECT
sector,
SUM(CAST(REPLACE(REPLACE(capitalization, 'B', '000000000'), 'M', '000000') AS DECIMAL(20, 2))) / 1000000 AS total_capitalization
FROM
companies
WHERE
sector != 'n/a' AND capitalization != 'n/a'
GROUP BY
sector
ORDER BY
sector;
SQL stock confirm
SQL: Calendar Application Events Report 2
SELECT
e.dt,
e.title,
GROUP_CONCAT(CONCAT(g.full_name, ' <', g.email_address, '>') ORDER BY g.full_name SEPARATOR ', ') AS guests
FROM
events e
JOIN
events_guests eg ON e.id = eg.event_id
JOIN
guests g ON eg.guest_id = g.id
WHERE
g.on_vacation = 0
GROUP BY
e.id, e.dt, e.title
ORDER BY
e.dt ASC
LIMIT 5;
๐1
def getMinCores(start, end):
events = [(t, 1) for t in start] + [(t, -1) for t in end]
events.sort(key=lambda x: (x[0], -x[1]))
max_cores = 0
current_cores = 0
for time, event_type in events:
if event_type == 1:
current_cores += 1
else:
current_cores -= 1
max_cores = max(max_cores, current_cores)
return max_cores
Process Scheduler โ
events = [(t, 1) for t in start] + [(t, -1) for t in end]
events.sort(key=lambda x: (x[0], -x[1]))
max_cores = 0
current_cores = 0
for time, event_type in events:
if event_type == 1:
current_cores += 1
else:
current_cores -= 1
max_cores = max(max_cores, current_cores)
return max_cores
Process Scheduler โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
const int MOD = 1000000007;
using namespace std;
void dfs(int node, const unordered_map<int, vector<pair<int, int>>>& tree, vector<long long>& magnitudes) {
auto it = tree.find(node);
if (it != tree.end()) {
for (const auto& neighbor : it->second) {
int next_node = neighbor.first;
int weight = neighbor.second;
magnitudes[next_node] = (magnitudes[node] * weight) % MOD;
dfs(next_node, tree, magnitudes);
}
}
}
vector<int> findEquivalentMagnitude(int unit_nodes, vector<int> unit_from, vector<int> unit_to, vector<int> unit_weight, int x) {
unordered_map<int, vector<pair<int, int>>> tree;
for (int i = 0; i < unit_from.size(); ++i) {
tree[unit_from[i]].emplace_back(unit_to[i], unit_weight[i]);
}
vector<long long> magnitudes(unit_nodes + 1, -1);
magnitudes[1] = x;
dfs(1, tree, magnitudes);
vector<int> result(unit_nodes);
for (int i = 1; i <= unit_nodes; ++i) {
result[i - 1] = magnitudes[i];
}
return result;
}
#include <vector>
#include <unordered_map>
#include <algorithm>
const int MOD = 1000000007;
using namespace std;
void dfs(int node, const unordered_map<int, vector<pair<int, int>>>& tree, vector<long long>& magnitudes) {
auto it = tree.find(node);
if (it != tree.end()) {
for (const auto& neighbor : it->second) {
int next_node = neighbor.first;
int weight = neighbor.second;
magnitudes[next_node] = (magnitudes[node] * weight) % MOD;
dfs(next_node, tree, magnitudes);
}
}
}
vector<int> findEquivalentMagnitude(int unit_nodes, vector<int> unit_from, vector<int> unit_to, vector<int> unit_weight, int x) {
unordered_map<int, vector<pair<int, int>>> tree;
for (int i = 0; i < unit_from.size(); ++i) {
tree[unit_from[i]].emplace_back(unit_to[i], unit_weight[i]);
}
vector<long long> magnitudes(unit_nodes + 1, -1);
magnitudes[1] = x;
dfs(1, tree, magnitudes);
vector<int> result(unit_nodes);
for (int i = 1; i <= unit_nodes; ++i) {
result[i - 1] = magnitudes[i];
}
return result;
}
int findMaxUses(vector<int>& costs, vector<int>& uses, int budget) {
int n = costs.size();
if (n < 2) {
return -1;
}
vector<pair<int, int>> ft;
for (int i = 0; i < n; ++i) {
ft.push_back({costs[i], uses[i]});
}
sort(ft.begin(), ft.end());
int mu = -1;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
int tc = ft[i].first + ft[j].first;
if (tc <= budget) {
int bg = ft[i].second + ft[j].second;
mu = max(mu, bg);
} else {
break;
}
}
}
return mu;
}
DE Shaw โ
int n = costs.size();
if (n < 2) {
return -1;
}
vector<pair<int, int>> ft;
for (int i = 0; i < n; ++i) {
ft.push_back({costs[i], uses[i]});
}
sort(ft.begin(), ft.end());
int mu = -1;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
int tc = ft[i].first + ft[j].first;
if (tc <= budget) {
int bg = ft[i].second + ft[j].second;
mu = max(mu, bg);
} else {
break;
}
}
}
return mu;
}
DE Shaw โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Almabase is hiring for Frontend engineering intern- Remote
Batch: 2024/2025/2026/2027
Stipend: โน40,000
Apply here: https://wellfound.com/l/2AoQyy
Batch: 2024/2025/2026/2027
Stipend: โน40,000
Apply here: https://wellfound.com/l/2AoQyy
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Bizup is hiring for Software Development Engineer
Expected Salary: 5-10 LPA
Apply here:
https://expertia.ai/bizup-app/job/hiring-software-development-engineer-65cd9bdd6146d4c2bb817876?easy_apply=true&date-refresh=07/10/2024
Expected Salary: 5-10 LPA
Apply here:
https://expertia.ai/bizup-app/job/hiring-software-development-engineer-65cd9bdd6146d4c2bb817876?easy_apply=true&date-refresh=07/10/2024
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
ReachInbox is hiring for Frontend Engineer
Expected Salary: 25k-35k per month
Apply here:
https://careers.outbox.vc/associate-frontend-engineer-179835/
Expected Salary: 25k-35k per month
Apply here:
https://careers.outbox.vc/associate-frontend-engineer-179835/
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Unomok is hiring for Machine Learning Engineer - Intern
Expected Stipend: 15K-50K per month
Apply here:
https://wellfound.com/jobs/3053954-machine-learning-engineer-intern
Expected Stipend: 15K-50K per month
Apply here:
https://wellfound.com/jobs/3053954-machine-learning-engineer-intern
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Vance is hiring for Backend Engineering Intern
Expected Stipend: 4-8 LPA
Apply here:
https://jobs.ashbyhq.com/Vance/99886987-e912-4c24-bddc-a0802c028e53
Expected Stipend: 4-8 LPA
Apply here:
https://jobs.ashbyhq.com/Vance/99886987-e912-4c24-bddc-a0802c028e53