Submission #1269355

#TimeUsernameProblemLanguageResultExecution timeMemory
1269355PagodePaivaSjeckanje (COCI21_sjeckanje)C++20
Compilation error
0 ms0 KiB
import sys import threading def main(): import sys data = sys.stdin line = data.readline().split() n, q = int(line[0]), int(line[1]) a = list(map(int, data.readline().split())) # If there's only one checkpoint, scenic score is always 0 if n == 1: for _ in range(q): data.readline() print(0) return # Build difference array d[i] = a[i+1] - a[i] d = [a[i+1] - a[i] for i in range(n-1)] # Initial total scenic score = sum of absolute differences total = sum(abs(v) for v in d) out = [] for _ in range(q): l, r, x = map(int, data.readline().split()) # Convert to 0-based l -= 1 r -= 1 # Update the difference at l-1 if l > 0 if l > 0: idx = l - 1 old = d[idx] new = old + x total += abs(new) - abs(old) d[idx] = new # Update the difference at r if r < n-1 if r < n - 1: idx = r old = d[idx] new = old - x total += abs(new) - abs(old) d[idx] = new out.append(str(total)) sys.stdout.write("\n".join(out)) if __name__ == "__main__": main()

Compilation message (stderr)

Main.cpp:10:7: error: invalid preprocessing directive #If; did you mean #if?
   10 |     # If there's only one checkpoint, scenic score is always 0
      |       ^~
      |       if
Main.cpp:10:15: warning: missing terminating ' character
   10 |     # If there's only one checkpoint, scenic score is always 0
      |               ^
Main.cpp:16:7: error: invalid preprocessing directive #Build
   16 |     # Build difference array d[i] = a[i+1] - a[i]
      |       ^~~~~
Main.cpp:18:7: error: invalid preprocessing directive #Initial
   18 |     # Initial total scenic score = sum of absolute differences
      |       ^~~~~~~
Main.cpp:23:11: error: invalid preprocessing directive #Convert
   23 |         # Convert to 0-based
      |           ^~~~~~~
Main.cpp:26:11: error: invalid preprocessing directive #Update
   26 |         # Update the difference at l-1 if l > 0
      |           ^~~~~~
Main.cpp:33:11: error: invalid preprocessing directive #Update
   33 |         # Update the difference at r if r < n-1
      |           ^~~~~~
Main.cpp:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
Main.cpp:1:1: note: C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c++20'