제출 #772958

#제출 시각아이디문제언어결과실행 시간메모리
772958LucaIlieWorst Reporter 3 (JOI18_worst_reporter3)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; struct period { int per, l, r; }; const int MAX_N = 5e5 + 1; const int MAX_T = 2e9; int d[MAX_N], per[MAX_N]; int higher( int x, int n ) { return ((int)ceil( (double)n / x )) * x; } int lower( int x, int n ) { return ((int)floor( (double)n / x )) * x; } vector<period> periods; signed main() { int n, q; cin >> n >> q; d[0] = 1; for ( int i = 1; i <= n; i++ ) cin >> d[i]; int maxx = 1, pos = 0; per[0] = 1; for ( int i = 1; i <= n; i++ ) { per[i] = higher( per[pos], d[i] ); if ( d[i] > maxx ) { periods.push_back( { per[pos], pos, i - 1 } ); maxx = d[i]; pos = i; } if ( per[i] > MAX_T ) break; } periods.push_back( { per[pos], pos, n } ); while ( q-- ) { int t, l, r, ans = 0; cin >> t >> l >> r; for ( period p: periods ) { int lp = lower( p.per, t ) - p.r, rp = lower( p.per, t ) - p.l; ans += max( 0, min( rp, r ) - max( lp, l ) + 1 ); } cout << ans << "\n"; } return 0; }

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

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:53:60: error: no matching function for call to 'max(int, long long int)'
   53 |             ans += max( 0, min( rp, r ) - max( lp, l ) + 1 );
      |                                                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from worst_reporter3.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
worst_reporter3.cpp:53:60: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   53 |             ans += max( 0, min( rp, r ) - max( lp, l ) + 1 );
      |                                                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from worst_reporter3.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
worst_reporter3.cpp:53:60: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   53 |             ans += max( 0, min( rp, r ) - max( lp, l ) + 1 );
      |                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from worst_reporter3.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
worst_reporter3.cpp:53:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |             ans += max( 0, min( rp, r ) - max( lp, l ) + 1 );
      |                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from worst_reporter3.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
worst_reporter3.cpp:53:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |             ans += max( 0, min( rp, r ) - max( lp, l ) + 1 );
      |                                                            ^