Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List < List < Integer >> optimalUtilizationOnlyMani2(int deviceCapacity, List < List < Integer >> foregroundAppList, List < List < Integer >> backgroundAppList) {
- if (foregroundAppList == null || foregroundAppList.isEmpty() || backgroundAppList == null || backgroundAppList.isEmpty()) {
- return new ArrayList < >();
- }
- // map of memory and id of foreground app, id of background app
- List < List < Integer >> output = new ArrayList < >();
- Integer maximum_memory = Integer.MIN_VALUE;
- for (List < Integer > forgroundApp: foregroundAppList) {
- for (List < Integer > backgroundApp: backgroundAppList) {
- Integer combined_memory = forgroundApp.get(1) + backgroundApp.get(1);
- if (combined_memory <= deviceCapacity && combined_memory >= maximum_memory) {
- if (combined_memory > maximum_memory) {
- maximum_memory = combined_memory;
- output.clear();
- }
- output.add(Arrays.asList(forgroundApp.get(0), backgroundApp.get(0)));
- }
- }
- }
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement