Submission #1299099

#TimeUsernameProblemLanguageResultExecution timeMemory
1299099sitingfakeMizuyokan 2 (JOI23_mizuyokan2)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; // define #define execute cerr << " Time: " << fixed << setprecision(6) << (1.0 * clock() / CLOCKS_PER_SEC) << "s\n"; #define ll long long #define int ll #define ii pair <int , int> #define iii pair <int , ii> #define se second #define fi first #define all(v) (v).begin() , (v).end() #define Unique(v) sort(all(v)) , v.resize(unique(all(v)) - v.begin()) #define bit(x,i) (((x) >> (i)) & 1LL) #define flip(x,i) ((x) ^ (1LL << (i))) #define ms(d,x) memset(d , x , sizeof(d)) #define exist __exist #define ends __ends #define visit visited #define left __left #define right __right #define prev __prev #define next __next #define sitingfake 1 #define orz 1 //constant const long long mod = 1e9 + 7; const long long linf = 4557430888798830399LL; const long long nlinf = -4485090715960753727LL; const int LOG = 20; const int inf = 1061109567; const int ninf = -1044266559; const int dx[] = {0 , -1 , 0 , 1}; const int dy[] = {-1 , 0 , 1 , 0}; template<typename T> bool maximize(T &a, const T &b) { if(a < b) {a = b; return 1;} return 0; } template<typename T> bool minimize(T &a, const T &b) { if(a > b) {a = b; return 1;} return 0; } void Plus(ll & a ,ll b) { b %= mod; a += b; if(a < 0) a += mod; a %= mod; return; } void Mul(ll & a, ll b) { (a *= (b % mod)) %= mod; return; } //code const int maxn = 200005; int n , q; int a[maxn]; struct query { int pos , val; int l , r; }Q[50005]; namespace sub3 { int pref[maxn] , dp[maxn] , val[maxn]; void Query(int l ,int r) { int len = (r - l + 1); for(int i = 1; i <= len; i++) val[i] = a[l + i - 1]; pref[0] = 0; for(int i = 1; i <= len; i++) pref[i] = pref[i - 1] + val[i]; for(int i = 0; i <= len; i++) dp[i] = -inf; dp[1] = 1; int ans = 1; for(int i = 1; i <= len; i++) { if(i != 1 && pref[i - 1] > val[i]) dp[i] = max(dp[i], 2); for(int j = i - 1; j >= 2; j--) { long long sumMid = pref[i - 1] - pref[j - 1]; if(sumMid > val[i] && sumMid > val[j - 1]) { dp[i] = max(dp[i] , dp[j - 1] + 2); } } if(pref[len] - pref[i] > val[i]) ans = max(ans , dp[i] + 1); } ans = max(ans , dp[len]); cout << ans << "\n"; } void solve() { for(int i = 1; i <= q; i++) { a[Q[i].pos] = Q[i].val; Query(Q[i].l , Q[i].r); } } } void solve(void) { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; } cin >> q; for(int i = 1; i <= q; i++) { cin >> Q[i].pos >> Q[i].val >> Q[i].l >> Q[i].r; Q[i].l++; } if(q <= 10) sub3 :: solve(); } /** 9 3 3 3 2 9 9 1 1 2 1 1 3 0 9 3 6 2 9 10 1 2 **/ signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int tc = 1; // cin >> tc; while(tc--) solve(); // execute; }

Compilation message (stderr)

mizuyokan2.cpp: In function 'void sub3::Query(long long int, long long int)':
mizuyokan2.cpp:98:59: error: no matching function for call to 'max(long long int&, int)'
   98 |             if(i != 1 && pref[i - 1] > val[i]) dp[i] = max(dp[i], 2);
      |                                                        ~~~^~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from mizuyokan2.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
mizuyokan2.cpp:98:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   98 |             if(i != 1 && pref[i - 1] > val[i]) dp[i] = max(dp[i], 2);
      |                                                        ~~~^~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
mizuyokan2.cpp:98:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   98 |             if(i != 1 && pref[i - 1] > val[i]) dp[i] = max(dp[i], 2);
      |                                                        ~~~^~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
mizuyokan2.cpp:98:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   98 |             if(i != 1 && pref[i - 1] > val[i]) dp[i] = max(dp[i], 2);
      |                                                        ~~~^~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
mizuyokan2.cpp:98:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   98 |             if(i != 1 && pref[i - 1] > val[i]) dp[i] = max(dp[i], 2);
      |                                                        ~~~^~~~~~~~~~
mizuyokan2.cpp: In function 'int main()':
mizuyokan2.cpp:155:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  155 |        freopen(task".inp","r",stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mizuyokan2.cpp:156:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  156 |        freopen(task".out","w",stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~