Submission #772271

#TimeUsernameProblemLanguageResultExecution timeMemory
772271sushikidRabbit Carrot (LMIO19_triusis)Java
100 / 100
417 ms31364 KiB
import java.util.*; import java.io.*; public class triusis { public static void main(String[] args) throws IOException{ BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(r.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); TreeMap<Long, Integer> multiset = new TreeMap<>(); for (int i = 1; i <= n; i++) { int x = Integer.parseInt(r.readLine()); long z = m * i - x; if(z < 0){ continue; } if(multiset.higherKey(z) != null){ multiset.put(multiset.higherKey(z), multiset.get(multiset.higherKey(z)) - 1); if(multiset.get(multiset.higherKey(z)) == 0){ multiset.remove(multiset.higherKey(z)); } } multiset.put(z, multiset.getOrDefault(z, 0) + 1); } int ans = 0; for(int e : multiset.values()){ ans += e; } pw.println(n - ans); pw.close(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...