蓝桥算法训练营—普及组—2023年2.9日

P1781 宇宙总统

https://www.luogu.com.cn/problem/P1781

字符串比较

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
    
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer st = new StreamTokenizer(in);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws Exception{
    	
    	int n = Integer.parseInt(in.readLine());
    	int idx = -1;
    	String ans = "0";
    	for (int i = 1; i <= n; i++) {
    		String ss = in.readLine();
    		int len = ss.length(), m = ans.length();
    		if (len > m) {
    			idx = i;
    			ans = ss;
    		} else if (len < m) {
    			continue;
    		} else if (ss.compareTo(ans) > 0){
    			idx = i;
    			ans = ss;			
    		}
    		
    	}
    	out.println(idx);
    	out.println(ans);
    	
    	out.flush();
    	in.close();
    }  
}

P1223 排队接水

https://www.luogu.com.cn/problem/P1223

贪心

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
    
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer st = new StreamTokenizer(in);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    public static void main(String[] args) throws Exception{
    	
    	int n = Integer.parseInt(in.readLine().trim());
    	int[][] arr = new int[n][2];
    	String[] ss = in.readLine().split(" ");
    	for (int i = 0; i < n; i++) {
    		arr[i][0] = i + 1;
    		arr[i][1] = Integer.parseInt(ss[i]);
    	}
    	Arrays.parallelSort(arr, (a, b) -> (a[1] - b[1]));
    	double tot = 0, cur = 0;
    	for (int i = 0; i < n; i++) {
    		out.print(arr[i][0] + " ");
    		tot += cur;
    		cur += arr[i][1];
    	}
    	out.printf("\n%.2f", tot / n);

    	
    	out.flush();
    	in.close();
    }  
}

P3817 小A的糖果

https://www.luogu.com.cn/problem/P3817

贪心

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
    
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer st = new StreamTokenizer(in);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    public static void main(String[] args) throws Exception{
    	
    	String[] nx = in.readLine().split(" ");
    	int n = Integer.parseInt(nx[0]), x = Integer.parseInt(nx[1]);
    	int[] arr = new int[n];
    	String[] ss = in.readLine().split(" ");
    	long ans = 0;
    	for (int i = 0; i < n; i++) {
    		arr[i] = Integer.parseInt(ss[i]);
    		if (i > 0 && arr[i] + arr[i - 1] > x) {
    			ans += arr[i] - x + arr[i - 1];
    			arr[i] = x - arr[i - 1];
    		}
    	}
    	
    	out.println(ans);
    	
    	out.flush();
    	in.close();
    }  
}

P1007 独木桥

https://www.luogu.com.cn/problem/P1007

贪心

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
    
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer st = new StreamTokenizer(in);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    public static void main(String[] args) throws Exception{
    	
    	int l = Integer.parseInt(in.readLine()), n = Integer.parseInt(in.readLine());
    	int mn = 0, mx = 0;
    	String[] ss = null;
    	if (n > 0) ss = in.readLine().split(" ");
    	for (int i = 0; i < n; i++) {
    		int t = Integer.parseInt(ss[i]);
    		mn = Math.max(mn, Math.min(t, l + 1 - t));
    		mx = Math.max(mx, Math.max(t, l + 1 - t));
    	}
    	out.println(mn + " " + mx);
    	
    	out.flush();
    	in.close();
    }  
}
20232月蓝桥STEMA评测C中级,氧气值、燃料值、装备重量是评测中的三个关键指标。 首先,氧气值是指参赛者所携带的氧气的储备量。在这个评测中,参赛者需要完成一系列与高海拔环境相关的任务,因此氧气的充足与否直接关系到参赛者的生命安全和任务完成的效率。参赛者需要合理规划氧气的使用,以满足任务需求,同时尽可能节约氧气的使用,减轻负重,提高携带效率。 其次,燃料值是指参赛者所携带燃料的储备量,如液态燃料等。在这个评测中,参赛者可能需要使用燃料进行加热、照明或其他用途,因此燃料的储备量也直接关系到任务的顺利进行。参赛者需要合理估计燃料的消耗量,并储备足够的燃料,以确保任务期间的能源供应。 最后,装备重量是指参赛者在进行任务时所携带装备的总重量。在这个评测中,参赛者需要具备一定的装备,如登山工具、食物、药品等,但同时也需要合理控制装备的重量,以减少负担并提高机动性。参赛者需要权衡装备的必要性和其重量,选择轻便而又功能齐全的装备,以获得最佳的任务表现。 综上所述,氧气值、燃料值和装备重量是20232月蓝桥STEMA评测C中级的三个重要指标。参赛者需合理规划、储备和利用氧气和燃料,同时也需要精心选择装备,以保证任务的安全和效率。这些指标将考察参赛者的规划能力、资源管理能力和任务执行能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值