栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

【CF补题】Codeforces Round #790 (Div. 4)C++代码

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【CF补题】Codeforces Round #790 (Div. 4)C++代码

懒得写题解,但欢迎提问。

注意:Div. 4,Div. 4,Div. 4,暴力,暴力,暴力!能过,能过,能过!

A.
#include
using namespace std;
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		int a = 0;
		int b = 0;
		char c;
		for (int i = 1; i <= 3; i++)
		{
			cin >> c;
			a += c - '0';
		}
		for (int i = 1; i <= 3; i++)
		{
			cin >> c;
			b += c - '0';
		}
		if (a == b)cout << "YES" << 'n';
		else cout << "NO" << 'n';
	}
	return 0;
}
B
#include
using namespace std;
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		long long sum = 0;
		int minn = 1e8;
		int x;
		cin >> n;
		for (int i = 1; i <= n; i++)
		{
			cin >> x;
			sum += x;
			minn = min(minn, x);
		}
		cout << sum - minn * n<<'n';
	}
	return 0;
}
C
#include
using namespace std;
int n,m;
char c[60][10];
int cha[60];
long long sum[60];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		sum[0] = 0;
		long long ans = 1e9 + 7;
		cin >> n >> m;
		for (int i = 1; i <= n; i++)
		{
			//cha[i] = 0;
			for (int j = 1; j <= m; j++)
			{
				cin >> c[i][j];
				if (i != 1)
				{
				//	cha[i] += c[i][j] - c[i - 1][j];
				}
			}
			//sum[i] = sum[i - 1] + cha[i];
		}
		long long summ;
		for(int i=1;i 
 
D 
#include
using namespace std;
int n, m;
int c[300][300];
int cha[60];
long long suma[1010], sumb[1010];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		long long ans = 0;
		cin >> n >> m;
		memset(suma, 0, sizeof(suma));
		memset(sumb, 0, sizeof(sumb));
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
			{
				cin >> c[i][j];
				suma[i - j + n + m] += c[i][j];
				sumb[i + j] += c[i][j];
			}
		int nm = max(n, m);
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
			{
				ans = max(ans, suma[i - j + n + m] + sumb[i + j] - c[i][j]);
			}
		}
		cout << ans << 'n';
	}
	return 0;
}
E
#include
using namespace std;
int n, m;
long long c[500005];
long long suma[500005];
int test(int low, int high, long long key)
{
	long long mid = 0;
	while (high > low)
	{
		mid = (high + low) / 2;
		if (suma[mid] >= key)
		{
			high = mid;
		}
		else
		{
			low = mid + 1;
		}
	}
	return high;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		long long ans = 0;
		cin >> n >> m;
		memset(suma, 0, sizeof(suma));
		for (int i = 1; i <= n; i++)
		{
			cin >> c[i];
		}
		sort(c + 1, c + 1 + n);
		suma[0] = 0;
		for (int i = 1; i <= n; i++)
		{
			suma[i] = suma[i - 1] + c[n - i + 1];
			//cout << suma[i] << endl;
		}
		long long q;
		while (m--)
		{
			cin >> q;
			if (q == 0)cout << 0 << 'n'; else
			{
				int ans = test(1, n, q);
				if (suma[ans] >= q)
					cout << ans << 'n'; else cout << -1 << 'n';
			}
		}
	}
	return 0;
}
F
#include
using namespace std;
int n, m;
int c[500005], a[500005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int q;
	cin >> q;
	mapt;
	while (q--)
	{
		int k = 0;
		int x;
		cin >> n >> m;
		for (int i = 1; i <= n; i++)
		{
			cin >> x;
			t[x]++;
			if (t[x] == m) a[++k] = x;
		}
		sort(a + 1, a + 1 + k);
		

		
		if (k == 0) {
			cout << -1 << 'n';
			t.clear();
			continue;
		}

		int cnt = 1;
		int ans = 1, anl = a[1], anr = a[1];
		int cnl = a[1], cnr = 0;

		for (int i = 2; i <= k; i++)
		{
			if (a[i] - a[i - 1] == 1)
			{
				cnt++;
				if (cnt > ans)
				{
					ans = cnt;
					anl = cnl;
					anr = a[i];
				}
			}
			else
			{
				cnt = 1;
				cnl = a[i];
			}
		}

		if (ans > 0)cout << anl << " " << anr<<'n';
		t.clear();
	}
	return 0;
}

G 暑期编程PK赛 得CSDN机械键盘等精美礼品!
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1015433.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号