Submission #195654

#TimeUsernameProblemLanguageResultExecution timeMemory
195654T0p_Art Exhibition (JOI18_art)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; struct data{ long long sz, vl; bool operator < (const data & o) const{ return sz < o.sz; } }; long long a[500500], b[500500]; vector<data> v; int main(){ int n; long long ans = 0; scanf(" %d",&n); for(int i=0 ; i<n ; i++){ long long sz, vl; scanf(" %lld %lld",&sz,&vl); v.push_back({sz, vl}); } v.push_back({0, 0}); sort(v.begin(), v.end()); for(int i=1 ; i<=n ; i++) v[i].vl += v[i-1].vl; b[0] = 1e18; for(int i=1 ; i<=n ; i++){ a[i] = v[i].vl - v[i].sz; a[i] = max(a[i], a[i-1]); b[i] = v[i-1].vl - v[i].sz; b[i] = min(b[i], b[i-1]); ans = max(ans, a[i] - b[i-1]); } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

art.cpp:12:12: error: template argument 1 is invalid
 vector<data> v;
            ^
art.cpp:12:12: error: template argument 2 is invalid
art.cpp: In function 'int main()':
art.cpp:21:5: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   v.push_back({sz, vl});
     ^~~~~~~~~
art.cpp:23:4: error: request for member 'push_back' in 'v', which is of non-class type 'int'
  v.push_back({0, 0});
    ^~~~~~~~~
art.cpp:24:9: error: request for member 'begin' in 'v', which is of non-class type 'int'
  sort(v.begin(), v.end());
         ^~~~~
art.cpp:24:20: error: request for member 'end' in 'v', which is of non-class type 'int'
  sort(v.begin(), v.end());
                    ^~~
art.cpp:25:31: error: invalid types 'int[int]' for array subscript
  for(int i=1 ; i<=n ; i++) v[i].vl += v[i-1].vl;
                               ^
art.cpp:25:44: error: invalid types 'int[int]' for array subscript
  for(int i=1 ; i<=n ; i++) v[i].vl += v[i-1].vl;
                                            ^
art.cpp:28:13: error: invalid types 'int[int]' for array subscript
   a[i] = v[i].vl - v[i].sz;
             ^
art.cpp:28:23: error: invalid types 'int[int]' for array subscript
   a[i] = v[i].vl - v[i].sz;
                       ^
art.cpp:30:15: error: invalid types 'int[int]' for array subscript
   b[i] = v[i-1].vl - v[i].sz;
               ^
art.cpp:30:25: error: invalid types 'int[int]' for array subscript
   b[i] = v[i-1].vl - v[i].sz;
                         ^
art.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d",&n);
  ~~~~~^~~~~~~~~~
art.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %lld %lld",&sz,&vl);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~