Created
February 13, 2012 00:16
-
-
Save tksmaru/1812001 to your computer and use it in GitHub Desktop.
SRM241 div1-score250 もう一度考えてみた。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
//SRM241 | |
public class ReportAccess { | |
public String[] whoCanSee(String[] userNames, String[] allowedData, | |
String[] reportData) { | |
List<String> users = new ArrayList<String>(); | |
int requires = reportData.length; | |
for (int i = 0; i < allowedData.length; i++) { | |
String[] splited = allowedData[i].split(" "); | |
int count = 0; | |
for (String allowed : splited) { | |
for (String report : reportData) { | |
if (allowed.equals(report)) { | |
count++; | |
} | |
} | |
} | |
if (count == requires) { | |
users.add(userNames[i]); | |
} | |
} | |
Collections.sort(users); | |
return users.toArray(new String[users.size()]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment