A. Office Keys

本文介绍了一种使用动态规划解决钥匙匹配问题的方法。通过定义dp数组来存储中间结果,避免了重复计算,提高了效率。该算法适用于需要为一组人分配对应的钥匙以达到最优化目标的情况。

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

dp[i][j] 第一维表示people,第二维表示key

当i==j的时候,刚好每个人对应一把钥匙
当i!=j的时候,分两种情况,i去拿j,和i不用拿j

所以代码如下

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define mem(i,a) memset(i,a,sizeof(i))
#define rson mid+1,r,rt<<1|1
#define lson l,mid,rt<<1
#define ll long long
#define LL long long
using namespace std;
template <typename T>inline void read(T &_x_){
    _x_=0;bool f=false;char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=!f;ch=getchar();}
    while ('0'<=ch&&ch<='9') {_x_=_x_*10+ch-'0';ch=getchar();}
    if(f) _x_=-_x_;
}
const double eps = 0.0000001;
const int maxn = 2e3+7;
const int mod = 1e9+7;

int n,k,p;
int a[maxn],b[maxn];
int dp[maxn][maxn];

int main(){
    read(n),read(k),read(p);
    FOR(i,1,n) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    FOR(i,1,k) scanf("%d",&b[i]);
    sort(b+1,b+1+k);
    FOR(i,1,n){
        FOR(j,i,k){
            if(i==j){
                dp[i][j]=max(dp[i-1][j-1],abs(a[i]-b[j])+abs(b[j]-p));
                continue;
            }  
            dp[i][j]=min(dp[i][j-1], max(dp[i-1][j-1],abs(a[i]-b[j])+abs(b[j]-p)));
        }
    }
    int ans=0x7fffffff;
    FOR(i,n,k) ans=min(ans,dp[n][i]);
    printf("%d\n",ans);
    return 0;
}
### Microsoft Office on macOS Installation and Usage Guide #### Prerequisites for Installation To install Microsoft Office on macOS, ensure that the system meets minimum requirements specified by Microsoft. Compatibility with different versions of macOS is crucial as not all editions support older or newer operating systems equally[^1]. #### Downloading Microsoft Office Obtain Microsoft Office from official sources to guarantee security and functionality. Subscription services like Microsoft 365 provide access to applications including Word, Excel, PowerPoint among others. After purchasing a subscription, download the installer directly via the provided link within the account management portal. #### Performing Installation Once downloaded, open the `.dmg` file containing the setup program. Dragging the application icons into the Applications folder completes most installations; however, some products may require additional steps such as entering product keys during this phase. #### Activating Software Activation typically occurs automatically when signing in using credentials associated with an active subscription. If automatic activation fails, manual entry of license information might be required following prompts displayed after launching any installed office suite component. #### Using Microsoft Office Applications Applications function similarly across platforms but possess unique features tailored specifically towards macOS users. Integration capabilities allow seamless interaction between Mac-native apps (e.g., Finder integration) enhancing productivity workflows without sacrificing familiarity for those accustomed to Apple ecosystems. ```bash # Example command line operations related to managing licenses sudo /Library/Application\ Support/Microsoft/Office16.0/OSET/Scripts/Set-License.sh -p PRODKEY ``` --related questions-- 1. What are common troubleshooting tips for issues encountered while installing Microsoft Office? 2. How does one manage multiple versions of Microsoft Office coexisting on a single machine running macOS? 3. Can third-party tools enhance compatibility between certain Microsoft Office functionalities and native macOS utilities? 4. Are there specific configurations needed for optimal performance of Microsoft Office under virtualized environments hosted on macOS hosts?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值