fork download
  1. uses math;
  2. const fi='';
  3. fo='';
  4. maxn=50000;
  5. maxq=200000;
  6. type arrp=record
  7. dau:longint;
  8. cuoi:longint;
  9. end;
  10. var i,j,n,q:longint;
  11. f:text;
  12. res1,res2:longint;
  13. a:array[1..maxn] of longint;
  14. p:array[1..maxq] of arrp;
  15. mind,maxd:array[1..maxn*4] of longint;
  16. procedure nhap;
  17. begin
  18. assign(f,fi);
  19. reset(f);
  20. readln(f,n,q);
  21. for i:=1 to n do readln(f,a[i]);
  22. for i:=1 to q do readln(f,p[i].dau,p[i].cuoi);
  23. close(f);
  24. end;
  25. procedure update(k,l,r:longint);
  26. var mid:longint;
  27. begin
  28. if l=r then
  29. begin
  30. maxd[k]:=a[l];
  31. mind[k]:=a[l];
  32. end
  33. else
  34. begin
  35. mid:=(l+r) div 2;
  36. update(k*2,l,mid);
  37. update(k*2+1,mid+1,r);
  38. mind[k]:=min(mind[k*2],mind[k*2+1]);
  39. maxd[k]:=max(maxd[k*2],maxd[k*2+1]);
  40. end;
  41. end;
  42. procedure find(k,l,r:longint);
  43. var mid:longint;
  44. begin
  45. if (l>j) or (r<i) then exit;
  46. if (i<=l) and (j>=r) then
  47. begin
  48. res1:=min(res1,mind[k]);
  49. res2:=max(res2,maxd[k]);
  50. exit;
  51. end;
  52. mid:=(l+r) div 2;
  53. find(k*2,l,mid);
  54. find(k*2+1,mid+1,r);
  55. end;
  56. procedure xuat;
  57. var k:longint;
  58. begin
  59. assign(f,fo);
  60. rewrite(f);
  61. update(1,1,n);
  62. for k:=1 to q do
  63. begin
  64. res1:=high(longint);
  65. res2:=0;
  66. i:=p[k].dau;
  67. j:=p[k].cuoi;
  68. find(1,1,n);
  69. writeln(f,res2-res1);
  70. end;
  71. close(f);
  72. end;
  73. begin
  74. nhap;
  75. xuat;
  76. end.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:12: error: empty character constant
prog.cpp:3:12: error: empty character constant
prog.cpp:13:17: error: too many decimal points in number
prog.cpp:14:17: error: too many decimal points in number
prog.cpp:15:25: error: too many decimal points in number
prog.cpp:1: error: 'uses' does not name a type
prog.cpp:2: error: ISO C++ forbids declaration of 'fi' with no type
prog.cpp:3: error: expected constructor, destructor, or type conversion before '=' token
prog.cpp:4: error: expected constructor, destructor, or type conversion before '=' token
prog.cpp:5: error: expected constructor, destructor, or type conversion before '=' token
prog.cpp:6: error: 'type' does not name a type
prog.cpp:8: error: function definition does not declare parameters
prog.cpp:9: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:10: error: 'var' does not name a type
prog.cpp:11: error: function definition does not declare parameters
prog.cpp:12: error: expected constructor, destructor, or type conversion before ',' token
prog.cpp:12: error: a function-definition is not allowed here before ':' token
prog.cpp:13: error: function definition does not declare parameters
prog.cpp:14: error: function definition does not declare parameters
prog.cpp:15: error: expected constructor, destructor, or type conversion before ',' token
prog.cpp:15: error: a function-definition is not allowed here before ':' token
prog.cpp:16: error: 'procedure' does not name a type
prog.cpp:17: error: 'begin' does not name a type
prog.cpp:19: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:20: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:21: error: expected unqualified-id before 'for'
prog.cpp:22: error: expected unqualified-id before 'for'
prog.cpp:23: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:24: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:25: error: 'procedure' does not name a type
prog.cpp:26: error: 'var' does not name a type
prog.cpp:28: error: expected constructor, destructor, or type conversion before 'if'
prog.cpp:31: error: 'k' was not declared in this scope
prog.cpp:31: error: function definition does not declare parameters
prog.cpp:33: error: expected constructor, destructor, or type conversion before 'else'
prog.cpp:36: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:37: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:38: error: 'k' was not declared in this scope
prog.cpp:38: error: function definition does not declare parameters
prog.cpp:39: error: 'k' was not declared in this scope
prog.cpp:39: error: function definition does not declare parameters
prog.cpp:40: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:41: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:42: error: 'procedure' does not name a type
prog.cpp:43: error: 'var' does not name a type
prog.cpp:45: error: expected constructor, destructor, or type conversion before 'if'
prog.cpp:46: error: expected unqualified-id before 'if'
prog.cpp:49: error: function definition does not declare parameters
prog.cpp:50: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:51: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:52: error: function definition does not declare parameters
prog.cpp:53: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:54: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:55: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:56: error: 'procedure' does not name a type
prog.cpp:57: error: 'var' does not name a type
prog.cpp:58: error: 'begin' does not name a type
prog.cpp:60: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:61: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:62: error: expected unqualified-id before 'for'
prog.cpp:65: error: function definition does not declare parameters
prog.cpp:66: error: function definition does not declare parameters
prog.cpp:67: error: function definition does not declare parameters
prog.cpp:68: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:69: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:70: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:71: error: expected constructor, destructor, or type conversion before '(' token
prog.cpp:72: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:73: error: 'begin' does not name a type
prog.cpp:75: error: expected constructor, destructor, or type conversion before ';' token
prog.cpp:76: error: expected constructor, destructor, or type conversion before '.' token
stdout
Standard output is empty