제출 #1128338

#제출 시각아이디문제언어결과실행 시간메모리
1128338mnbvcxz123Art Exhibition (JOI18_art)C++20
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; constexpr ll INF = 1e18, mod = 1e9 + 7, N = 2e5 + 5; void solve(){ ll n,m; cin >> n; vector<pair<int,int>>v; v.push_back({0, 0}); ll a,b; for(int i = 0; i < n; i++){ cin >> a >> b; v.push_back({a,b}); } sort(all(v)); ll maxi = 0; ll cur = 0; for(int i = 1; i <= n; i++){ cur += v[i].second; cur = max(cur, v[i].first + v[i].second); maxi = max(maxi, cur - v[i].first); } cout << maxi << endl; } int main() { fast; ll t = 1; // cin >> t; while(t--){ solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

art.cpp:4:11: error: 'll' does not name a type
    4 | constexpr ll INF = 1e18, mod = 1e9 + 7, N = 2e5 + 5;
      |           ^~
art.cpp: In function 'void solve()':
art.cpp:7:5: error: 'll' was not declared in this scope
    7 |     ll n,m;
      |     ^~
art.cpp:8:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |     cin >> n;
      |            ^
      |            yn
art.cpp:11:7: error: expected ';' before 'a'
   11 |     ll a,b;
      |       ^~
      |       ;
art.cpp:13:15: error: 'a' was not declared in this scope
   13 |        cin >> a >> b;
      |               ^
art.cpp:13:20: error: 'b' was not declared in this scope
   13 |        cin >> a >> b;
      |                    ^
art.cpp:14:19: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   14 |        v.push_back({a,b});
      |        ~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from art.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
art.cpp:16:10: error: 'all' was not declared in this scope
   16 |     sort(all(v));
      |          ^~~
art.cpp:16:10: note: suggested alternatives:
In file included from /usr/include/c++/11/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from art.cpp:1:
/usr/include/c++/11/bits/fs_fwd.h:154:7: note:   'std::filesystem::perms::all'
  154 |       all               =  0777,
      |       ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:146,
                 from art.cpp:1:
/usr/include/c++/11/ranges:1130:27: note:   'std::ranges::views::all'
 1130 |     inline constexpr _All all;
      |                           ^~~
art.cpp:17:7: error: expected ';' before 'maxi'
   17 |     ll maxi = 0;
      |       ^~~~~
      |       ;
art.cpp:18:7: error: expected ';' before 'cur'
   18 |     ll cur = 0;
      |       ^~~~
      |       ;
art.cpp:20:9: error: 'cur' was not declared in this scope
   20 |         cur += v[i].second;
      |         ^~~
art.cpp:22:9: error: 'maxi' was not declared in this scope
   22 |         maxi = max(maxi, cur - v[i].first);
      |         ^~~~
art.cpp:24:13: error: 'maxi' was not declared in this scope
   24 |     cout << maxi << endl;
      |             ^~~~
art.cpp: In function 'int main()':
art.cpp:28:5: error: 'll' was not declared in this scope
   28 |     ll t = 1;
      |     ^~
art.cpp:30:11: error: 't' was not declared in this scope; did you mean 'tm'?
   30 |     while(t--){
      |           ^
      |           tm