完美世界 笔试

有元宝题和数学竞赛题ac代码吗~~
5555555555555555555555555大佬在哪里~
一个80一个20
80那个想不通  20那个不会做
#笔试题目##完美世界#
全部评论
第一个80,第二个直接用背包问题解决了
点赞 回复 分享
发布于 2019-04-15 21:24
s=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) a=sorted(a,reverse=True) b=sorted(b,reverse=True) total=0 for i in a:     if i<b[-1]:         total-=100     else:         for j in b:             if i>j:                 total+=100                 break         b.remove(j) print(total) 元宝
点赞 回复 分享
发布于 2019-04-15 21:27
importjava.util.Scanner; public class Main {public static void main(String[] args) { Scanner sc = newScanner(System.in); int n = sc.nextInt(); int[] socer = new int[n]; int[] time = new int[n]; for(inti =0; i < n;i++){ int x = sc.nextInt(); socer[i] = x; } for(inti =0; i < n;i++){ int x = sc.nextInt(); time[i] = x; } intallTime = sc.nextInt(); System.out.println(maxSoc(n,socer,time,allTime)); } public static int maxSoc(intn,int[] socer,int[] time,intallTime){//01背包 int[] dp = new int[allTime + 1]; for(inti =0;i < n;i++){ for(intj = allTime;j >=0;j--){ if((j - time[i] >= 0) && (dp[j] <= dp[j - time[i]] + socer[i])){//状态方程 dp[j] = dp[j - time[i]] + socer[i]; } } } returndp[allTime]; } } 数学竞赛题
点赞 回复 分享
发布于 2019-04-15 21:48
数学竞赛0-1背包问题
点赞 回复 分享
发布于 2019-04-15 21:48
result=-1000 def dfs(a,b,n,d,t):     global result     if d>=n:         if t>result:             result=t         return     for i in range(d,n):         temp=a[d]         a[d]=a[i]         a[i]=temp         tl=0         if a[d]>b[d]:             tl=100         elif a[d]<b[d]:             tl=-100         dfs(a,b,n,d+1,t+tl) s=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) n=len(a) dfs(a,b,n,0,0) print(result)
点赞 回复 分享
发布于 2019-04-16 09:17

相关推荐

双非本科小鼠:27兄弟,不应该还在享受校园吗哈哈😂
点赞 评论 收藏
分享
评论
点赞
2
分享

创作者周榜

更多
牛客网
牛客企业服务