我是靠谱客的博主 懦弱西装,最近开发中收集的这篇文章主要介绍牛客练习赛7,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

有题解就不写题解啦、 这次三题比之前的感觉要简单点

A

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define lson (rt << 1)
#define rson ((rt << 1) | 1)
#define pill pair<int, int>
#define mst(a, b)
memset(a, b, sizeof a)
#define REP(i, x, n)
for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
int a[10], b[10];
int main(){
int t;
scanf("%d", &t) ;
while(t--) {
for(int i = 0; i < 6; ++i) {
scanf("%d", a + i) ;
}
for(int i = 0; i < 6; ++i) {
scanf("%d", b + i) ;
}
int x = 0, y = 0;
for(int i = 0; i < 6; ++i) {
for(int j = 0; j < 6; ++j) {
if(a[i] > b[j])
x++;
else if(a[i] < b[j]) y++;
}
}
if(x == y) {
puts("Tie");
} else if(x > y) {
puts("Alice");
} else {
puts("Bob");
}
}
return 0;
}


B

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define lson (rt << 1)
#define rson ((rt << 1) | 1)
#define pill pair<int, int>
#define mst(a, b)
memset(a, b, sizeof a)
#define REP(i, x, n)
for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 400 + 10;
const LL INF = 1e15 + 10;
LL dp[qq][qq];
LL candy[qq][qq];
int n, m;
void init() {
for(int i = 0; i <= n; ++i) {
for(int j = 0; j <= n; ++j) {
dp[i][j] = INF;
}
}
dp[0][0] = 0;
}
void print() {
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
printf("%lld ", dp[i][j]);
}
puts("");
}
}
int main(){
scanf("%d%d", &n, &m) ;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
scanf("%lld", &candy[i][j]) ;
}
sort(candy[i] + 1, candy[i] + 1 + m);
for(int j = 1; j <= m; ++j) {
candy[i][j] += candy[i][j - 1];
}
}
init();
for(int i = 1; i <= n; ++i) {
for(int j = min(i * m, n); j >= i; --j) {
for(int l = 0; l <= m; ++l) {
if(j - l < 0)
continue;
dp[i][j] = min(dp[i][j], dp[i - 1][j - l] + candy[i][l] + 1LL * l * l);
}
}
}
printf("%lldn", dp[n][n]);
return 0;
}


E

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
#define LL __int128
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define lson (rt << 1)
#define rson ((rt << 1) | 1)
#define pill pair<int, int>
#define mst(a, b)
memset(a, b, sizeof a)
#define REP(i, x, n)
for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 1e6 + 10;
const int INF = 1e9 + 10;
LL sum[qq];
int a[qq], b[qq];
int n;
int lowBit(int x) {
return x & (-x);
}
LL getSum(int x) {
LL ans = 0;
while(x > 0) {
ans += sum[x];
x -= lowBit(x);
}
return ans;
}
void upDate(int x, int dis) {
while(x <= n) {
sum[x] += dis;
x += lowBit(x);
}
}
struct Node {
int x, id;
}p[qq];
bool cmp1(const Node &a, const Node &b) {
return a.x < b.x;
}
bool cmp2(const Node &a, const Node &b) {
return a.id < b.id;
}
void print(LL x) {
if(x == 0)
return ;
if(x)
print(x / 10) ;
putchar(x % 10 + '0');
}
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
scanf("%d", a + i);
b[i] = a[i];
}
sort(b + 1, b + n + 1);
int k = unique(b + 1, b + n + 1) - b;
LL ans = 0;
for(int i = n; i >= 1; --i) {
int x = lower_bound(b + 1, b + k, a[i]) - b;
ans += getSum(x - 1) * i;
upDate(x, n - i + 1);
}
if(ans == 0) {
puts("0");
} else {
print(ans);
}
return 0;
}

D题应该可做,待补

最后

以上就是懦弱西装为你收集整理的牛客练习赛7的全部内容,希望文章能够帮你解决牛客练习赛7所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部