Thank you for participating!
Idea: mesanu
Tutorial
Tutorial is loading...
Solution
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int a, b, c;
cin >> a >> b >> c;
cout << (a+b+c-min({a,b,c}) >= 10 ? "YES\n" : "NO\n");
}
int main()
{
int t;
cin >> t;
while(t--)
{
solve();
}
}
Idea: flamestorm
Tutorial
Tutorial is loading...
Solution
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200007;
const int MOD = 1000000007;
void solve() {
int n;
cin >> n;
int winner = -1, best_score = 0;
for (int i = 1; i <= n; i++) {
int a, b;
cin >> a >> b;
if (b > best_score && a <= 10) {winner = i; best_score = b;}
}
cout << winner << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve();}
// solve();
}
Idea: flamestorm
Tutorial
Tutorial is loading...
Solution
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200007;
const int MOD = 1000000007;
void solve() {
for (int r = 0; r < 8; r++) {
for (int c = 0; c < 8; c++) {
char x;
cin >> x;
if (x != '.') {cout << x;}
}
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve();}
// solve();
}
Idea: SlavicG
Tutorial
Tutorial is loading...
Solution
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
void solve() {
int n, k; cin >> n >> k;
vector<int> a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
sort(all(a));
int cnt = 1, ans = 1;
for(int i = 1; i < n; ++i) {
if(a[i] - a[i - 1] > k) {
cnt = 1;
} else {
++cnt;
}
ans = max(ans, cnt);
}
cout << n - ans << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}
1850E - Cardboard for Pictures
Idea: flamestorm
Tutorial
Tutorial is loading...
Solution
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
#define int long long
void solve() {
int n, c; cin >> n >> c;
vector<int> a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
int l = 1, r = 1e9;
while(l <= r) {
int mid = l + (r - l) / 2;
int sumall = 0;
for(int i = 0; i < n; ++i) {
sumall += (a[i] + 2 * mid) * (a[i] + 2 * mid);
if(sumall > c) break;
}
if(sumall == c) {
cout << mid << "\n";
return;
}
if(sumall > c) {
r = mid - 1;
} else {
l = mid + 1;
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}
Tutorial
Tutorial is loading...
Solution
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
void solve() {
int n; cin >> n;
vector<ll> cnt(n + 1, 0), mx(n + 1, 0);
for(int i = 0; i < n; ++i) {
int x; cin >> x;
if(x <= n) ++cnt[x];
}
for(int i = 1; i <= n; ++i) {
for(int j = i; j <= n; j += i) mx[j] += cnt[i];
}
cout << *max_element(all(mx)) << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}
Idea: flamestorm
Tutorial
Tutorial is loading...
Solution
#include <bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define int long long
void solve()
{
int n;
cin >> n;
map<int, int> up, side, diag1, diag2;
int ans = 0;
for(int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
up[x]++;
side[y]++;
diag1[x-y]++;
diag2[x+y]++;
}
for(auto x : up)
{
ans+=x.second*(x.second-1);
}
for(auto x : side)
{
ans+=x.second*(x.second-1);
}
for(auto x : diag1)
{
ans+=x.second*(x.second-1);
}for(auto x : diag2)
{
ans+=x.second*(x.second-1);
}
cout << ans << endl;
}
int32_t main(){
startt
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
Idea: SlavicG
Tutorial
Tutorial is loading...
Solution
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
#define int long long
const int N = 2e5 + 5;
vector<pair<int, int>> adj[N];
int val[N], vis[N];
void dfs(int u) {
vis[u] = 1;
for(auto x: adj[u]) {
int v = x.first, w = x.second;
if(!vis[v]) {
val[v] = val[u] + w;
dfs(v);
}
}
}
void solve() {
int n, m; cin >> n >> m;
for(int i = 1; i <= n; ++i) {
adj[i].clear();
vis[i] = 0, val[i] = 0;
}
vector<array<int, 3>> c;
for(int i = 1; i <= m; ++i) {
int a, b, d; cin >> a >> b >> d;
adj[a].pb({b, d});
adj[b].pb({a, -d});
c.pb({a, b, d});
}
for(int i = 1; i <= n; ++i) {
if(!vis[i]) dfs(i);
}
for(int i = 1; i <= m; ++i) {
int a = c[i - 1][0], b = c[i - 1][1], d = c[i - 1][2];
if(val[a] + d != val[b]) {
cout << "NO\n";
return;
}
}
cout << "YES\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}