#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int a[10];
for (int i = 1; i <= 8; i++)
{
cin >> a[i];
if (a[i] % 25 != 0)
{
cout << "No\n";
return 0;
}
if (a[i] < 100 || a[i] > 675)
{
cout << "No\n";
return 0;
}
if (i > 1 && a[i] < a[i - 1])
{
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n, m;
string c[105];
string d[105];
int p[105];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> c[i];
for (int i = 1; i <= m; i++)
cin >> d[i];
for (int i = 0; i <= m; i++)
cin >> p[i];
int ans = 0;
for (int i = 1; i <= n; i++)
{
int now = p[0];
for (int j = 1; j <= m; j++)
if (c[i] == d[j])
now = p[j];
ans += now;
}
cout << ans << "\n";
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
struct Node
{
int a, b, id;
};
Node a[200000 + 5];
bool cmp(Node x, Node y)
{
// px>py: x.a/(x.a+x.b)>y.fist/(y.a+y.b)
if (x.a * (y.a + y.b) != y.a * (x.a + x.b))
return x.a * (y.a + y.b) > y.a * (x.a + x.b);
return x.id < y.id;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i].a >> a[i].b;
a[i].id = i;
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++)
cout << a[i].id << " ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n, m;
char g[505][505];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
string S = "snuke";
bool vis[505][505][5];
void dfs(int x, int y, int step)
{
if (x == n && y == m && g[x][y] == S[step % 5])
{
cout << "Yes\n";
exit(0);
}
if (vis[x][y][step % 5])
return;
vis[x][y][step % 5] = true;
if (g[x][y] != S[step % 5])
return;
for (int i = 0; i < 4; i++)
{
int nx = x + dx[i];
int ny = y + dy[i];
dfs(nx, ny, step + 1);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> g[i][j];
dfs(1, 1, 0);
cout << "No\n";
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 200000;
int n;
int a[MAXN + 5];
string s;
int M[MAXN + 5][3];
int E[MAXN + 5][3][3];
int X[MAXN + 5][3][3][3];
int cnt[3];
int mex(int a, int b, int c)
{
cnt[0] = cnt[1] = cnt[2] = 0;
cnt[a]++;
cnt[b]++;
cnt[c]++;
if (!cnt[0])
return 0;
if (!cnt[1])
return 1;
if (!cnt[2])
return 2;
return 3;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
cin >> s;
s = "$" + s + "^";
for (int i = 1; i <= n; i++)
{
// 继承前一项
for (int j = 0; j < 3; j++)
{
M[i][j] = M[i - 1][j];
for (int k = 0; k < 3; k++)
{
E[i][j][k] = E[i - 1][j][k];
for (int l = 0; l < 3; l++)
X[i][j][k][l] = X[i - 1][j][k][l];
}
}
// 当前这一项的贡献
if (s[i] == 'M')
{
M[i][a[i]]++;
}
else if (s[i] == 'E')
{
for (int j = 0; j < 3; j++)
{
if (M[i][j] > 0)
E[i][j][a[i]] += M[i][j];
}
}
else if (s[i] == 'X')
{
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
if (E[i][j][k] > 0)
X[i][j][k][a[i]] += E[i][j][k];
}
}
int ans = 0;
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
for (int l = 0; l < 3; l++)
ans += mex(j, k, l) * X[n][j][k][l];
cout << ans << "\n";
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 200000; // MAXM
int n, m;
int p[MAXN + 5];
pair<int, int> a[MAXN + 5];
priority_queue<int> q;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> p[i];
for (int i = 1; i <= m; i++)
cin >> a[i].first;
for (int i = 1; i <= m; i++)
cin >> a[i].second;
sort(p + 1, p + n + 1);
sort(a + 1, a + m + 1);
int ans = 0;
for (int i = 1, j = 1; i <= n; i++)
{
while (j <= m && a[j].first <= p[i])
{
q.push(a[j].second);
j++;
}
int now = 0;
if (!q.empty())
{
now = q.top();
q.pop();
}
ans += p[i] - now;
}
cout << ans << "\n";
return 0;
}