prompt string | response string |
|---|---|
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... |
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
public class CFContest {
public static void main(String[] args) throws Exception {
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Arr... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int n, a[400010], cnt[21];
long long inv[21][21], f[(1 << 21) + 1];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", a + i);
for (int j = 1; j <= 20; ++j) inv[a[i]][j] += cnt[j];
++cnt[a[i]];
}
for (int i = 1; i < (1 << 20); ++i) ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
long long n, x;
long long num[21], f[1 << 20], g[21][21];
int main() {
cin >> n;
for (; n--;) {
cin >> x;
++num[--x];
for (int i = 0; i < 20; ++i) g[x][i] += num[i];
}
memset(f, 1, sizeof(f));
f[0] = 0;
for (int i = 0; i < 1 << 20; ++i)
for (int ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 20;
vector<vector<long long>> pre(N, vector<long long>(N));
vector<long long> dp(1 << N, -1);
vector<int> A;
vector<long long> cnt(N);
long long func(int mask) {
if (mask == (1 << N) - 1) return 0;
if (dp[mask] != -1) return dp[mask];
long long ans = 100... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int a[400007];
int c[400007];
long long f[(1 << 20) + 7];
long long dp[(1 << 20) + 7][27];
int cnt[27];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
c[i] = a[i];
}
sort(c + 1, c + 1 + n);
int m = unique(c + 1, c + 1 + n) - c ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
vector<int> num;
long long dp[1 << 20], c[21];
long long w[21][21], val[1 << 20][21];
int vis[21], b[21], a[maxn], sum[21];
bool vit[21];
void judge(int x) {
num.clear();
for (int i = 1; x; i++) {
if (x & 1) num.push_back(i);
x >>= 1;
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int mx = (1 << 20), N = 25;
long long dp[mx], tot[25], cnt[N][N];
int main() {
int n, x;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &x);
x--;
for (int j = 0; j < 20; ++j) cnt[x][j] += tot[j];
tot[x]++;
}
memset(dp, 0x3f, size... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
using ii = pair<long long int, long long int>;
class prioritize {
public:
bool operator()(ii &p1, ii &p2) { return p1.first < p2.first; }
};
auto start_time = high_resolution_clock::now();
void time() { return; }
void ojudge() {
ios_base::s... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.util.*;
public class HelloWorld{
public static void main(String []args)throws IOException{
BufferedReader re = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(re.readLine());
ArrayList<ArrayList<Integer>> l... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
return p1 == p2 ? EOF : *(p1++);
}
template <class T>
inline void read(T &n) {
n = 0;
register int ch = gc();
while (ch < '0' || ch > '9') ch... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import sys
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
M = [[0 for i in range (0, 21)] for j in range (0, 21)]
F = [0 for i in range (0, 21)]
for i in range (0, n):
x = int(a[i])
for j in range (0, 21):
if j != x:
M[j][x] = M[j][x] + F[j]
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.util.Comparator.*;
public class Main {
FastScanner in;
PrintWriter out;
ArrayList<Integer>[] graph;
ArrayList<GraphPair>[] weightedGraph;
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class E_Marbles {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader inp = new InputReader(inputStream);
PrintWriter out = new ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 4e6 + 7;
long long odej[30][30];
long long dp[N];
int t[N], n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> t[i];
}
for (int kol = 1; kol <= 20; kol++) {
int zm = 0;
for (int i = n - 1; i >= 0; i--) {
if (t[i] == kol)
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
long long n, x;
long long num[21], f[1 << 20], g[21][21];
int main() {
cin >> n;
for (; n--;) {
cin >> x;
++num[--x];
for (int i = 0; i < 20; ++i) g[x][i] += num[i];
}
memset(f, 9, sizeof(f));
f[0] = 0;
for (int i = 0; i < 1 << 20; ++i)
for (int ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
const long long inf = 1e18;
using namespace std;
inline int read() {
int x = 0, y = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') y = 1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return y... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
inline long long read() {
long long num = 0, flag = 1;
char c = ' ';
for (; c > '9' || c < '0'; c = getchar())
if (c == '-') flag = 0;
for (; c >= '0' && c <= '9';
num = (num << 1) + (num << 3) + c - 48, c = getchar())
;
retu... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimization("unroll-loops")
using namespace std;
using int64 = long long;
const int N = 4e5 + 5, M = 20;
int ar[N];
int cb[M];
int64 cost[M][M];
int64 dp[1 << M];
bool visited[1 << M];
int mai... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int n, a, siz[21];
const long long inf = 1e11;
const int cnt = 20;
long long dp[1048576], w[21][21];
int main() {
scanf("%d", &n);
for (register int i = 1; i <= n; ++i) {
scanf("%d", &a);
++siz[a];
for (register int j = 1; j <= cnt; ++j) w[j][a] += siz[j];
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.util.*;
//import javafx.util.*;
import java.math.*;
//import java.lang.*;
public class Main
{
// static int n;static ArrayList<Integer> arr[];
// static int m;
// static boolean v[];
// int ans[];
public static void main(String[] args) throws IOException {
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
long long q_pow(long long x, long long n, long long mod) {
long long ret = 1;
while (n) {
if (n & 1) ret = x * ret % mod;
x = x * x % mod;
n >>= 1;
}
return ret;
}
long long __gcd(long long x, long long y) {
if (!y) return x;
return __gcd(y, x % y);
}
int dx[] = {-1, 1, ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10, mx = 1 << 20;
long long s[30], cnt[30][30], dp[N];
int main() {
int n, x;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &x);
for (int j = 1; j <= 20; ++j) cnt[x][j] += s[j];
s[x]++;
}
memset(dp, 0x3f, sizeof dp);
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
long long n, x, k, z, m, pos, q;
long long b[100500];
vector<long long> g, f;
long long a[400500];
long long pa[400500][22], sum[22], pr[22][22];
long long dp[1048576 + 15];
long long get_sum(long long num, long long l, long long r) {
return pa[r + 1][num] - pa[l][num];
}... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
template <class T>
bool ckmin(T& a, const T& b) {
return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
return a < b ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.util.*;
import java.io.*;
public class Main{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new Main();
out.flush(); out.close();
}
Main(){
solve(... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | //package round585;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class E {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
static AReader scan = new AReader();
static void slove(){
int n = scan.nextInt();
int[] a = new int[n];
for(int i... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
inline int read() {
char c;
int x;
for (c = getchar(); !isdigit(c); c = getchar())
;
for (x = 0; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
}
return x;
}
const int N = 20, M = 5e5 + 5, A = 1 << N;
int n, m, all, a[M], cnt[N];
long long w[N][N], f[A];
int main() {
n... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 400000 + 10;
int n, i, a[N], cr[N][30], cl[N][30], j, k;
long long tmp1, tmp2, ans, x;
int main() {
scanf("%d", &n);
for (i = 1; i <= n; i++) scanf("%d", &a[i]);
for (i = 1; i <= n; i++) {
for (j = 1; j <= 20; j++) cl[i][j] = cl[i - 1][j];
cl[i][... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int num[400005];
int tot = 0;
set<int> st;
int mp[20];
int freq[20];
long long push[20][20];
long long addp[20][1048576];
vector<int> pos[20];
long long sum[20];
int cnt[20];
long long memo[1048576];
long long cost(int mask, int ofst, int id) {
return sum[id] + addp[id][m... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
char ch = getchar();
long long f = 1, x = 0;
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | /**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static MyScanner scan;
static PrintWriter pw;
static long MOD = 1_000_000_007;
static long INF = 1_000_000_000_000_000_000L;
static long inf = 2_000_000_000;
public static void main(Strin... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 20;
long long dp[(1 << 20) + 66];
long long f[maxn + 6][maxn + 6];
long long sum[26];
int cnt[26];
int n, a[400006];
bool mybool[26];
set<int> Set;
set<int>::iterator it;
map<int, int> Map;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scan... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
const int maxn = 4e5 + 10;
const int maxm = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-7;
using namespace std;
long long cnt[25][25], dp[1 << 21];
int n;
vector<int> pos[25];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
int n, col, a[400005], cnt[25];
long long dp[1 << 20], sum[25], con[25][25];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", a + i), col = std::max(col, a[i]),
sum[a[i]] += i - cnt[a[i]] - 1, ++cnt[a[i]];
for (int i = 1; i <= col; ++i) {
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
long long n, x;
long long num[21], f[1 << 20], g[21][21];
int main() {
cin >> n;
for (; n--;) {
cin >> x;
++num[--x];
for (int i = 0; i < 20; ++i) g[x][i] += num[i];
}
memset(f, 99, sizeof(f));
f[0] = 0;
for (int i = 0; i < 1 << 20; ++i)
for (int... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.util.*;
import static jdk.nashorn.internal.objects.Global.print;
/**
* A simple template for competitive programming problems.
*/
public class Banana {
final InputReader in = new InputReader(System.in);
final PrintWriter out = new PrintWriter(System.out);
boolean DEBUG = f... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class Ty>
Ty randint(Ty a, Ty b) {
return uniform_int_distribution<Ty>(a, b)(rng);
}
template <class T>
void DBG(T&& x) {
cerr << x << " ";
}... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int n, A[400005];
int S[25][400005];
long long f[1 << 20], T[25][25], all[25];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &A[i]);
S[A[i]][i]++;
for (int j = 1; j <= 20; j++) {
S[j][i] += S[j][i - 1];
T[A[i]][j] += S[... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20;
long long a[maxn];
long long dp[maxn];
long long cnt[22][22], tot[22];
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
a[i]--;
for (int j = 0; j < 20; j++) {
cnt[a[i]][j] += tot[j];
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.util.*;
import java.io.*;
public class Solution{
public static Integer INT(String s){
return Integer.parseInt(s);
}
public static Long LONG(String s){
return Long.parseLong(s);
}
//==================================================================================================================... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
long long int cost[25][25], occ[25], f[25][(1 << 20) + 5], d[1 << 20];
int n;
int a[400005];
inline long long int calcCost(int x, int y) {
long long int cnt = 0;
long long int res = 0;
for (int i = 1; i <= n; i++) {
if (a[i] == x) cnt++;
if (a[i] == y) res += ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
int n, m, k, sy;
int cas;
vector<int> v[25];
long long val[25][25];
long long dp[1100000];
signed main() {
scanf("%d", &n);
for (int i = 1, x; i <= n; i++) {
scanf("%d", &x);
v[x].push_back(i);
}
for (int i = 1; i <= 20; i++) {
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
const int N = 400005;
const int M = 1048580;
const long long inf = (long long)1e18;
int n, m, a[N], bin[25], ls[25];
long long lef[25][M], f[M];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]), m = std::max(m, a[i]);
bin[0] = 1;
for (int i = 1; i <= m; i++)... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 4e5, M = 20;
long long cnt[M][1 << M], dp[1 << M];
int n, a[N], sum[N][M];
vector<int> pos[M];
inline void read_input() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
}
inline void solve() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < M; ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 13;
const int M = 21;
const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
int n;
long long d[(1 << M)];
long long cnt[M][M];
vector<int> col[M];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
template <class T>
bool rmn(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool rmx(T &a, T b) {
return a < b ? (a = b, true) : false;
}
const long long INFLL = 0x7f7f7f7f7f7f7f7f, MOD = 1e9 + 7;
const long long INF = 0x7f7f7f7f;
vector<vector<p... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
const long long int MAXN = 4e5 + 10;
const long long int MAXM = (1 << 20);
long long int a[MAXN];
long long int count_ahea... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.util.Arrays;
import java.util.Scanner;
public class r585e {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int[] a=new int[n];
m=0;
f=new long[20];
before=new long[20][20];
moves=new long[20];
for(int i=0;i<n;i++) {
a[i]=scan.nextInt(... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner sc = new FastScanner();
int N = sc.nextInt();
int[] nums = new int[N];
ArrayList<Integer>[] locs = new ArrayList[20];
for (int i = 0; i < 20; i... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
long long rd() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
public class Main {
public static void main(String[] args) {
FS reader = new FS();
// write reader
int n = reader.nextInt();
ArrayList<Integer>[] a = new ArrayList[20];
for (in... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5;
const long long mod = 1e9 + 7;
long long pw(long long b, long long r, long long md = mod) {
b = b % md;
long long ans = 1;
while (r) {
if (r & 1) ans = (ans * b) % md;
b = (b * b) % md;
r >>= 1;
}
return ans;
}
long long... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << "\n";
err(++it, args...);
}
const lo... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int n, k, a[N], b[N], sum[22];
long long dp[1050000], cnt[22][22];
inline void Do(long long &x, long long y) {
if ((~x && x > y) || x == -1) x = y;
}
int main() {
scanf("%d", &n);
register int i, j, o;
for (i = 1; i <= n; i++) scanf("%d", &a[... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
const inline bool Get_bit(const int &a, const int &i) { return (a >> i) & 1; }
const inline int Change_bit(const int &a, int const &i) { return a ^ (1 << i); }
int main() {
cin.tie(NULL);
cout.tie(NUL... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
int a[400005], b[400005];
int h[21];
long long dp[2100000];
long long f[21][21];
int num[21];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if (!h[a[i]]) h[a[i]] = ++m;
b[i] = h[a[i]];
}
for (int i = n; i >= 1... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
long long dp[1 << 20ll];
long long addon[1 << 20ll][20];
long long arr[400009];
long long adder[21][21];
long long sumas[21];
int main() {
long long kurac = 0;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
kurac |= (1 << (arr[i] - 1));
su... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 4e5 + 5;
const ll M = 1e18 + 7;
int a[N];
ll dp[(1 << 20)][20];
ll d[20][20], suff[N][20];
ll sum[N], cnt[N];
void solve() {
for (int mask = 0; mask < (1 << 20); ++mask) {
for (int i = 0; i < 20; ++i) {
dp[mask][i] = M;
}
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in range(1, 21):
for j in range(1, 21):
d[(i, j)] = 0
cv = [0 for i in range(21)]
for j in a:
for i in range(1, 21):
d[(i, j)] += cv[i]
cv[j] += 1
s = 0
for i in range(1, 21):
for j in range(i+1, 21):
s += min... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.util.*;
import java.io.*;
public class Practice {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
private static final long MOD = 1000L * 1000L * 1000L + 7;
private static final int[] dx = {0, -1, 0, 1};
private static final int[] dy = {1, 0, -1, 0};
private static fina... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | # ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
int n, a[N], c[N], b[N], nb;
long long g[20][20], f[1 << 20];
void bin(int x) {
for (int i = 0; i < nb; ++i) printf("%d", x >> i & 1);
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scan... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
long long q_pow(long long x, long long n, long long mod) {
long long ret = 1;
while (n) {
if (n & 1) ret = x * ret % mod;
x = x * x % mod;
n >>= 1;
}
return ret;
}
long long __gcd(long long x, long long y) {
if (!y) return x;
return __gcd(y, x % y);
}
int dx[] = {-1, 1, ... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
char ch = getchar();
long long f = 1, x = 0;
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.util.Comparator.*;
public class Main {
FastScanner in;
PrintWriter out;
ArrayList<Integer>[] graph;
ArrayList<GraphPair>[] weightedGraph;
... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | #include <bits/stdc++.h>
using namespace std;
int n;
long long pre[20][20];
int a[400005];
void fpre() {
vector<int> c(20, 0);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 20; j++) pre[j][a[i]] += c[j];
c[a[i]]++;
}
}
long long dp[1 << 20];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(n... |
Problem: Monocarp has arranged n colored marbles in a row. The color of the i-th marble is a_i. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color).
In other words, Monocarp wants ... | import java.util.*;
import java.io.*;
public class Solution{
public static Integer INT(String s){
return Integer.parseInt(s);
}
public static Long LONG(String s){
return Long.parseLong(s);
}
//==================================================================================================================... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
struct Node {
int t, a, b;
} p[MAXN];
inline bool cmp(const Node &p, const Node &q) { return p.t < q.t; }
void solve(void) {
int n, m, c, beg;
scanf("%d%d%d%d", &n, &m, &c, &beg);
for (int i = 1; i <= n; ++i) scanf("%d%d%d", &p[i].t, &p[i].... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int MaxN = 500005;
int test, n, m, c, c0;
tuple<int, int, int> Query[MaxN];
map<int, int> mp;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> test;
while (test--) {
cin >> n >> m >> c >> c0;
int t, a, b;
for (int i ... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int arr = 2e5 + 10;
const int ar = 2e3 + 10;
const long double pi = acos(-1);
const long double eps = 1e-10;
const long long md = 1e9 + 7;
int t[(int)(2e6 + 10)];
int a[(int)(2e6 + 10)];
int b[(int)(2e6 + 10)];
vector<int> vh[(int)(2e6 + 10)];
int tt[(int)(2e6 + 10)];... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | import java.util.*;
import java.io.*;
//textbook pitcher pouring problem
public class AbildekWaterSystem {
public static void main(String[] args) {
FastScanner scanner = new FastScanner();
PrintWriter out = new PrintWriter(System.out, false);
int q = scanner.nextInt();
top:
... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll solve() {
ll N, M, C, C0;
cin >> N >> M >> C >> C0;
vector<int> ord(N);
for (int i = 0; i < (N); i++) ord[i] = i;
vector<ll> T(N), A(N), B(N);
for (int i = 0; i < (N); i++) cin >> T[i] >> A[i] >> B[i];
ord.push_back(N);
T.push_back(M... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n, m, CAP, c0;
cin >> n >> m >> CAP >> c0;
vector<tuple<int, int, int>> evs(n);
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
evs[i] = {x, y, z};
}
evs.emplace_back(m, 0, 0);
sort(evs.begin(... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int N = 500 * 1000 + 13;
int n, m, c, c0;
pair<int, pair<int, int> > a[N];
long long solve() {
scanf("%d%d%d%d", &n, &m, &c, &c0);
for (int i = 0; i < int(n); ++i)
scanf("%d%d%d", &a[i].first, &a[i].second.first, &a[i].second.second);
a[n++] = make_pair(m, m... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 7;
const int inf = INT_MAX;
const long long inff = 1e18;
const long long mod = 1e9 + 7;
long long q;
long long n, m, c0, c;
vector<long long> v;
long long t[maxn], a[maxn], b[maxn];
multimap<long long, long long> mm;
int32_t main() {
ios::sync_with_... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
int main() {
ios::sync_with_stdio(false);
int q;
cin >> q;
while (q--) {
int n, m, c;
cin >> n >> m >> c;
int c0;
cin >> c0;
vector<int> t(n, 0), a = t, b = t;
for (int i ... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
template <typename T>
inline void Read(T &t) {
int c = getchar(), f = 0;
for (; c < '0' || c > '9'; c = getchar()) f = (c == '-');
for (t = 0; c >= '0' && c <= '9'; c = getchar())
t = (t << 3) + (t << 1) + (c ^ 48);
if (f) t = -t;
}
const... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int Nmax = 5e5 + 112;
int q, n, m, c, c0, T;
long long ans = 0;
bool check = false;
struct person {
int t, a, b;
bool operator<(person other) const { return t < other.t; }
} p[Nmax];
multiset<pair<int, int> > s;
int main() {
ios::sync_with_stdio(0);
cin.tie(0)... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
int n, i, q, m, c, c0, tot;
struct str {
int t, a, b;
} a[500005];
long long ans;
multiset<pair<int, int> > s;
bool cmp(str a, str b) { return a.t < b.t; }
int main() {
scanf("%d", &q);
while (q--) {
scanf("%d %d %d %d", &n, &m, &c, &c0);
for (i = 1; i <= n; i... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
void add(map<pair<long long, long long>, long long> &mp,
pair<long long, long long> elem) {
if (mp.count(elem) == 0) {
mp.insert({elem, 1});
} else {
mp[elem]++;
}
}
void del(map<pair<long long, long long>, long long> &mp,
pair<long long, lon... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
template <typename T>
inline void read(T &AKNOI) {
T x = 0, flag = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') flag = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
struct man {
long long t, a, b;
man() : t(0) {}
man(long long t, long long a, long long b) : t(t), a(a), b(b) {}
};
bool cmp(const man a, const man b) { return a.t < b.t; }
long long q, ans, sum;
long long n, m, c0, c;
long long tmp, rt, k;
bool tf = 1;
man arr[500000... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
namespace input {
template <class T>
inline void _R(T& x) {
cin >> x;
}
template <class T1, class T2>
inline void _R(pair<T1, T2>& x) {
_R(x.first);
_R(x.second);
}
template <class T>
inline void _R(vector<T>& x) {
for (auto& i : x) _R(... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
template <typename T>
inline T read() {
T sum = 0, fl = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') fl = -1;
for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
return sum * ... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
struct Fr {
int t, a, b;
} fr[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int q;
cin >> q;
while (q--) {
int n, m, c, c0;
cin >> n >> m >> c >> c0;
for (int i = 0; i < n; i++) {
cin >> fr[i].t >> fr[i].a... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
int test;
int n;
long long m, c, c0, c1;
set<pair<long long, long long> > s;
vector<pair<long long, pair<long long, long long> > > fr;
long long ans = 0;
void inserting(pair<long long, long long> p) {
auto itf = s.lower_bound({p.first, 0});
if (itf == s.end() || (itf->f... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
struct cojo {
int t, a, b;
};
cojo t[500005];
map<int, int> q;
bool mycmp(cojo a, cojo b) {
if (a.t == b.t)
if (a.a == b.a)
return a.b < b.b;
else
return a.a < b.a;
else
return a.t < b.t;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
void _in(long long *a, ...) {
va_list arg_ptr;
scanf("%I64d", a);
long long *temp;
va_start(arg_ptr, a);
temp = va_arg(arg_ptr, long long *);
while (temp) {
scanf("%I64d", temp);
temp = va_arg(arg_ptr, long long *);
}
va_end(arg_ptr);
}
void _in(int ... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
template <typename T, typename E, typename F, typename G, typename H>
struct LazySegmentTree {
private:
int n, height;
F f;
G g;
H h;
T ti;
E ei;
vector<T> dat;
vector<E> laz;
T reflect(int k) { return laz[k] == ei ? dat[k] : g(dat[k], laz[k]); }
void p... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
struct node {
int time, liter, price;
} a[550000];
int q, n, m, c0, c;
map<int, int> tank;
long long ans;
bool comp(node x, node y) {
if (x.time < y.time)
return (true);
else
return (false);
}
long long work() {
tank[0] = c0;
int t = 0, delta, tot = c0;
... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
const int N = 500500;
using namespace std;
int n;
int m;
int c;
int c0;
int st[N];
int t[4 * N];
int shit[4 * N];
vector<pair<int, pair<int, int> > > a;
void build(int x, int l, int r) {
shit[x] = 0;
if (l == r) {
t[x] = c0 - a[l].first;
return;
}
int m = (l + r) / 2;
build(x ... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void cetak(T t) {
cout << t << ']' << endl;
}
template <typename T, typename... V>
void cetak(T t, V... v) {
cout << t;
if (sizeof...(v)) cerr << ", ";
cetak(v...);
}
const int mx = 5e5 + 10;
int lazy[mx * 4], mini[mx * 4];
void build(int idx, ... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
int n, m, c, c0, t, minn[500005 << 2], res[500005 << 2], maxx[500005 << 2],
tag[500005 << 2], pos[500005 << 2], posa[500005 << 2];
long long ans;
struct node {
int t, a, c;
} a[500005];
vector<int> vec;
priority_queue<pair<int, int> > q[500005];
inline int read() {
... |
Problem: Adilbek has to water his garden. He is going to do it with the help of a complex watering system: he only has to deliver water to it, and the mechanisms will do all the remaining job.
The watering system consumes one liter of water per minute (if there is no water, it is not working). It can hold no more than... | #include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, m, c, c0;
struct node {
int t, S, v;
} q[N];
set<pair<int, int> > S;
bool cmp(node x, node y) { return x.t < y.t; }
void solve() {
scanf("%d%d%d%d", &n, &m, &c, &c0);
for (int i = (int)(1); i <= (int)(n); i++)
scanf("%d%d%d", &q[i].t, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.