Submission #623015

#TimeUsernameProblemLanguageResultExecution timeMemory
623015PoonYaPatSafety (NOI18_safety)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n,k,a[200001],h[200001]; long long ans; int main() {  ios_base::sync_with_stdio(0); cin.tie(0);  cin>>n>>k;  for (int i=1; i<=n; ++i) cin>>h[i];  a[n]=h[n];  for (int i=n; i>1; --i) {    if (a[i]-h[i-1]>k) a[i-1]=a[i]-k;    else if (h[i-1]-a[i]>k) a[i-1]=a[i]+k;    else a[i-1]=h[i-1];    ans+=abs(a[i-1]-h[i-1]);  }  cout<<ans; }

Compilation message (stderr)

safety.cpp:8:2: error: extended character   is not valid in an identifier
    8 |   ios_base::sync_with_stdio(0); cin.tie(0);
      |  ^
safety.cpp:9:2: error: extended character   is not valid in an identifier
    9 |   cin>>n>>k;
      |  ^
safety.cpp:10:2: error: extended character   is not valid in an identifier
   10 |   for (int i=1; i<=n; ++i) cin>>h[i];
      |  ^
safety.cpp:11:2: error: extended character   is not valid in an identifier
   11 |   a[n]=h[n];
      |  ^
safety.cpp:12:2: error: extended character   is not valid in an identifier
   12 |   for (int i=n; i>1; --i) {
      |  ^
safety.cpp:13:2: error: extended character   is not valid in an identifier
   13 |     if (a[i]-h[i-1]>k) a[i-1]=a[i]-k;
      |  ^
safety.cpp:13:5: error: extended character   is not valid in an identifier
   13 |     if (a[i]-h[i-1]>k) a[i-1]=a[i]-k;
      |    ^
safety.cpp:14:2: error: extended character   is not valid in an identifier
   14 |     else if (h[i-1]-a[i]>k) a[i-1]=a[i]+k;
      |  ^
safety.cpp:14:5: error: extended character   is not valid in an identifier
   14 |     else if (h[i-1]-a[i]>k) a[i-1]=a[i]+k;
      |    ^
safety.cpp:15:2: error: extended character   is not valid in an identifier
   15 |     else a[i-1]=h[i-1];
      |  ^
safety.cpp:15:5: error: extended character   is not valid in an identifier
   15 |     else a[i-1]=h[i-1];
      |    ^
safety.cpp:16:2: error: extended character   is not valid in an identifier
   16 |     ans+=abs(a[i-1]-h[i-1]);
      |  ^
safety.cpp:16:5: error: extended character   is not valid in an identifier
   16 |     ans+=abs(a[i-1]-h[i-1]);
      |    ^
safety.cpp:17:2: error: extended character   is not valid in an identifier
   17 |   }
      |  ^
safety.cpp:18:2: error: extended character   is not valid in an identifier
   18 |   cout<<ans;
      |  ^
safety.cpp: In function 'int main()':
safety.cpp:8:2: error: '\U000000a0ios_base' has not been declared
    8 |   ios_base::sync_with_stdio(0); cin.tie(0);
      |  ^~~~~~~~~
safety.cpp:9:2: error: '\U000000a0cin' was not declared in this scope
    9 |   cin>>n>>k;
      |  ^~~~
safety.cpp:10:9: error: expected primary-expression before 'int'
   10 |   for (int i=1; i<=n; ++i) cin>>h[i];
      |        ^~~
safety.cpp:10:18: error: 'i' was not declared in this scope
   10 |   for (int i=1; i<=n; ++i) cin>>h[i];
      |                 ^
safety.cpp:11:2: error: '\U000000a0a' was not declared in this scope
   11 |   a[n]=h[n];
      |  ^~
safety.cpp:12:9: error: expected primary-expression before 'int'
   12 |   for (int i=n; i>1; --i) {
      |        ^~~
safety.cpp:18:2: error: '\U000000a0cout' was not declared in this scope
   18 |   cout<<ans;
      |  ^~~~~