牛客每日练习----最小化价格,Sequence,Games

本文深入探讨了算法竞赛中常见的几种问题类型,包括团队分配、序列操作和游戏策略。通过具体实例,解析了如何利用数据结构和算法优化解决方案,旨在帮助参赛者提升解题效率和策略制定能力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我喜欢给自己压力,必须得定一个很高的目标,逼自己朝着这个目标前进,不管会不会实现,都是一个动力。                                      ----喻言

链接:https://ac.nowcoder.com/acm/problem/15911
来源:牛客网
 

题目描述

现有n组人,m个地点,给出每组人的人数,每个地点可容纳的最大人数和选择的价格

要求一种方式,使得每组人都到一个各不相同的地点,最小化选择的价格

每个队伍的人都要在同一个地方每个地方只能有一个队伍

输入描述:

第一行n,m
第二行n个数,表示每组的人数
接下来m行,每行两个数,表示可容纳的最大人数和选择的价格

输出描述:

输出最小化选择的价格,无解输出-1

示例1

输入

复制

3 4
2 3 4
1 2
2 3
3 4
4 5

输出

复制

12

备注:

所有数据小于1e5
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
int const N=10010;
int const mod=1e9+7;
const int maxn=1e5+10;
int n,m,a[maxn];
priority_queue<int,vector<int>,greater<int> >s;
struct node
{
    int a;
    int b;
}b[maxn];
bool cmp(node x,node y)
{
    return x.a<y.a;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) 
		scanf("%d",&a[i]);
    for(int i=1;i<=m;i++) 
		scanf("%d%d",&b[i].a,&b[i].b);
    sort(a+1,a+n+1);
    sort(b+1,b+m+1,cmp);
    int jg=0;
    for(int i=n,j=m;i>0;i--)
    {
        for(;b[j].a>=a[i];j--) 
			s.push(b[j].b);
        if(s.empty())
        {
            printf("-1\n");
            return 0;
        }
        jg+=s.top();
        s.pop();
    }
    printf("%d\n",jg);
    return 0;
}

链接:https://ac.nowcoder.com/acm/problem/15931
来源:牛客网
 

题目描述

We define an element aia_{i}ai​ in a sequence "good", if and only if there exists aja_{j}aj​ (1≤j<i) such that aj<aia_{j}<a_{i}aj​<ai​.

Given a permutation p of integers from 1 to n. Remove an element from the permutation such that the number of "good" elements is maximized.

输入描述:

The input consists of several test cases. The first
line of the input gives the number of test cases,T(1≤T≤103)T(1\leq T \leq 10^3)T(1≤T≤103).

For each test case, the first line contains an
integer n(1≤n≤106)n(1\leq n \leq 10^6)n(1≤n≤106),
representing the length of the given permutation.

The second line contains n integersp1,p2,…,pn (1≤pi≤n)(1\leq p_{i} \leq n)(1≤pi​≤n),
representing the given permutation p.

It's guaranteed that  ∑n≤2∗107\sum_{}^{}{n} \leq 2 *10^7∑​n≤2∗107.

输出描述:

For each test case, output one integer in a single
line, representing the element that should be deleted. If there are several
answers, output the minimal one.

示例1

输入

复制

2
1
1
5
5 1 2 3 4

输出

复制

1
5
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
int const N=10010;
int const mod=1e9+7;
const int maxn=1000010;
int n,a,ls,jg,mx,mi;
int c[maxn];
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        mx=inf,mi=inf;
        for(int i=1;i<=n;i++) 
			c[i]=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a);
            if(a<=mi)
            {
                mx=mi;
                mi=a;
            }
            else if(a>=mi&&a<mx)
            {
                c[mi]++;
                c[a]++;
                mx=a;
            }
            else if(a>=mx)
                c[a]++;
        }
        ls=inf,jg=mi;
        for(int i=1;i<=n;i++)
        {
            if(c[i]<ls)
            {
            	ls=c[i];
            	jg=i;
            }
        }
        printf("%d\n",jg);
    }
    return 0;
}

链接:https://ac.nowcoder.com/acm/problem/15933
来源:牛客网
 

题目描述

Alice and Bob are playing a stone game. There are n piles of stones. In each turn, a player can remove some stones from a pile (the number must be positive and not greater than the number of remaining stones in the pile). One player wins if he or she remove the last stone and all piles are empty. Alice plays first.

To make this game even more interesting, they add a new rule: Bob can choose some piles and remove entire of them before the game starts. The number of removed piles is a nonnegative integer, and not greater than a given number d. Note d can be greater than n, and in that case you can remove all of the piles.

Let ans denote the different ways of removing piles such that Bob are able to win the game if both of the players play optimally. Bob wants you to calculate the remainder of ans divided by109+7.

输入描述:

The first line contains an integer T, representing
the number of test cases.

For each test cases, the first line are two
integers n and d, which are described above.

The second line are n positive integersai,
representing the number of stones in each pile.

T≤5,n≤103,d≤10,ai≤103T \leq 5 ,n \leq 10^3 ,d \leq 10, a_{i}\leq10^3T≤5,n≤103,d≤10,ai​≤103

输出描述:

For each test case, output one integer (modulo109+7.) in a
single line, representing the number of different ways of removing piles that
Bob can ensure his victory.

示例1

输入

复制

2
5 2
1 1 2 3 4
6 3
1 2 4 7 1 2

输出

复制

