YJJ's Salesman

YJJ's Salesman

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1085    Accepted Submission(s): 371


 

Problem Description

YJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination.
One day, he is going to travel from city A to southeastern city B. Let us assume that A is (0,0) on the rectangle map and B (109,109). YJJ is so busy so he never turn back or go twice the same way, he will only move to east, south or southeast, which means, if YJJ is at (x,y) now (0≤x≤109,0≤y≤109), he will only forward to (x+1,y), (x,y+1) or (x+1,y+1).
On the rectangle map from (0,0) to (109,109), there are several villages scattering on the map. Villagers will do business deals with salesmen from northwestern, but not northern or western. In mathematical language, this means when there is a village k on (xk,yk) (1≤xk≤109,1≤yk≤109), only the one who was from (xk−1,yk−1) to (xk,yk) will be able to earn vk dollars.(YJJ may get different number of dollars from different village.)
YJJ has no time to plan the path, can you help him to find maximum of dollars YJJ can get.

 

 

Input

The first line of the input contains an integer T (1≤T≤10),which is the number of test cases.

In each case, the first line of the input contains an integer N (1≤N≤105).The following N lines, the k-th line contains 3 integers, xk,yk,vk (0≤vk≤103), which indicate that there is a village on (xk,yk) and he can get vk dollars in that village.
The positions of each village is distinct.

 

 

Output

The maximum of dollars YJJ can get.

 

 

Sample Input

 

1 3 1 1 1 1 2 2 3 3 1

 

 

Sample Output

 

3

 

 

Source

2018中国大学生程序设计竞赛 - 网络选拔赛

 

想到了离散化,想到了背包,甚至树状数组也想到了,但就是没做出来。。。。

好烦。。

代码转载自

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
int maxx[maxn],pos[maxn];
int lowbit(int x)
{
    return x&(-x);
}
void add(int pos,int val)
{
    for(int i=pos;i<=maxn;i+=lowbit(i))
        maxx[i]=max(maxx[i],val);
}
int query(int pos)
{
    int ans=0;
    for(int i=pos;i>=1;i-=lowbit(i))
        ans=max(ans,maxx[i]);
    return ans;
}
int a[maxn];
struct node
{
    int x,y,v;
    bool operator < (const node& q)const
    {
        if(x==q.x)
            return y>q.y;
        return x<q.x;
    }
}p[maxn];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(maxx,0,sizeof(maxx));
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].v),a[i]=p[i].y;
        sort(a+1,a+1+n);
        int all=unique(a+1,a+1+n)-(a+1);
        for(int i=1;i<=n;i++)
            p[i].y=lower_bound(a+1,a+1+all,p[i].y)-a;
        sort(p+1,p+1+n);
        for(int i=1;i<=n;i++)
        {
            int val=query(p[i].y-1)+p[i].v;

            add(p[i].y,val);
        }
        printf("%d\n",query(maxn-1));
    }
    return 0;
}

 

 

 

 

### 解决方案 当遇到 `LVM WARNING VG rl is missing PV` 的警告时,通常是因为物理卷 (Physical Volume, PV) 被移除或者未被正确识别。以下是针对该问题的具体分析和解决方案。 #### 1. 检查物理卷状态 可以使用以下命令来查看当前 LVM 中的物理卷及其状态: ```bash pvscan ``` 如果 `/dev/sdb1` 不再显示为可用的物理卷,则说明它可能已被删除或无法访问[^1]。 #### 2. 验证设备是否存在 确认 `/dev/sdb1` 是否仍然存在并可读写: ```bash lsblk fdisk -l | grep sdb1 ``` 上述命令可以帮助验证设备的存在性和分区结构。如果没有找到 `/dev/sdb1`,则可能是磁盘已丢失或重新挂载到了其他位置[^2]。 #### 3. 尝试恢复物理卷 如果 `/dev/sdb1` 存在但未被识别为物理卷,可以通过以下方式尝试修复: ```bash pvcreate --restorefile /etc/lvm/backup/VolGroup01 --uuid "10Okmv-LpNW-NXXa-B91K-EfTb-s67x-yjj5Ii" /dev/sdb1 ``` 此操作会基于备份文件重建指定 UUID 的物理卷。注意替换 `"10Okmv-LpNW-NXXa-B91K-EfTb-s67x-yjj5Ii"` 和路径 `/dev/sdb1` 到实际环境中的值[^3]。 #### 4. 更新卷组元数据 完成物理卷恢复后,更新卷组以包含新加入的物理卷: ```bash vgcfgrestore VolGroup01 vgchange -ay VolGroup01 ``` 这些步骤确保了卷组能够再次正常工作,并使逻辑卷变得可用。 #### 5. 扩展逻辑卷(如有必要) 一旦所有组件恢复正常运作,可以根据需求调整逻辑卷大小: ```bash lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv ``` --- ### 注意事项 - 如果原始磁盘确实已经损坏或不可用,则需考虑从最近的数据快照或其他冗余机制中恢复。 - 上述方法适用于大多数标准配置下的 Linux 系统;对于特殊定制化部署情况可能会有所差异,请谨慎执行每一步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值