Badges
Certifications
Work Experience
Co-Founder
RFEyeD•  January 2025 - Present•  aswe
import java.io.*; import java.util.*; public class Solution { static class AdSlot implements Comparable<AdSlot> { int duration; int payment; double revenuePerSecond; public AdSlot(int duration, int payment) { this.duration = duration; this.payment = payment; this.revenuePerSecond = (double) payment / duration; } @Override public int compareTo(AdSlot other) { return Double.compare(other.revenuePerSecond, this.revenuePerSecond); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] durations = new int[n]; int[] payments = new int[n]; for (int i = 0; i < n; i++) { durations[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { payments[i] = sc.nextInt(); } int totalTime = sc.nextInt(); AdSlot[] adSlots = new AdSlot[n]; for (int i = 0; i < n; i++) { adSlots[i] = new AdSlot(durations[i], payments[i]); } Arrays.sort(adSlots); double maxRevenue = 0.0; for (AdSlot adSlot : adSlots) { if (totalTime >= adSlot.duration) { maxRevenue += adSlot.payment; totalTime -= adSlot.duration; } else { maxRevenue += adSlot.revenuePerSecond * totalTime; break; } } System.out.printf("%.2f\n", maxRevenue); } }
Education
23dce071 has not updated education details yet.
Links
23dce071 has not updated links details yet.
Skills
23dce071 has not updated skills details yet.