A 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;
}
B 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;
}
C 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;
}