【Codeforces】Codeforces Round 867 (Div. 3) (+155!)

TubeTube Feed

题目大意:

解题思路:

狠狠的贪,每次能看电视就都看,找出能看的最大娱乐值

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int q, n, t;
struct node {
	int id;
	int a, b;
} s[N];
bool cmp(node x, node y) {
	return x.b > y.b;
}
int main() {
	cin >> q;
	while (q--) {
		cin >> n >> t;
		for (int i = 1; i <= n; i++) cin >> s[i].a;
		for (int i = 1; i <= n; i++) cin >> s[i].b;
		int ans, ma = 0;
		for (int i = 1; i <= n; i++) {
			if (t >= s[i].a) {
				if (ma < s[i].b) {
					ma = s[i].b;
					ans = i;
				}
			}
			t--;
		}
		if (ma) cout << ans << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Karina and Array

题目大意:

解题思路:

排序,找到最大的两个数或者最小的两个数

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 5;
int t, n;
ll a[N];
ll inf = 9999999999999999;
ll ans;
int main() {
	cin >> t;
	while (t--) {
		cin >> n;
		for (int i = 1; i <= n; i++)cin >> a[i];
		sort(a + 1, a + n + 1);
		ans = max(a[1] * a[2], a[n] * a[n - 1]);
		cout << ans << endl;
	}
	return 0;
}

Bun Lover

题目大意:

解题思路:

推式子

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
ll t, n;
ll ans;
int main() {
	cin >> t;
	while (t--) {
		cin >> n;
		ans = 2 + 2 * n + n * n;
		cout << ans << endl;
	}
	return 0;
}

Super-Permutation

题目大意:

解题思路:

参考代码:

E

题目大意:

解题思路:

参考代码:

F

题目大意:

解题思路:

参考代码:

G1

G2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值