2
5
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
int const N=10010;
int const mod=1e9+7;
const int maxn=1e5+5;
int dp[1100][12][1100];
int t,n,d;
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>n>>d;
        memset(dp,0,sizeof(dp));
        for(int i=0;i<=n; i++)
            dp[i][0][0]=1;
        ll x,sum=0;
        for(int i=1;i<= n; i++)
        {
            cin>>x;
            sum^=x;
            for(int j=1;j<=d;j++)
            {
                for(int k=0; k<1024; k++)
                    dp[i][j][k]=(dp[i-1][j][k]+dp[i-1][j-1][k^x])%mod;
            }
        }
        ll jg=0;
        for(int i=0 ;i<=d; i++)
            jg=(jg+dp[n][i][sum])%mod;
        cout<<jg<<endl;
    }
    return 0;
}

 

标题SpringBoot基于Web的图书借阅管理信息系统设计与实现AI更换标题第1章引言介绍图书借阅管理信息系统的研究背景、意义、现状以及论文的研究方法和创新点。1.1研究背景与意义分析当前图书借阅管理的需和SpringBoot技术的应用背景。1.2国内外研究现状概述国内外在图书借阅管理信息系统方面的研究进展。1.3研究方法与创新点介绍本文采用的研究方法和系统设计的创新之处。第2章相关理论技术阐述SpringBoot框架、Web技术和数据库相关理论。2.1SpringBoot框架概述介绍SpringBoot框架的基本概念、特点和核心组件。2.2Web技术基础概述Web技术的发展历程、基本原理和关键技术。2.3数据库技术应用讨论数据库在图书借阅管理信息系统中的作用和选型依据。第3章系统需分析对图书借阅管理信息系统的功能需、非功能需进行详细分析。3.1功能需分析列举系统应具备的各项功能,如用户登录、图书查询、借阅管理等。3.2非功能需分析阐述系统应满足的性能、安全性、易用性等方面的要。第4章系统设计详细介绍图书借阅管理信息系统的设计方案和实现过程。4.1系统架构设计给出系统的整体架构,包括前后端分离、数据库设计等关键部分。4.2功能模块设计具体阐述各个功能模块的设计思路和实现方法,如用户管理模块、图书管理模块等。4.3数据库设计详细介绍数据库的设计过程,包括表结构、字段类型、索引等关键信息。第5章系统实现与测试对图书借阅管理信息系统进行编码实现,并进行详细的测试验证。5.1系统实现介绍系统的具体实现过程,包括关键代码片段、技术难点解决方法等。5.2系统测试给出系统的测试方案、测试用例和测试结果,验证系统的正确性和稳定性。第6章结论与展望总结本文的研究成果,指出存在的问题和未来的研究方向。6.1研究结论概括性地总结本文的研究内容和取得的成果。6.2展望对图书借阅管理
摘 要 基于SpringBoot的电影院售票系统为用户提供了便捷的在线购票体验,覆盖了从注册登录到观影后的评价反馈等各个环节。用户能够通过系统快速浏览和搜索电影信息,包括正在热映及即将上映的作品,并利用选座功能选择心仪的座位进行预订。系统支持多种支付方式如微信、支付宝以及银行卡支付,同时提供积分兑换和优惠券领取等功能,增强了用户的购票体验。个人中心允许用户管理订单、收藏喜爱的影片以及查看和使用优惠券,极大地提升了使用的便利性和互动性。服聊天功能则确保用户在遇到问题时可以即时获得帮助。 后台管理人员,系统同样提供了全面而细致的管理工具来维护日常运营。管理员可以通过后台首页直观地查看销售额统计图,了解票房情况并据此调整策略。电影信息管理模块支持新增、删除及修改电影资料,确保信息的准确与及时更新。用户管理功能使得管理员可以方便地处理用户账号,包括导入导出数据以供分析。订单管理模块简化了对不同状态订单的处理流程,提高了工作效率。优惠券管理和弹窗提醒管理功能有助于策划促销活动,吸引更多观众。通过这样的集成化平台,SpringBoot的电影院售票系统不仅优化了用户的购票体验,也加强了影院内部的管理能力,促进了业务的发展和服务质量的提升。 关键词:电影院售票系统;SpringBoot框架;Java技术
内容概要:本文介绍了2025年中国网络安全的十大创新方向,涵盖可信数据空间、AI赋能数据安全、ADR(应用检测与响应)、供应链安全、深度伪造检测、大模型安全评估、合规管理与安全运营深度融合、AI应用防火墙、安全运营智能体、安全威胁检测智能体等。每个创新方向不仅提供了推荐的落地方案和典型厂商,还详细阐述了其核心能力、应用场景、关键挑战及其用户价值。文中特别强调了AI技术在网络安全领域的广泛应用,如AI赋能数据安全、智能体驱动的安全运营等,旨在应对日益复杂的网络威胁,提升企业和政府机构的安全防护能力。 适合人群:从事网络安全、信息技术、数据管理等相关工作的专业人士,尤其是负责企业信息安全、技术架构设计、合规管理的中高层管理人员和技术人员。 使用场景及目标:①帮助企业理解和应对最新的网络安全威胁和技术趋势;②指导企业选择合适的网络安全产品和服务,提升整体安全防护水平;③协助企业构建和完善自身的网络安全管理体系,确保合规运营;④为技术研发人员提供参考,推动技术创新和发展。 其他说明:文章内容详尽,涉及多个技术领域和应用场景,建议读者根据自身需重点关注相关章节,并结合实际情况进行深入研究和实践。文中提到的多个技术和解决方案已在实际应用中得到了验证,具有较高的参考价值。此外,随着技术的不断发展,文中提及的部分技术和方案可能会有所更新或改进,因此建议读者保持关注最新的行业动态和技术进展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值