系统环境:NOI Linux (Ubuntu)
软件环境:Code::Blocks 20.03 Linux
Debugger返回信息:
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Release
Adding source dir: /home/jayz/cpp/1/
Adding source dir: /home/jayz/cpp/1/
Adding file: /home/jayz/cpp/1/bin/Release/1
Changing directory to: /home/jayz/cpp/1/.
Set variable: LD_LIBRARY_PATH=.:
Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /home/jayz/cpp/1/bin/Release/1
Setting SHELL to '/bin/sh'
done
Setting breakpoints
Debugger name and version: GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1
[Inferior 1 (process 7674) exited normally]
Debugger finished with status 0
Code:
#include<iostream>
#include<string.h>
#include<cmath>
using namespace std;
struct E{
int dis,n;
string name;
}a[151];
int tot,ans=0x7f7f7f7f,anx;
int main(){
freopen("in.in","r",stdin);
++tot;
cin>>a[tot].n>>a[tot].dis>>a[tot].name;
while(a[tot].dis){
++tot;
cin>>a[tot].n>>a[tot].dis>>a[tot].name;
}
for(int i=1;i<=tot;i++){
int t=0;
for(int j=1;j<=tot;j++)t+=a[j].n*abs(a[j].dis-a[i].dis);
if(t<=ans)ans=t,anx=i;
}
cout<<a[anx].name<<" "<<ans;
return 0;
}