10131 - Is Bigger Smarter? 水dp

Question 1: Is Bigger Smarter?

The Problem

Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the IQ's are decreasing.

The input will consist of data for a bunch of elephants, one elephant per line, terminated by the end-of-file. The data for a particular elephant will consist of a pair of integers: the first representing its size in kilograms and the second representing its IQ in hundredths of IQ points. Both integers are between 1 and 10000. The data will contain information for at most 1000 elephants. Two elephants may have the same weight, the same IQ, or even the same weight and IQ.

Say that the numbers on the i-th data line are W[i] and S[i]. Your program should output a sequence of lines of data; the first line should contain a number n; the remaining n lines should each contain a single positive integer (each one representing an elephant). If these n integers are a[1]a[2],..., a[n] then it must be the case that

   W[a[1]] < W[a[2]] < ... < W[a[n]]
and
   S[a[1]] > S[a[2]] > ... > S[a[n]]
In order for the answer to be correct,  n  should be as large as possible. All inequalities are strict: weights must be strictly increasing, and IQs must be strictly decreasing. There may be many correct outputs for a given input, your program only needs to find one.

Sample Input

6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900

Sample Output

4
4
5
9
7
---------



-----------

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

using namespace std;

struct EL{
    int x;
    int y;
    int id;
}a[11111];

bool cmp(EL a,EL b)
{
    if (a.x==b.x) return a.id<b.id;
    return a.x<b.x;
}

int n;
int f[11111]={0};
int p[11111]={0};
int ans[11111]={0};
int cnt;

int main()
{
    n=1;
    while (~scanf("%d%d",&a[n].x,&a[n].y)){a[n].id=n;n++;}
    n--;
    sort(a+1,a+n+1,cmp);
    int mx=0;
    int ww=0;
    //for (int i=1;i<=n;i++){cerr<<a[i].x<<" "<<a[i].y<<" "<<a[i].id<<endl;}
    for (int i=1;i<=n;i++)
    {
        f[i]=1;
        p[i]=0;
        for (int k=1;k<i;k++)
        {
            if (a[i].y<a[k].y&&a[i].x>a[k].x&&f[k]+1>f[i])
            {
                f[i]=f[k]+1;
                p[i]=k;
            }
        }
        if (f[i]>mx)
        {
            mx=f[i];
            ww=i;
        }
    }
    //for (int i=1;i<=n;i++) cerr<<f[i]<<" ";cerr<<endl;
    printf("%d\n",mx);
    cnt=0;
    while (ww!=0)
    {
        ans[cnt++]=a[ww].id;
        ww=p[ww];
    }
    for (int i=cnt-1;i>=0;i--)
    {
        printf("%d\n",ans[i]);
    }
    return 0;
}



<think>嗯,用户遇到了运行BFG工具时的错误,提示无法访问bfg.jar文件。我需要先理解这个错误的原因。通常,这种情况是因为系统找不到bfg.jar文件,可能用户没有正确下载或者保存的位置不对。首先,我应该确认用户是否按照步骤正确安装了BFG工具。 用户的问题是在执行命令`java -jar bfg.jar --strip-blobs-bigger-than 10M`时出现错误,说明系统找不到bfg.jar。可能用户没有下载这个文件,或者下载后没有放在当前的工作目录下。另外,可能用户下载的是错误的文件,或者文件名不一致,比如版本号导致文件名不同,例如bfg-1.14.0.jar这样的名字。 接下来,我需要考虑用户的操作系统,因为不同系统的命令可能有所不同。例如,在Linux或macOS中,用户可能使用curl或wget下载文件,而Windows用户可能需要用浏览器下载,并确保文件路径正确。另外,用户可能没有安装Java环境,或者Java版本不兼容,但错误信息是关于jar文件无法访问,所以更可能的是文件路径问题。 我应该分步骤指导用户:首先确认是否下载了BFG,然后检查文件名是否正确,确保在正确的目录下运行命令。同时,提供下载链接和具体的下载命令,比如使用wget或curl,或者直接浏览器下载。另外,提醒用户下载后的文件可能需要重命名为bfg.jar,或者使用实际下载的文件名来执行命令。 此外,用户可能对命令行操作不太熟悉,特别是路径处理部分,所以需要给出具体的例子,比如将bfg.jar放在项目根目录,或者指定绝对路径。同时,可能需要检查Java环境是否安装,虽然错误不是关于Java的,但这一步可以作为补充。 最后,总结常见错误,帮助用户逐一排查,比如路径问题、文件名问题、Java安装问题等。确保用户能按照步骤解决问题,顺利运行BFG命令来清理大文件。</think>$\boxed{问题分析}$ 报错`Unable to access jarfile bfg.jar`表示系统找不到BFG工具的可执行文件。以下是完整解决方案: --- $\boxed{解决方案}$ ```bash # 步骤1:正确下载BFG # 通过curl下载(Linux/macOS) curl -L -o bfg.jar https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar # 或浏览器手动下载(全平台适用): # 访问 https://rtyley.github.io/bfg-repo-cleaner/ # 下载最新版.jar文件并重命名为bfg.jar # 步骤2:验证文件存在 ls -l bfg.jar # 应显示文件大小约1.8MB # 步骤3:带完整路径执行(假设文件在/home/user/目录) java -jar /home/user/bfg.jar --strip-blobs-bigger-than 10M # 或移动到项目根目录执行 mv bfg.jar /your/git/repo/ cd /your/git/repo/ java -jar bfg.jar --strip-blobs-bigger-than 10M ``` --- $\boxed{技术原理}$ 1. **路径依赖**:`java -jar`命令需要精确指定.jar文件的物理路径 2. **版本对应**:必须使用[官方发布的.jar文件](https://rtyley.github.io/bfg-repo-cleaner/) 3. **权限问题**:某些系统需要执行权限: ```bash chmod +x bfg.jar # Linux/macOS添加可执行权限 ``` --- $\boxed{常见错误排查}$ | 现象 | 解决方法 | |------|----------| | 下载成`bfg-X.X.X.jar` | 重命名文件:`mv bfg-*.jar bfg.jar` | | 文件不在当前目录 | 使用绝对路径:`java -jar /完整路径/bfg.jar` | | Java环境缺失 | 安装JRE:`sudo apt install default-jre` (Debian/Ubuntu) | | 文件损坏 | 重新下载并验证`sha256sum bfg.jar`应为`d33741f22d...` | --- $\boxed{操作验证}$ ```bash # 验证BFG版本 java -jar bfg.jar --version # 正确输出示例:bfg 1.14.0 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值