submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s976760960
p03839
C++
#pragma once #include "Macro.h" namespace AGC008B { void Run(void) { ll n, k; cin >> n >> k; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; ll l = 0; ll r = k - 1; vector<ll> ans_w(1); rep(i, 1, n) ans_w[0] += (0 < a[i] && k <= i) ? a[i] : 0; while (1) { // 白く塗ったKマスをスライドさせて累積 l++; r++; if (r == n) break; ans_w.push_back(ans_w.back()); ans_w.back() += (0 < a[l - 1]) ? a[l - 1] : 0; ans_w.back() += (0 < a[r]) ? -a[r] : 0; } l = 0; r = k - 1; vector<ll> ans_b(1); rep(i, 0, n) ans_b[0] += (i < k) ? a[i] : (k <= i && 0 < a[i]) ? a[i] : 0; while (1) { // 黒く塗ったKマスをスライドさせて累積 l++; r++; if (r == n) break; ans_b.push_back(ans_b.back()); ans_b.back() += (0 < a[l - 1]) ? 0 : -a[l - 1]; ans_b.back() += (0 < a[r]) ? 0 : a[r]; } cout << max(*max_element(all(ans_w)), *max_element(all(ans_b))); } }; int main(void) { AGC008B::Run(); return 0; }
a.cc:1:9: warning: #pragma once in main file 1 | #pragma once | ^~~~ a.cc:3:10: fatal error: Macro.h: No such file or directory 3 | #include "Macro.h" | ^~~~~~~~~ compilation terminated.
s468959515
p03839
C++
// https://atcoder.jp/contests/agc008/tasks/agc008_b #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; #define EPS (1e-9) #define INF (1e9) #define INFL (1e18) #define MOD (1000000007) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = (n)-1; i >= 0; i--) #define FOREACH(x, a) for (auto &(x) : (a)) #define ALL(obj) (obj).begin(), (obj).end() #define ALLR(obj) (obj).rbegin(), (obj).rend() #define LEN(x) (sizeof(x) / sizeof(*(x))) // ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<ll> v(n); ll sum = 0, pos = 0, now = 0, minv = 0, ncnt = 0; bool nflag = false; REP(i, n) { cin >> v[i]; if (v[i] > 0) sum += v[i]; if (v[i] <= 0) { ncnt++; if (ncnt >= k) { nflag = true; } } else { ncnt = 0; } } // マイナスがK個以上連続したら、プラスのみ加算 if (nflag) { cout << sum << endl; return 0; } sum = 0; REP(i, k) now += v[i]; minv = now; for (int i = k; i < n; i++) { now += v[i] - v[i - k]; if (minv < now) { minv = now; pos = i - k + 1; } } for (int i = 0; i < pos; i++) { if (v[i] > 0) sum += v[i]; } for (int i = pos + k; i < n; i++) { if (v[i] > 0) sum += v[i]; } // 求めた最大値がマイナスなら、白にして加算しない cout << sum + max(0, minv) << endl; return 0; }
a.cc: In function 'int main()': a.cc:68:22: error: no matching function for call to 'max(int, ll&)' 68 | cout << sum + max(0, minv) << endl; | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:68:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 68 | cout << sum + max(0, minv) << endl; | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:68:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 68 | cout << sum + max(0, minv) << endl; | ~~~^~~~~~~~~
s496128992
p03839
C++
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,l) for(lli i=s;i<l;i++) #define DEBUG 0 #define INF (1LL<<50) #define MOD 1000000007 signed main(){ lli n,k; cin>>n>>k; lli flag=0; vector<lli> a(n); REP(i,0,n){ cin>>a[i]; if(a[i]>=0)flag++; } /*data[i], a0からaiまでのプラスのみ足し合わせた数*/ vector<lli> data(n+1,0); data[0] = max(0LL,a[0]); REP(i,1,n)data[i] = data[i-1] + max(0LL,a[i]); lli sum = 0; lli flag=0; /*先頭k個を黒にしたときの尺取りを行う*/ REP(i,0,k)sum += a[i]; if(DEBUG)cout<<"first sum ="<<sum<<endl; data[n] = data[n-1]; lli ans = -INF; if(flag==n)ans = data[n]; /*黒で塗った時*/ ans = max(ans,sum + data[n-1]-data[k]); if(DEBUG)cout<<"BALL ans="<<ans<<endl; /*白で塗った時*/ ans = max(ans,data[n-1]-data[k-1]); if(DEBUG)cout<<"WALL ans="<<ans<<endl; if(DEBUG){ for(lli i=0;i<n;i++){ cout<<data[i]<<endl; } } if(DEBUG)cout<<"ans="<<ans<<endl; for(lli i=k;i<n;i++){ if(DEBUG)cout<<"i="<<i<<endl; sum += a[i]; sum -= a[i-k]; if(DEBUG)cout<<"sum="<<sum<<endl; lli next = sum + data[n-1] - data[i+1]; if(i-k-1>=0)next += data[i-k-1]; ans = max(ans,next); if(DEBUG)cout<<"BALL ans="<<ans<<endl; ans = max(ans,data[n-1] - data[i] + data[i-k]); if(DEBUG)cout<<"WALL ans="<<ans<<endl; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:30:13: error: redeclaration of 'long long int flag' 30 | lli flag=0; | ^~~~ a.cc:16:13: note: 'long long int flag' previously declared here 16 | lli flag=0; | ^~~~
s144492962
p03839
C++
#include<bits/stdc++.h> using namespace std; #define REP(i,k,n) for(int i=k;i<n;i++) #define INF 1844674407370955161 #define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0])) #define MOD 1000000007 int lcm(int a,int b){ return a/__gcd(a,b) * b; } void clear( std::queue<pair<int,int> > &q ) { std::queue<pair<int,int> > empty; std::swap( q, empty ); } bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } template<typename T> std::vector<T> enum_div(T n)//nの約数を列挙 { std::vector<T> ret; for(T i=1 ; i*i<=n ; ++i) { if(n%i == 0) { ret.push_back(i); if(i!=1 && i*i!=n) { ret.push_back(n/i); } } } return ret; } map< int, int > prime_factor(int n) { map< int, int > ret; for(int i = 2; i * i <= n; i++) { while(n % i == 0) { ret[i]++; n /= i; } } if(n != 1) ret[n] = 1; return ret; } class DisjointSet{ public: vector<int> rank, p; DisjointSet(){ } DisjointSet(int size){ rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size;i++){ makeSet(i); } } void makeSet(int x){ p[x] = x; rank[x] = 0; } bool same(int x,int y){ return findSet(x) == findSet(y); } void unite(int x,int y){ link(findSet(x), findSet(y)); } void link(int x,int y){ if(rank[x]>rank[y]){ p[y] = x; }else{ p[x] = y; if(rank[x]==rank[y]){ rank[y]++; } } } int findSet(int x){ if(x!=p[x]){ p[x] = findSet(p[x]); } return p[x]; } }; signed main() { int N,K; cin>>N>>K; long long a[N]; long long x[N]; long long b[N]; REP(i,0,N){ cin>>a[i]; x[i]=0; b[i]=0; } x[0]=a[0]; if(a[0]>0){ b[0]=a[0]; } REP(i,1,N+1){ x[i]=x[i-1]+a[i]; if(a[i]>0){ b[i]=b[i-1]+a[i]; }else{ b[i]=b[i-1]; } } int ans=0; REP(i,0,N-K+1){ int tmp=0; if(i==0){ tmp=x[K-1]+b[N-1]-b[K-1]; }else if(i==N-K){ tmp=x[N-1]-x[N-K-1]+b[N-K-1]; }else{ tmp=x[K+i-1]-x[i-1]+b[i-1]+b[N-1]-b[K+i-1]; } ans=max(ans,tmp); if(i==0){ tmp=b[N-1]-b[K-1]; }else if(i==N-K){ tmp=b[N-K-1]; }else{ tmp=b[i-1]+b[N-1]-b[K+i-1]; } ans=max(ans,tmp); } cout<<ans<<endl; }#include<bits/stdc++.h> using namespace std; #define REP(i,k,n) for(int i=k;i<n;i++) #define INF 1844674407370955161 #define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0])) #define MOD 1000000007 int lcm(int a,int b){ return a/__gcd(a,b) * b; } void clear( std::queue<pair<int,int> > &q ) { std::queue<pair<int,int> > empty; std::swap( q, empty ); } bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } template<typename T> std::vector<T> enum_div(T n)//nの約数を列挙 { std::vector<T> ret; for(T i=1 ; i*i<=n ; ++i) { if(n%i == 0) { ret.push_back(i); if(i!=1 && i*i!=n) { ret.push_back(n/i); } } } return ret; } map< int, int > prime_factor(int n) { map< int, int > ret; for(int i = 2; i * i <= n; i++) { while(n % i == 0) { ret[i]++; n /= i; } } if(n != 1) ret[n] = 1; return ret; } class DisjointSet{ public: vector<int> rank, p; DisjointSet(){ } DisjointSet(int size){ rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size;i++){ makeSet(i); } } void makeSet(int x){ p[x] = x; rank[x] = 0; } bool same(int x,int y){ return findSet(x) == findSet(y); } void unite(int x,int y){ link(findSet(x), findSet(y)); } void link(int x,int y){ if(rank[x]>rank[y]){ p[y] = x; }else{ p[x] = y; if(rank[x]==rank[y]){ rank[y]++; } } } int findSet(int x){ if(x!=p[x]){ p[x] = findSet(p[x]); } return p[x]; } }; signed main() { int N,K; cin>>N>>K; long long a[N]; long long x[N]; long long b[N]; REP(i,0,N){ cin>>a[i]; x[i]=0; b[i]=0; } x[0]=a[0]; if(a[0]>0){ b[0]=a[0]; } REP(i,1,N+1){ x[i]=x[i-1]+a[i]; if(a[i]>0){ b[i]=b[i-1]+a[i]; }else{ b[i]=b[i-1]; } } int ans=0; REP(i,0,N-K+1){ int tmp=0; if(i==0){ tmp=x[K-1]+b[N-1]-b[K-1]; }else if(i==N-K){ tmp=x[N-1]-x[N-K-1]+b[N-K-1]; }else{ tmp=x[K+i-1]-x[i-1]+b[i-1]+b[N-1]-b[K+i-1]; } ans=max(ans,tmp); if(i==0){ tmp=b[N-1]-b[K-1]; }else if(i==N-K){ tmp=b[N-K-1]; }else{ tmp=b[i-1]+b[N-1]-b[K+i-1]; } ans=max(ans,tmp); } cout<<ans<<endl; }
a.cc:170:2: error: stray '#' in program 170 | }#include<bits/stdc++.h> | ^ a.cc:170:3: error: 'include' does not name a type 170 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:183:5: error: redefinition of 'int lcm(int, int)' 183 | int lcm(int a,int b){ | ^~~ a.cc:14:5: note: 'int lcm(int, int)' previously defined here 14 | int lcm(int a,int b){ | ^~~ a.cc:187:6: error: redefinition of 'void clear(std::queue<std::pair<int, int> >&)' 187 | void clear( std::queue<pair<int,int> > &q ) | ^~~~~ a.cc:18:6: note: 'void clear(std::queue<std::pair<int, int> >&)' previously defined here 18 | void clear( std::queue<pair<int,int> > &q ) | ^~~~~ a.cc:192:6: error: redefinition of 'bool IsPrime(int)' 192 | bool IsPrime(int num) | ^~~~~~~ a.cc:23:6: note: 'bool IsPrime(int)' previously defined here 23 | bool IsPrime(int num) | ^~~~~~~ a.cc:212:16: error: redefinition of 'template<class T> std::vector<_Tp> enum_div(T)' 212 | std::vector<T> enum_div(T n)//nの約数を列挙 | ^~~~~~~~ a.cc:43:16: note: 'template<class T> std::vector<_Tp> enum_div(T)' previously declared here 43 | std::vector<T> enum_div(T n)//nの約数を列挙 | ^~~~~~~~ a.cc:230:17: error: redefinition of 'std::map<int, int> prime_factor(int)' 230 | map< int, int > prime_factor(int n) { | ^~~~~~~~~~~~ a.cc:61:17: note: 'std::map<int, int> prime_factor(int)' previously defined here 61 | map< int, int > prime_factor(int n) { | ^~~~~~~~~~~~ a.cc:241:7: error: redefinition of 'class DisjointSet' 241 | class DisjointSet{ | ^~~~~~~~~~~ a.cc:72:7: note: previous definition of 'class DisjointSet' 72 | class DisjointSet{ | ^~~~~~~~~~~ a.cc:286:8: error: redefinition of 'int main()' 286 | signed main() | ^~~~ a.cc:117:8: note: 'int main()' previously defined here 117 | signed main() | ^~~~
s786782172
p03839
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; //template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } //template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } /* attention long longのシフト演算には気をつけよう タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも */ int main(){ int N, K; cin >> N >> K; vector<ll> a(N+1); for(int i=1; i<=N; i++) cin >> a[i]; vector<ll> cum(N+1, 0); vector<ll> cum2(N+1, 0); for(int i=1; i<=N; i++) cum[i] = cum[i-1]+a[i]; for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[i]); ll ans = -(1LL<<59); for(int i=1; i<=N+1-K; i++){ ll tmp = cum[i+K-1]-cum[i-1]; ll tmp2 = 0; tmp += cum2[i-1] + cum2[N]-cum2[i+K-1]; tmp2 += cum2[i-1] + cum2[N]-cum2[i+K-1]; ans = max(ans, max(tmp, tmp2)); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:20:52: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 20 | for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[i]); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:20:52: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 20 | for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:20:52: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 20 | for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[i]); | ~~~^~~~~~~~~
s986814357
p03839
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define tr(container, it) \ for (auto it = container.begin(); it != container.end(); it++) #define scontains(c, x) ((c).find(x) != (c).end()) //O(log n) #define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n) #define pll pair<ll,ll> #define pii pair<int,int> #define mll map<ll,ll> #define in(x, a, b)((x)>=a && (x)<=b) #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1) #define all(x) (x).begin(),(x).end() //#define len(array) (sizeof(array)/sizeof((array)[0])) #define endl '\n' #define what_is(x) cerr << #x << " is " << x << endl; #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); } #define mod(x, m) ((((x) % (m)) + (m)) % (m)) void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } const double PI = 2 * acos(.0); const int INF = 0x3f3f3f3f; const ll LLINF = 1000000000000000005LL;; const ll MOD = (ll) (1e9) + 7; //const ll MOD = (ll) 998244353 ; const double EPS = 1e-10; int readint() { int x; cin >> x; return x; } template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *) array, (T *) (array + N), val); } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto a : v)os << a << " "; return os; } template<typename T> ostream &operator<<(ostream &os, const set<T> &v) { for (auto a : v)os << a << " "; return os; } ll power_mod(ll x, ll y, ll p) { if (y < 0)return 0; ll res = 1; x = x % p; while (y) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } ll power(ll x, ll y) { if (y < 0)return 0; ll res = 1; while (y) { if (y & 1) res = (res * x); y = y >> 1; x *= x; } return res; } int fac[7777777]; void init(int MX) { fac[0] = 1; for (int i = 1; i <= MX; i++) fac[i] = fac[i - 1] * i % MOD; } // Returns n^(-1) mod p int modInverse(int n, int p) { return power_mod(n, p - 2, p); } int comb_mod(int n, int r, int p) { if (r == 0) return 1; return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } int comb(int a, int b) { int res = 1; rep(i, a + 1, a - b + 1)res *= i, res /= a - i + 1; // rep(i,1,b+1)res /= i; return res; } bool equal(double a, double b) { return std::fabs(a - b) < std::numeric_limits<double>::epsilon(); } struct UnionFind { // par[i]:データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである vector<int> par; // sizes[i]:根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { // 最初は全てのデータiがグループiに存在するものとして初期化 rep(i, 0, n) par[i] = i; } // データxが属する木の根を得る int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す } // 2つのデータx, yが属する木をマージする void unite(int x, int y) { // データの根ノードを得る x = find(x); y = find(y); // 既に同じ木に属しているならマージしない if (x == y) return; // xの木がyの木より大きくなるようにする if (sizes[x] < sizes[y]) swap(x, y); // xがyの親になるように連結する par[y] = x; sizes[x] += sizes[y]; // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい } // 2つのデータx, yが属する木が同じならtrueを返す bool same(int x, int y) { return find(x) == find(y); } // データxが含まれる木の大きさを返す int size(int x) { return sizes[find(x)]; } }; //fastest struct cpmFunctor { inline bool operator()(const pair<int, int> &p1, const pair<int, int> &p2) { return p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second); } }; bool isPrime(int n) { // Corner case if (n <= 1) return false; if (n == 2 || n == 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; // Check from 2 to n-1 for (int i = 5; i * i <= n; i += 6) if (n % i == 0) return false; for (int i = 7; i * i <= n; i += 6) if (n % i == 0) return false; return true; } int lcm(int a, int b) { return a / __gcd(a, b) * b; } //class Graph{ // int V; // vector<int>* adj; // //public: // Graph(int V){ // this->V = V; // adj = new vector<int>[V]; // // } // // void addEdge(int from, int to){ // adj[from].push_back(to); // } // // // bool isCyclicUtil(int v, bool visited[], bool *recStack) // { // if(visited[v] == false) // { // // Mark the current node as visited and part of recursion stack // visited[v] = true; // recStack[v] = true; // // // Recur for all the vertices adjacent to this vertex // for(auto i = adj[v].begin(); i != adj[v].end(); ++i) // { // if ( !visited[*i] && isCyclicUtil(*i, visited, recStack) ) // return true; // else if (recStack[*i]) // return true; // } // // } // recStack[v] = false; // remove the vertex from recursion stack // return false; // } // //// Returns true if the graph contains a cycle, else false. //// This function is a variation of DFS() in https://www.geeksforgeeks.org/archives/18212 // bool isCyclic() // { // // Mark all the vertices as not visited and not part of recursion // // stack // bool *visited = new bool[V]; // bool *recStack = new bool[V]; // for(int i = 0; i < V; i++) // { // visited[i] = false; // recStack[i] = false; // } // // // Call the recursive helper function to detect cycle in different // // DFS trees // for(int i = 0; i < V; i++) // if (isCyclicUtil(i, visited, recStack)) // return true; // // return false; // } // // //}; struct edge { int to; int cost; }; class wGraph { int V; vector<edge> *adj; public: wGraph(int V) { this->V = V; adj = new vector<edge>[V]; } void addEdge(int from, int to, int cost) { adj[from].push_back({to, cost}); } }; #define int ll int N, K; int A[101010]; int S[101010],SS[101010]; void solve(){ cin >> N >> K; _for(i,N)cin >> A[i]; ll sum = 0, mi = 1e18, mii = 1e18; _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); _for(i,N-K+1)mi = min(mi, (ll)S[i+K] - S[i]); _for(i,N-K+1)mi = min(mi, (ll)SS[i+K]- SS[i]); cout << sum - mi << endl; } #undef int int main() { #if __MINGW32__ freopen("../Input.txt", "r", stdin); freopen("../Output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); } #include <bits/stdc++.h> using namespace std; typedef long long ll; #define tr(container, it) \ for (auto it = container.begin(); it != container.end(); it++) #define scontains(c, x) ((c).find(x) != (c).end()) //O(log n) #define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n) #define pll pair<ll,ll> #define pii pair<int,int> #define mll map<ll,ll> #define in(x, a, b)((x)>=a && (x)<=b) #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1) #define all(x) (x).begin(),(x).end() //#define len(array) (sizeof(array)/sizeof((array)[0])) #define endl '\n' #define what_is(x) cerr << #x << " is " << x << endl; #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); } #define mod(x, m) ((((x) % (m)) + (m)) % (m)) void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } const double PI = 2 * acos(.0); const int INF = 0x3f3f3f3f; const ll LLINF = 1000000000000000005LL;; const ll MOD = (ll) (1e9) + 7; //const ll MOD = (ll) 998244353 ; const double EPS = 1e-10; int readint() { int x; cin >> x; return x; } template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *) array, (T *) (array + N), val); } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto a : v)os << a << " "; return os; } template<typename T> ostream &operator<<(ostream &os, const set<T> &v) { for (auto a : v)os << a << " "; return os; } ll power_mod(ll x, ll y, ll p) { if (y < 0)return 0; ll res = 1; x = x % p; while (y) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } ll power(ll x, ll y) { if (y < 0)return 0; ll res = 1; while (y) { if (y & 1) res = (res * x); y = y >> 1; x *= x; } return res; } int fac[7777777]; void init(int MX) { fac[0] = 1; for (int i = 1; i <= MX; i++) fac[i] = fac[i - 1] * i % MOD; } // Returns n^(-1) mod p int modInverse(int n, int p) { return power_mod(n, p - 2, p); } int comb_mod(int n, int r, int p) { if (r == 0) return 1; return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } int comb(int a, int b) { int res = 1; rep(i, a + 1, a - b + 1)res *= i, res /= a - i + 1; // rep(i,1,b+1)res /= i; return res; } bool equal(double a, double b) { return std::fabs(a - b) < std::numeric_limits<double>::epsilon(); } struct UnionFind { // par[i]:データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである vector<int> par; // sizes[i]:根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { // 最初は全てのデータiがグループiに存在するものとして初期化 rep(i, 0, n) par[i] = i; } // データxが属する木の根を得る int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す } // 2つのデータx, yが属する木をマージする void unite(int x, int y) { // データの根ノードを得る x = find(x); y = find(y); // 既に同じ木に属しているならマージしない if (x == y) return; // xの木がyの木より大きくなるようにする if (sizes[x] < sizes[y]) swap(x, y); // xがyの親になるように連結する par[y] = x; sizes[x] += sizes[y]; // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい } // 2つのデータx, yが属する木が同じならtrueを返す bool same(int x, int y) { return find(x) == find(y); } // データxが含まれる木の大きさを返す int size(int x) { return sizes[find(x)]; } }; //fastest struct cpmFunctor { inline bool operator()(const pair<int, int> &p1, const pair<int, int> &p2) { return p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second); } }; bool isPrime(int n) { // Corner case if (n <= 1) return false; if (n == 2 || n == 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; // Check from 2 to n-1 for (int i = 5; i * i <= n; i += 6) if (n % i == 0) return false; for (int i = 7; i * i <= n; i += 6) if (n % i == 0) return false; return true; } int lcm(int a, int b) { return a / __gcd(a, b) * b; } //class Graph{ // int V; // vector<int>* adj; // //public: // Graph(int V){ // this->V = V; // adj = new vector<int>[V]; // // } // // void addEdge(int from, int to){ // adj[from].push_back(to); // } // // // bool isCyclicUtil(int v, bool visited[], bool *recStack) // { // if(visited[v] == false) // { // // Mark the current node as visited and part of recursion stack // visited[v] = true; // recStack[v] = true; // // // Recur for all the vertices adjacent to this vertex // for(auto i = adj[v].begin(); i != adj[v].end(); ++i) // { // if ( !visited[*i] && isCyclicUtil(*i, visited, recStack) ) // return true; // else if (recStack[*i]) // return true; // } // // } // recStack[v] = false; // remove the vertex from recursion stack // return false; // } // //// Returns true if the graph contains a cycle, else false. //// This function is a variation of DFS() in https://www.geeksforgeeks.org/archives/18212 // bool isCyclic() // { // // Mark all the vertices as not visited and not part of recursion // // stack // bool *visited = new bool[V]; // bool *recStack = new bool[V]; // for(int i = 0; i < V; i++) // { // visited[i] = false; // recStack[i] = false; // } // // // Call the recursive helper function to detect cycle in different // // DFS trees // for(int i = 0; i < V; i++) // if (isCyclicUtil(i, visited, recStack)) // return true; // // return false; // } // // //}; struct edge { int to; int cost; }; class wGraph { int V; vector<edge> *adj; public: wGraph(int V) { this->V = V; adj = new vector<edge>[V]; } void addEdge(int from, int to, int cost) { adj[from].push_back({to, cost}); } }; #define int ll int N, K; int A[101010]; int S[101010],SS[101010]; void solve(){ cin >> N >> K; _for(i,N)cin >> A[i]; ll sum = 0, mi = 1e18, mii = 1e18; _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); _for(i,N-K+1)mi = min(mi, (ll)S[i+K] - S[i]); _for(i,N-K+1)mi = min(mi, (ll)SS[i+K]- SS[i]); cout << sum - mi << endl; } #undef int int main() { #if __MINGW32__ freopen("../Input.txt", "r", stdin); freopen("../Output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
a.cc: In function 'void solve()': a.cc:290:24: error: no matching function for call to 'max(int, ll&)' 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:290:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:290:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~ a.cc:290:52: error: no matching function for call to 'max(int, ll&)' 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:290:52: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:290:52: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~~ a.cc:290:83: error: no matching function for call to 'min(int, ll&)' 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:290:83: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:290:83: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 290 | _for(i,N)sum += max(0,A[i]),S[i+1] = S[i] + max(0, A[i]),SS[i+1] = SS[i] - min(0,A[i]); | ~~~^~~~~~~~ a.cc: At global scope: a.cc:337:6: error: redefinition of 'void err(std::istream_iterator<std::__cxx11::basic_string<char> >)' 337 | void err(istream_iterator<string> it) {} | ^~~ a.cc:22:6: note: 'void err(std::istream_iterator<std::__cxx11::basic_string<char> >)' previously defined here 22 | void err(istream_iterator<string> it) {} | ^~~ a.cc:340:6: error: redefinition of 'template<class T, class ... Args> void err(std::istream_iterator<std::__cxx11::basic_string<char> >, T, Args ...)' 340 | void err(istream_iterator<string> it, T a, Args... args) { | ^~~ a.cc:25:6: note: 'template<class T, class ... Args> void err(std::istream_iterator<std::__cxx11::basic_string<char> >, T, Args ...)' previously declared here 25 | void err(istream_iterator<string> it, T a, Args... args) { | ^~~ a.cc:345:14: error: redefinition of 'const double PI' 345 | const double PI = 2 * acos(.0); | ^~ a.cc:30:14: note: 'const double PI' previously defined here 30 | const double PI = 2 * acos(.0); | ^~ a.cc:346:11: error: redefinition of 'const int INF' 346 | const int INF = 0x3f3f3f3f; | ^~~ a.cc:31:11: note: 'const int INF' previously defined here 31 | const int INF = 0x3f3f3f3f; | ^~~ a.cc:347:10: error: redefinition of 'const ll LLINF' 347 | const ll LLINF = 1000000000000000005LL;; | ^~~~~ a.cc:32:10: note: 'const ll LLINF' previously defined here 32 | const ll LLINF = 1000000000000000005LL;; | ^~~~~ a.cc:348:10: error: redefinition of 'const ll MOD' 348 | const ll MOD = (ll) (1e9) + 7; | ^~~ a.cc:33:10: note: 'const ll MOD' previously defined here 33 | const ll MOD = (ll) (1e9) + 7; | ^~~ a.cc:350:14: error: redefinition of 'const double EPS' 350 | const double EPS = 1e-10; | ^~~ a.cc:35:14: note: 'const double EPS' previously defined here 35 | const double EPS = 1e-10; | ^~~ a.cc:352:5: error: redefinition of 'int readint()' 352 | int readint() { | ^~~~~~~ a.cc:37:5: note: 'int readint()' previously defined here 37 | int readint() { | ^~~~~~~ a.cc:359:6: error: redefinition of 'template<class A, long unsigned int N, class T> void Fill(A (&)[N], const T&)' 359 | void Fill(A (&array)[N], const T &val) { | ^~~~ a.cc:44:6: note: 'template<class A, long unsigned int N, class T> void Fill(A (&)[N], const T&)' previously declared here 44 | void Fill(A (&array)[N], const T &val) { | ^~~~ a.cc:364:10: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)' 364 | ostream &operator<<(ostream &os, const vector<T> &v) { | ^~~~~~~~ a.cc:49:10: note: 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)' previously declared here 49 | ostream &operator<<(ostream &os, const vector<T> &v) { | ^~~~~~~~ a.cc:370:10: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, const std::set<T>&)' 370 | ostream &operator<<(ostream &os, const set<T> &v) { | ^~~~~~~~ a.cc:55:10: note: 'template<class T> std::ostream& operator<<(std::ostream&, const std::set<T>&)' previously declared here 55 | ostream &operator<<(ostream &os, const set<T> &v) { | ^~~~~~~~ a.cc:375:4: error: redefinition of 'll power_mod(ll, ll, ll)' 375 | ll power_mod(ll x, ll y, ll p) { | ^~~~~~~~~ a.cc:60:4: note: 'll power_mod(ll, ll, ll)' previously defined here 60 | ll power_mod(ll x, ll y, ll p) { | ^~~~~~~~~ a.cc:390:4: error: redefinition of 'll power(ll, ll)' 390 | ll power(ll x, ll y) { | ^~~~~ a.cc:75:4: note: 'll power(ll, ll)' previously defined here 75 | ll power(ll x, ll y) { |
s067448880
p03839
C++
//Relive your past life. //Face your demons. //The past is never dead,it is not even past. //The memories are not only the key to the past but...also to the future. //coded in Rusty Lake #include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define ll long long #define pb push_back #define mp make_pair #define orz 1000000007ll using namespace std; int n,k,a[100005]; ll l[100005],r[100005],s[100005],ans; int main(){ scanf("%d%d",&n,&k); for(int i=1;i<=n;++i)scanf("%d",a+i),s[i]=s[i-1]+a[i]; for(int i=1;i<=n;++i)l[i]=l[i-1]+max(a[i],0); for(int i=n;i;--i)r[i]=r[i+1]+max(a[i],0); for(int i=k;i<=n;++i)ans=max(ans,max(s[i]-s[i-k],0)+l[i-k]+r[i+1]); printf("%lld\n",ans); //system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:73:41: error: no matching function for call to 'max(long long int, int)' 73 | for(int i=k;i<=n;++i)ans=max(ans,max(s[i]-s[i-k],0)+l[i-k]+r[i+1]); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from a.cc:6: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:73:41: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 73 | for(int i=k;i<=n;++i)ans=max(ans,max(s[i]-s[i-k],0)+l[i-k]+r[i+1]); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:9: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:73:41: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 73 | for(int i=k;i<=n;++i)ans=max(ans,max(s[i]-s[i-k],0)+l[i-k]+r[i+1]); | ~~~^~~~~~~~~~~~~~~
s662784928
p03839
C++
#include <bits/stdc++.h> using namespace std; #define dump(x) cout << (x) << '\n'; typedef int64_t Int; Int mod = 1e9+7; Int INF = 1e9+18; int main() { ios::sync_with_stdio(false); Int n, k; cin >> n >> k; vector<Int> a(n); vector<Int> b(n + 1, 0); vector<Int> c(n + 1, 0); Int sum = 0; for (Int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) sum += a[i]; } for (Int i = 0; i < n; i++) b[i + 1] += b[i] + a[i]; for (Int i = 0; i < n; i++) { if (a[i] > 0) c[i + 1] += a[i]; c[i + 1] += c[i]; } Int res = 0; for (Int i = 0; i <= n - k; i++) { Int ma = max(0LL, b[i + k] - b[i]); res = max(res, ma + sum - (c[i + k] - c[i])); } dump(res); return 0; }
a.cc: In function 'int main()': a.cc:27:21: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)' 27 | Int ma = max(0LL, b[i + k] - b[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:27:21: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'}) 27 | Int ma = max(0LL, b[i + k] - b[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:27:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | Int ma = max(0LL, b[i + k] - b[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s095485747
p03839
C++
#include <bits/stdc++.h> #define INF 10000000000000007 using namespace std; int main() { int n, k; cin >> n >> k; long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; long acc[n + 1]; acc[0] = 0; for (int i = 1; i <= n; i++) { acc[i] = acc[i - 1] + a[i - 1]; } long max_acc = 0; int index = 0; for (int i = k; i <= n; i++) { if (max_acc < acc[i] - acc[i - k]) { max_acc = acc[i] - acc[i - k]; index = i - k; } } long ans = 0; if (max_acc == 0) { long min_acc = INF; acc[0] = 0; for (int i = 1; i <= n; i++) { acc[i] = acc[i - 1] + max(0, a[i - 1]); } for (int i = k; i <= n; i++) { if (min_acc > acc[i] - acc[i - k]) { min_acc = acc[i] - acc[i - k]; index = i - k; } } } else { ans = max_acc; } for (int i = 0; i < k; i++) { a[i + index] = 0; } for (int i = 0; i < n; i++) { if (a[i] > 0) ans += a[i]; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:38: error: no matching function for call to 'max(int, long int&)' 31 | acc[i] = acc[i - 1] + max(0, a[i - 1]); | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:38: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long int') 31 | acc[i] = acc[i - 1] + max(0, a[i - 1]); | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:38: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 31 | acc[i] = acc[i - 1] + max(0, a[i - 1]); | ~~~^~~~~~~~~~~~~
s019234788
p03839
C++
#include <iostream> #include <vector> #include <algorithm> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + std::max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += std::max((sm[i+k] - sm[i]), 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); ans = std::max(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:6:15: error: 'int_fast64_t' does not name a type 6 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:7:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 7 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:7:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 7 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:7:31: error: template argument 1 is invalid 7 | using PAIR = pair<int64, int64>; | ^ a.cc:7:31: error: template argument 2 is invalid a.cc:9:11: error: 'int64' does not name a type; did you mean 'int64_t'? 9 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:14:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 14 | #define int int64 | ^~~~~ a.cc:16:24: note: in definition of macro 'VAR' 16 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:41:13: note: in expansion of macro 'int' 41 | VAR(int,n,k); | ^~~ a.cc:41:17: error: 'n' was not declared in this scope 41 | VAR(int,n,k); | ^ a.cc:16:56: note: in definition of macro 'VAR' 16 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:41:19: error: 'k' was not declared in this scope 41 | VAR(int,n,k); | ^ a.cc:16:56: note: in definition of macro 'VAR' 16 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:19:36: error: template argument 2 is invalid 19 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:42:9: note: in expansion of macro 'VEC' 42 | VEC(int,a,n); | ^~~ a.cc:42:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 42 | VEC(int,a,n); | ^ a.cc:19:56: note: in definition of macro 'VEC' 19 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:42:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 42 | VEC(int,a,n); | ^ a.cc:19:56: note: in definition of macro 'VEC' 19 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:44:19: error: template argument 2 is invalid 44 | vector<int> sm(n+1,0); | ^ a.cc:44:29: error: expression list treated as compound expression in initializer [-fpermissive] 44 | vector<int> sm(n+1,0); | ^ a.cc:45:19: error: template argument 2 is invalid 45 | vector<int> po_sm(n+1,0); | ^ a.cc:45:32: error: expression list treated as compound expression in initializer [-fpermissive] 45 | vector<int> po_sm(n+1,0); | ^ a.cc:46:13: error: expected ';' before 'i' 46 | REP(i,n){ | ^ a.cc:36:27: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:46:13: error: 'i' was not declared in this scope 46 | REP(i,n){ | ^ a.cc:36:31: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:51:13: error: expected ';' before 'ans' 51 | int ans = 0; | ^~~ a.cc:52:13: error: expected ';' before 'i' 52 | REP(i,n){ | ^ a.cc:36:27: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:52:13: error: 'i' was not declared in this scope 52 | REP(i,n){ | ^ a.cc:36:31: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:53:21: error: expected ';' before 'tmp' 53 | int tmp = 0; | ^~~ a.cc:55:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 55 | tmp += std::max((sm[i+k] - sm[i]), 0LL); | ^~~ | tm a.cc:61:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 61 | ans = std::max(ans,tmp); | ^~~ | abs a.cc:63:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 63 | OUT(ans)BR; | ^~~ a.cc:24:26: note: in definition of macro 'OUT' 24 | #define OUT(dist) cout<<(dist); | ^~~~
s933403866
p03839
C++
#include <iostream> #include <vector> #include <algorithm> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += max(sm[i+k] - sm[i], 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); chmax(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:6:15: error: 'int_fast64_t' does not name a type 6 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:7:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 7 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:7:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 7 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:7:31: error: template argument 1 is invalid 7 | using PAIR = pair<int64, int64>; | ^ a.cc:7:31: error: template argument 2 is invalid a.cc:9:11: error: 'int64' does not name a type; did you mean 'int64_t'? 9 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:14:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 14 | #define int int64 | ^~~~~ a.cc:16:24: note: in definition of macro 'VAR' 16 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:41:13: note: in expansion of macro 'int' 41 | VAR(int,n,k); | ^~~ a.cc:41:17: error: 'n' was not declared in this scope 41 | VAR(int,n,k); | ^ a.cc:16:56: note: in definition of macro 'VAR' 16 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:41:19: error: 'k' was not declared in this scope 41 | VAR(int,n,k); | ^ a.cc:16:56: note: in definition of macro 'VAR' 16 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:19:36: error: template argument 2 is invalid 19 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:42:9: note: in expansion of macro 'VEC' 42 | VEC(int,a,n); | ^~~ a.cc:42:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 42 | VEC(int,a,n); | ^ a.cc:19:56: note: in definition of macro 'VEC' 19 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:42:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 42 | VEC(int,a,n); | ^ a.cc:19:56: note: in definition of macro 'VEC' 19 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:44:19: error: template argument 2 is invalid 44 | vector<int> sm(n+1,0); | ^ a.cc:44:29: error: expression list treated as compound expression in initializer [-fpermissive] 44 | vector<int> sm(n+1,0); | ^ a.cc:45:19: error: template argument 2 is invalid 45 | vector<int> po_sm(n+1,0); | ^ a.cc:45:32: error: expression list treated as compound expression in initializer [-fpermissive] 45 | vector<int> po_sm(n+1,0); | ^ a.cc:46:13: error: expected ';' before 'i' 46 | REP(i,n){ | ^ a.cc:36:27: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:46:13: error: 'i' was not declared in this scope 46 | REP(i,n){ | ^ a.cc:36:31: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:51:13: error: expected ';' before 'ans' 51 | int ans = 0; | ^~~ a.cc:52:13: error: expected ';' before 'i' 52 | REP(i,n){ | ^ a.cc:36:27: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:52:13: error: 'i' was not declared in this scope 52 | REP(i,n){ | ^ a.cc:36:31: note: in definition of macro 'REP' 36 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:53:21: error: expected ';' before 'tmp' 53 | int tmp = 0; | ^~~ a.cc:55:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 55 | tmp += max(sm[i+k] - sm[i], 0LL); | ^~~ | tm a.cc:61:23: error: 'ans' was not declared in this scope; did you mean 'abs'? 61 | chmax(ans,tmp); | ^~~ | abs a.cc:63:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 63 | OUT(ans)BR; | ^~~ a.cc:24:26: note: in definition of macro 'OUT' 24 | #define OUT(dist) cout<<(dist); | ^~~~
s629252545
p03839
C++
#include <iostream> #include <vector> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += max(sm[i+k] - sm[i], 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); chmax(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:5:15: error: 'int_fast64_t' does not name a type 5 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:6:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:31: error: template argument 1 is invalid 6 | using PAIR = pair<int64, int64>; | ^ a.cc:6:31: error: template argument 2 is invalid a.cc:8:11: error: 'int64' does not name a type; did you mean 'int64_t'? 8 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:13:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 13 | #define int int64 | ^~~~~ a.cc:15:24: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:40:13: note: in expansion of macro 'int' 40 | VAR(int,n,k); | ^~~ a.cc:40:17: error: 'n' was not declared in this scope 40 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:40:19: error: 'k' was not declared in this scope 40 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:18:36: error: template argument 2 is invalid 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:41:9: note: in expansion of macro 'VEC' 41 | VEC(int,a,n); | ^~~ a.cc:41:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 41 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:41:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 41 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:43:19: error: template argument 2 is invalid 43 | vector<int> sm(n+1,0); | ^ a.cc:43:29: error: expression list treated as compound expression in initializer [-fpermissive] 43 | vector<int> sm(n+1,0); | ^ a.cc:44:19: error: template argument 2 is invalid 44 | vector<int> po_sm(n+1,0); | ^ a.cc:44:32: error: expression list treated as compound expression in initializer [-fpermissive] 44 | vector<int> po_sm(n+1,0); | ^ a.cc:45:13: error: expected ';' before 'i' 45 | REP(i,n){ | ^ a.cc:35:27: note: in definition of macro 'REP' 35 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:45:13: error: 'i' was not declared in this scope 45 | REP(i,n){ | ^ a.cc:35:31: note: in definition of macro 'REP' 35 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:50:13: error: expected ';' before 'ans' 50 | int ans = 0; | ^~~ a.cc:51:13: error: expected ';' before 'i' 51 | REP(i,n){ | ^ a.cc:35:27: note: in definition of macro 'REP' 35 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:51:13: error: 'i' was not declared in this scope 51 | REP(i,n){ | ^ a.cc:35:31: note: in definition of macro 'REP' 35 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:52:21: error: expected ';' before 'tmp' 52 | int tmp = 0; | ^~~ a.cc:54:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 54 | tmp += max(sm[i+k] - sm[i], 0LL); | ^~~ | tm a.cc:60:23: error: 'ans' was not declared in this scope; did you mean 'abs'? 60 | chmax(ans,tmp); | ^~~ | abs a.cc:62:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 62 | OUT(ans)BR; | ^~~ a.cc:23:26: note: in definition of macro 'OUT' 23 | #define OUT(dist) cout<<(dist); | ^~~~
s998889049
p03839
C++
#include <iostream> #include <vector> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += max(sm[i+k] - sm[i], 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); ans = max(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:5:15: error: 'int_fast64_t' does not name a type 5 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:6:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:31: error: template argument 1 is invalid 6 | using PAIR = pair<int64, int64>; | ^ a.cc:6:31: error: template argument 2 is invalid a.cc:8:11: error: 'int64' does not name a type; did you mean 'int64_t'? 8 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:13:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 13 | #define int int64 | ^~~~~ a.cc:15:24: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:38:13: note: in expansion of macro 'int' 38 | VAR(int,n,k); | ^~~ a.cc:38:17: error: 'n' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:38:19: error: 'k' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:18:36: error: template argument 2 is invalid 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:39:9: note: in expansion of macro 'VEC' 39 | VEC(int,a,n); | ^~~ a.cc:39:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:39:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:41:19: error: template argument 2 is invalid 41 | vector<int> sm(n+1,0); | ^ a.cc:41:29: error: expression list treated as compound expression in initializer [-fpermissive] 41 | vector<int> sm(n+1,0); | ^ a.cc:42:19: error: template argument 2 is invalid 42 | vector<int> po_sm(n+1,0); | ^ a.cc:42:32: error: expression list treated as compound expression in initializer [-fpermissive] 42 | vector<int> po_sm(n+1,0); | ^ a.cc:43:13: error: expected ';' before 'i' 43 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:43:13: error: 'i' was not declared in this scope 43 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:48:13: error: expected ';' before 'ans' 48 | int ans = 0; | ^~~ a.cc:49:13: error: expected ';' before 'i' 49 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:49:13: error: 'i' was not declared in this scope 49 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:50:21: error: expected ';' before 'tmp' 50 | int tmp = 0; | ^~~ a.cc:52:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 52 | tmp += max(sm[i+k] - sm[i], 0LL); | ^~~ | tm a.cc:58:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 58 | ans = max(ans,tmp); | ^~~ | abs a.cc:60:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 60 | OUT(ans)BR; | ^~~ a.cc:21:26: note: in definition of macro 'OUT' 21 | #define OUT(dist) cout<<(dist); | ^~~~
s928485527
p03839
C++
#include <iostream> #include <vector> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += max(sm[i+k] - sm[i], 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); ans = max(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:5:15: error: 'int_fast64_t' does not name a type 5 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:6:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:31: error: template argument 1 is invalid 6 | using PAIR = pair<int64, int64>; | ^ a.cc:6:31: error: template argument 2 is invalid a.cc:8:11: error: 'int64' does not name a type; did you mean 'int64_t'? 8 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:13:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 13 | #define int int64 | ^~~~~ a.cc:15:24: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:38:13: note: in expansion of macro 'int' 38 | VAR(int,n,k); | ^~~ a.cc:38:17: error: 'n' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:38:19: error: 'k' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:18:36: error: template argument 2 is invalid 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:39:9: note: in expansion of macro 'VEC' 39 | VEC(int,a,n); | ^~~ a.cc:39:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:39:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:41:19: error: template argument 2 is invalid 41 | vector<int> sm(n+1,0); | ^ a.cc:41:29: error: expression list treated as compound expression in initializer [-fpermissive] 41 | vector<int> sm(n+1,0); | ^ a.cc:42:19: error: template argument 2 is invalid 42 | vector<int> po_sm(n+1,0); | ^ a.cc:42:32: error: expression list treated as compound expression in initializer [-fpermissive] 42 | vector<int> po_sm(n+1,0); | ^ a.cc:43:13: error: expected ';' before 'i' 43 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:43:13: error: 'i' was not declared in this scope 43 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:48:13: error: expected ';' before 'ans' 48 | int ans = 0; | ^~~ a.cc:49:13: error: expected ';' before 'i' 49 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:49:13: error: 'i' was not declared in this scope 49 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:50:21: error: expected ';' before 'tmp' 50 | int tmp = 0; | ^~~ a.cc:52:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 52 | tmp += max(sm[i+k] - sm[i], 0LL); | ^~~ | tm a.cc:58:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 58 | ans = max(ans,tmp); | ^~~ | abs a.cc:60:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 60 | OUT(ans)BR; | ^~~ a.cc:21:26: note: in definition of macro 'OUT' 21 | #define OUT(dist) cout<<(dist); | ^~~~
s208280169
p03839
C++
#include <iostream> #include <vector> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += max(sm[i+k] - sm[i], 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); ans = max(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:5:15: error: 'int_fast64_t' does not name a type 5 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:6:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:31: error: template argument 1 is invalid 6 | using PAIR = pair<int64, int64>; | ^ a.cc:6:31: error: template argument 2 is invalid a.cc:8:11: error: 'int64' does not name a type; did you mean 'int64_t'? 8 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:13:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 13 | #define int int64 | ^~~~~ a.cc:15:24: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:38:13: note: in expansion of macro 'int' 38 | VAR(int,n,k); | ^~~ a.cc:38:17: error: 'n' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:38:19: error: 'k' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:18:36: error: template argument 2 is invalid 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:39:9: note: in expansion of macro 'VEC' 39 | VEC(int,a,n); | ^~~ a.cc:39:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:39:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:41:19: error: template argument 2 is invalid 41 | vector<int> sm(n+1,0); | ^ a.cc:41:29: error: expression list treated as compound expression in initializer [-fpermissive] 41 | vector<int> sm(n+1,0); | ^ a.cc:42:19: error: template argument 2 is invalid 42 | vector<int> po_sm(n+1,0); | ^ a.cc:42:32: error: expression list treated as compound expression in initializer [-fpermissive] 42 | vector<int> po_sm(n+1,0); | ^ a.cc:43:13: error: expected ';' before 'i' 43 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:43:13: error: 'i' was not declared in this scope 43 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:48:13: error: expected ';' before 'ans' 48 | int ans = 0; | ^~~ a.cc:49:13: error: expected ';' before 'i' 49 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:49:13: error: 'i' was not declared in this scope 49 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:50:21: error: expected ';' before 'tmp' 50 | int tmp = 0; | ^~~ a.cc:52:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 52 | tmp += max(sm[i+k] - sm[i], 0LL); | ^~~ | tm a.cc:58:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 58 | ans = max(ans,tmp); | ^~~ | abs a.cc:60:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 60 | OUT(ans)BR; | ^~~ a.cc:21:26: note: in definition of macro 'OUT' 21 | #define OUT(dist) cout<<(dist); | ^~~~
s553189065
p03839
C++
#include <iostream> #include <vector> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int64, int64>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 3e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0); #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;} template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);} #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; // out #define OUT(dist) cout<<(dist); #define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist); #define SP cout<<" "; #define BR cout<<endl; #define zero(n) cout<<setfill('0')<<right<<setw(n) #define debug(x) cerr<<#x<<":"<< (x);BR; // utility #define ALL(a) (a).begin(), (a).end() #define EACH(i, a) for(auto &&i:(a)) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i) #define REP(i, n) for(int i=0;i<(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) signed main() { INIT; VAR(int,n,k); VEC(int,a,n); vector<int> sm(n+1,0); vector<int> po_sm(n+1,0); REP(i,n){ sm[i+1] = sm[i] + a[i]; po_sm[i+1] = po_sm[i] + max(0LL, a[i]); } int ans = 0; REP(i,n){ int tmp = 0; if (i+k>n) break; tmp += max(sm[i+k] - sm[i], 0LL); debug(tmp); tmp += po_sm[i]; tmp += po_sm[n] - po_sm[i+k]; debug(i); debug(tmp); ans = max(ans,tmp); } OUT(ans)BR; return 0; }
a.cc:5:15: error: 'int_fast64_t' does not name a type 5 | using int64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:6:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:26: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 6 | using PAIR = pair<int64, int64>; | ^~~~~ | int64_t a.cc:6:31: error: template argument 1 is invalid 6 | using PAIR = pair<int64, int64>; | ^ a.cc:6:31: error: template argument 2 is invalid a.cc:8:11: error: 'int64' does not name a type; did you mean 'int64_t'? 8 | constexpr int64 LINF = 1LL << 60; | ^~~~~ | int64_t a.cc: In function 'int main()': a.cc:13:13: error: 'int64' was not declared in this scope; did you mean 'int64_t'? 13 | #define int int64 | ^~~~~ a.cc:15:24: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~ a.cc:38:13: note: in expansion of macro 'int' 38 | VAR(int,n,k); | ^~~ a.cc:38:17: error: 'n' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:38:19: error: 'k' was not declared in this scope 38 | VAR(int,n,k); | ^ a.cc:15:56: note: in definition of macro 'VAR' 15 | #define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); | ^~~~~~~~~~~ a.cc:18:36: error: template argument 2 is invalid 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ a.cc:39:9: note: in expansion of macro 'VEC' 39 | VEC(int,a,n); | ^~~ a.cc:39:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:39:17: error: 'end' was not declared in this scope; did you mean 'std::end'? 39 | VEC(int,a,n); | ^ a.cc:18:56: note: in definition of macro 'VEC' 18 | #define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i; | ^ /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc:41:19: error: template argument 2 is invalid 41 | vector<int> sm(n+1,0); | ^ a.cc:41:29: error: expression list treated as compound expression in initializer [-fpermissive] 41 | vector<int> sm(n+1,0); | ^ a.cc:42:19: error: template argument 2 is invalid 42 | vector<int> po_sm(n+1,0); | ^ a.cc:42:32: error: expression list treated as compound expression in initializer [-fpermissive] 42 | vector<int> po_sm(n+1,0); | ^ a.cc:43:13: error: expected ';' before 'i' 43 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:43:13: error: 'i' was not declared in this scope 43 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:48:13: error: expected ';' before 'ans' 48 | int ans = 0; | ^~~ a.cc:49:13: error: expected ';' before 'i' 49 | REP(i,n){ | ^ a.cc:33:27: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:49:13: error: 'i' was not declared in this scope 49 | REP(i,n){ | ^ a.cc:33:31: note: in definition of macro 'REP' 33 | #define REP(i, n) for(int i=0;i<(n);++i) | ^ a.cc:50:21: error: expected ';' before 'tmp' 50 | int tmp = 0; | ^~~ a.cc:52:17: error: 'tmp' was not declared in this scope; did you mean 'tm'? 52 | tmp += max(sm[i+k] - sm[i], 0LL); | ^~~ | tm a.cc:58:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 58 | ans = max(ans,tmp); | ^~~ | abs a.cc:60:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 60 | OUT(ans)BR; | ^~~ a.cc:21:26: note: in definition of macro 'OUT' 21 | #define OUT(dist) cout<<(dist); | ^~~~
s114462454
p03839
C++
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define rng(a) a.begin(),a.end() #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define limit(x,l,r) max(l,min(x,r)) #define lims(x,l,r) (x = max(l,min(x,r))) #define isin(x,l,r) ((l) <= (x) && (x) < (r)) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)),x.end()) #define snuke srand((unsigned)clock()+(unsigned)time(NULL)); #define show(x) cout<<#x<<" = "<<x<<endl; #define PQ(T) priority_queue<T,v(T),greater<T> > #define bn(x) ((1<<x)-1) #define dup(x,y) (((x)+(y)-1)/(y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; inline int in() { int x; scanf("%d",&x); return x;} template<typename T>inline istream& operator>>(istream&i,v(T)&v) {rep(j,sz(v))i>>v[j];return i;} template<typename T>string join(const v(T)&v) {stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);} template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v) {if(sz(v))o<<join(v);return o;} template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v) {return i>>v.fi>>v.se;} template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v) {return o<<v.fi<<","<<v.se;} template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;} const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} const int MX = 200005; #define RET(ans) {cout<<ans<<endl;return 0;} // 二次元ベクターの基本 /* vector<vector<int>> dp; // 宣言 dp.resize(n); // 1次元めの要素数決定 dp[i].push_back(int); // プッシュバック rep(i,n){ sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート } */ // 整数スキャン(複数) /* int x,y,z; scanf("%d%d%d",&x,&y,&z); // n個の整数のスキャン /* ll a[n] = {}; rep(i,n){ scanf("%lld",&a[i]); } */ // 文字列スキャン /* string s; cin >> s; */ // n個の文字列スキャン /* vector<string> slist; rep(i,n){ string s; cin >> s; slist.push_back(s); } */ int main() { int n,k; scanf("%d%d",&n,&k); ll a[n] = {}; ll ans = 0; rep(i,n){ scanf("%lld",&a[i]); if(a[i]>0){ ans += a[i]; } } ll b[n][2]; rep(i,n){ b[i][0]=0; b[i][1]=0; } rep(i,k){ if(a[i]>0){ b[0][0] += a[i]; }else{ b[0][1] += -a[i]; } } srep(i,1,n+1-k){ b[i][0] = b[i-1][0]; b[i][1] = b[i-1][1]; if(a[i-1]>0){ b[i][0] -= a[i-1] }else{ b[i][1] -= -a[i-1]; } if(a[k-1+i]>0){ b[i][0] += a[k-1+i]; }else{ b[i][1] += -a[k-1+i]; } } ll mi = b[0][0]; rep(i,n+1-k){ mi = min(mi,b[i][0]); mi = min(mi,b[i][1]); } cout << ans - mi << endl; return 0; }
a.cc: In function 'int main()': a.cc:121:30: error: expected ';' before '}' token 121 | b[i][0] -= a[i-1] | ^ | ; 122 | }else{ | ~
s355660457
p03839
C++
#include <iostream> #include <algorithm> #include <cmath> #include <limits> #include <vector> #include <cstdio> #include <bits/stdc++.h> #include <set> #include <map> #include <stdio.h> #include <stack> #include <queue> #include <deque> #include <numeric> #include <bits/stdc++.h> #include <utility> #include <iomanip> #define ALL(obj) (obj).begin(), (obj).end() #define FOR(i,a,b) for(int i = (a); i < (b); i++) #define RFOR(i,a,b) for(int i = (a); (b) <= i; i--) #define REP(i,n) for(int i = 0; i < (n); i++) #define RREP(i,n) for(int i = n; n <= i; i--) #define ABS(a) ((a < 0) ? ((-1)*(a)) : (a)) #define elif else if #define MOD 1000000007 #define INF (1<<29) using namespace std; #define ld long double #define ll long long map <int ,int> mpa,mpb; typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P>> pque; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int N,K; cin >> N >> K; ll t[100100]={0}; ll s[100100]={0}; ll a; t[0]=0; s[0]=0; for(int i=1;i<=N;i++){ cin >> a; t[i]=t[i-1]+a; s[i]=s[i-1]+max(a,0); } ll ans=0; for(int i=0;i<=N-K;i++){ ans=max(ans,s[N]-s[i+K]+s[i]); ans=max(ans,s[N]-s[i+K]+s[i]+t[i+K]-t[i]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:51:20: error: no matching function for call to 'max(long long int&, int)' 51 | s[i]=s[i-1]+max(a,0); | ~~~^~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:51:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 51 | s[i]=s[i-1]+max(a,0); | ~~~^~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:51:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 51 | s[i]=s[i-1]+max(a,0); | ~~~^~~~~
s844108467
p03839
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define z (ll) int main(){ ll n,k,d=0,e=0,r=0,s=0,t=0,u=0; cin>>n>>k; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; if(i<k){ s+=a[i]; r+=max(z 0,a[i]); t=s; u=r; }else{ s-=a[i-k]; s+=a[i]; r-=max(z 0,a[i-k]); r+=max(z 0,a[i]); if(t<s){ t=s; d=i-k+1; } if(u>r){ u=r; e=i-k+1; } } if(t<=0){ u=0; for(int i=0;i<e;i++) u+=max(z 0,a[i]); for(int i=e+k;i<n;i++) u+=max(z 0,a[i]); cout<<u; return 0; } for(int i=0;i<d;i++) t+=max(z 0,a[i]); for(int i=d+k;i<n;i++) t+=max(z 0,a[i]); cout<<t; }
a.cc: In function 'int main()': a.cc:40:2: error: expected '}' at end of input 40 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s927703491
p03839
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define z (ll) int main(){ ll n,k,d=0,e=0,r=0,s=0,t=0,u=0; cin>>n>>k; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; if(i<k){ s+=a[i]; r+=max(z 0,a[i]); t=s; u=r; }else{ s-=a[i-k]; s+=a[i]; r-=max(z0,a[i-k]); r+=max(z0,a[i]); if(t<s){ t=s; d=i-k+1; } if(u>r){ u=r; e=i-k+1; } } if(t<=0){ u=0; for(int i=0;i<e;i++) u+=max(z0,a[i]); for(int i=e+k;i<n;i++) u+=max(z0,a[i]); cout<<u; return 0; } for(int i=0;i<d;i++) t+=max(z0,a[i]); for(int i=d+k;i<n;i++) t+=max(z0,a[i]); cout<<t; }
a.cc: In function 'int main()': a.cc:19:14: error: 'z0' was not declared in this scope; did you mean 'y0'? 19 | r-=max(z0,a[i-k]); | ^~ | y0 a.cc:32:33: error: 'z0' was not declared in this scope; did you mean 'y0'? 32 | for(int i=0;i<e;i++) u+=max(z0,a[i]); | ^~ | y0 a.cc:33:35: error: 'z0' was not declared in this scope; did you mean 'y0'? 33 | for(int i=e+k;i<n;i++) u+=max(z0,a[i]); | ^~ | y0 a.cc:37:31: error: 'z0' was not declared in this scope; did you mean 'y0'? 37 | for(int i=0;i<d;i++) t+=max(z0,a[i]); | ^~ | y0 a.cc:38:33: error: 'z0' was not declared in this scope; did you mean 'y0'? 38 | for(int i=d+k;i<n;i++) t+=max(z0,a[i]); | ^~ | y0 a.cc:40:2: error: expected '}' at end of input 40 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s404311642
p03839
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define z (ll) int main(){ ll n,k,d=0,e=0,r=0,s=0,t=0,u=0; cin>>n>>k; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; if(i<k){ s+=a[i]; r+=max(z0,a[i]); t=s; u=r; }else{ s-=a[i-k]; s+=a[i]; r-=max(z0,a[i-k]); r+=max(z0,a[i]); if(t<s){ t=s; d=i-k+1; } if(u>r){ u=r; e=i-k+1; } } if(t<=0){ u=0; for(int i=0;i<e;i++) u+=max(z0,a[i]); for(int i=e+k;i<n;i++) u+=max(z0,a[i]); cout<<u; return 0; } for(int i=0;i<d;i++) t+=max(z0,a[i]); for(int i=d+k;i<n;i++) t+=max(z0,a[i]); cout<<t; }
a.cc: In function 'int main()': a.cc:13:14: error: 'z0' was not declared in this scope; did you mean 'y0'? 13 | r+=max(z0,a[i]); | ^~ | y0 a.cc:19:14: error: 'z0' was not declared in this scope; did you mean 'y0'? 19 | r-=max(z0,a[i-k]); | ^~ | y0 a.cc:32:33: error: 'z0' was not declared in this scope; did you mean 'y0'? 32 | for(int i=0;i<e;i++) u+=max(z0,a[i]); | ^~ | y0 a.cc:33:35: error: 'z0' was not declared in this scope; did you mean 'y0'? 33 | for(int i=e+k;i<n;i++) u+=max(z0,a[i]); | ^~ | y0 a.cc:37:31: error: 'z0' was not declared in this scope; did you mean 'y0'? 37 | for(int i=0;i<d;i++) t+=max(z0,a[i]); | ^~ | y0 a.cc:38:33: error: 'z0' was not declared in this scope; did you mean 'y0'? 38 | for(int i=d+k;i<n;i++) t+=max(z0,a[i]); | ^~ | y0 a.cc:40:2: error: expected '}' at end of input 40 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s210892932
p03839
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define 0 (ll)0 int main(){ ll n,k,d=0,e=0,r=0,s=0,t=0,u=0; cin>>n>>k; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; if(i<k){ s+=a[i]; r+=max(0,a[i]); t=s; u=r; }else{ s-=a[i-k]; s+=a[i]; r-=max(0,a[i-k]); r+=max(0,a[i]); if(t<s){ t=s; d=i-k+1; } if(u>r){ u=r; e=i-k+1; } } if(t<=0){ u=0; for(int i=0;i<e;i++) u+=max(0,a[i]); for(int i=e+k;i<n;i++) u+=max(0,a[i]); cout<<u; return 0; } for(int i=0;i<d;i++) t+=max(0,a[i]); for(int i=d+k;i<n;i++) t+=max(0,a[i]); cout<<t; }
a.cc:4:9: error: macro names must be identifiers 4 | #define 0 (ll)0 | ^ a.cc: In function 'int main()': a.cc:13:13: error: no matching function for call to 'max(int, long long int&)' 13 | r+=max(0,a[i]); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:13:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 13 | r+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:13:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 13 | r+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:19:13: error: no matching function for call to 'max(int, long long int&)' 19 | r-=max(0,a[i-k]); | ~~~^~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:19:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 19 | r-=max(0,a[i-k]); | ~~~^~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:19:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 19 | r-=max(0,a[i-k]); | ~~~^~~~~~~~~~ a.cc:20:13: error: no matching function for call to 'max(int, long long int&)' 20 | r+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:20:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 20 | r+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:20:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 20 | r+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:32:32: error: no matching function for call to 'max(int, long long int&)' 32 | for(int i=0;i<e;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:32: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 32 | for(int i=0;i<e;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 32 | for(int i=0;i<e;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:33:34: error: no matching function for call to 'max(int, long long int&)' 33 | for(int i=e+k;i<n;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:33:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 33 | for(int i=e+k;i<n;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:33:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 33 | for(int i=e+k;i<n;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:37:30: error: no matching function for call to 'max(int, long long int&)' 37 | for(int i=0;i<d;i++) t+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:37:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 37 | for(int i=0;i<d;i++) t+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(
s260600206
p03839
C++
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll n,k,d=0,e=0,r=0,s=0,t=0,u=0; cin>>n>>k; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; if(i<k){ s+=a[i]; r+=max(0,a[i]); t=s; u=r; }else{ s-=a[i-k]; s+=a[i]; r-=max(0,a[i-k]); r+=max(0,a[i]); if(t<s){ t=s; d=i-k+1; } if(u>r){ u=r; e=i-k+1; } } if(t<=0){ u=0; for(int i=0;i<e;i++) u+=max(0,a[i]); for(int i=e+k;i<n;i++) u+=max(0,a[i]); cout<<u; return 0; } for(int i=0;i<d;i++) t+=max(0,a[i]); for(int i=d+k;i<n;i++) t+=max(0,a[i]); cout<<t; }
a.cc: In function 'int main()': a.cc:12:13: error: no matching function for call to 'max(int, long long int&)' 12 | r+=max(0,a[i]); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 12 | r+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:12:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 12 | r+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:18:13: error: no matching function for call to 'max(int, long long int&)' 18 | r-=max(0,a[i-k]); | ~~~^~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:18:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 18 | r-=max(0,a[i-k]); | ~~~^~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:18:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 18 | r-=max(0,a[i-k]); | ~~~^~~~~~~~~~ a.cc:19:13: error: no matching function for call to 'max(int, long long int&)' 19 | r+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:19:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 19 | r+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:19:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 19 | r+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:31:32: error: no matching function for call to 'max(int, long long int&)' 31 | for(int i=0;i<e;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:32: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 31 | for(int i=0;i<e;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:32: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 31 | for(int i=0;i<e;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:32:34: error: no matching function for call to 'max(int, long long int&)' 32 | for(int i=e+k;i<n;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 32 | for(int i=e+k;i<n;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 32 | for(int i=e+k;i<n;i++) u+=max(0,a[i]); | ~~~^~~~~~~~ a.cc:36:30: error: no matching function for call to 'max(int, long long int&)' 36 | for(int i=0;i<d;i++) t+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:36:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 36 | for(int i=0;i<d;i++) t+=max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note
s085875384
p03839
C++
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second typedef long long ll; using namespace std; const int MAXN = 1e5 + 5 * 1e2; ll n, k, a[MAXN]; ll pref[MAXN], dp1[MAXN], dp2[MAXN]; int main(){ cin >> n >> k; for(int i=1;i<=n;i++){ cin >> a[i]; pref[i] += pref[i - 1] + a[i]; /**/ dp1[i] += dp1[i - 1]; if(a[i] > 0){ dp1[i] += a[i]; } } for(int i=n;i>=1;i--){ dp2[i] += dp2[i + 1]; if(a[i] > 0){ dp2[i] += a[i]; } } int ans = 0; for(int i=1;i<=n-k+1;i++){ ans = max(ans, dp1[i - 1] + dp2[i + k] + max(0ll, pref[i + k - 1] - pref[i])); } cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:38:14: error: no matching function for call to 'max(int&, ll)' 38 | ans = max(ans, dp1[i - 1] + dp2[i + k] + max(0ll, pref[i + k - 1] - pref[i])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:38:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 38 | ans = max(ans, dp1[i - 1] + dp2[i + k] + max(0ll, pref[i + k - 1] - pref[i])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:38:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 38 | ans = max(ans, dp1[i - 1] + dp2[i + k] + max(0ll, pref[i + k - 1] - pref[i])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s271740134
p03839
C++
#include<iostream> using namespace std; typedef long long ll; #define fr(i,n) for(int i=0;i<n;i++) int main(){ ll n,k,a[100010],s[100010],m[100010],t=0; cin>>n>>k; fr(i,n) cin>>a[i]; fr(i,n){ s[i+1]=s[i]+a[i]; m[i+1]=m[i]+max(a[i],0); } fr(i,n-k+1){ t=max(t,m[i]+m[n]-m[i+k]+max(0,s[i+k]-s[i])); } cout<<t<<endl; }
a.cc: In function 'int main()': a.cc:12:20: error: no matching function for call to 'max(ll&, int)' 12 | m[i+1]=m[i]+max(a[i],0); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 12 | m[i+1]=m[i]+max(a[i],0); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided a.cc:15:33: error: no matching function for call to 'max(int, ll)' 15 | t=max(t,m[i]+m[n]-m[i+k]+max(0,s[i+k]-s[i])); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:15:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 15 | t=max(t,m[i]+m[n]-m[i+k]+max(0,s[i+k]-s[i])); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
s638362306
p03839
C++
/* Author: QAQ-Automaton LANG: C++ PROG: b.cpp Mail: cnyalilk@vip.qq.com */ #include<bits/stdc++.h> #define debug(...) fprintf(stderr,__VA_ARGS__) #define DEBUG printf("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__) #define Debug debug("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__) #define all(x) x.begin(),x.end() #define x first #define y second using namespace std; typedef long long ll; typedef pair<ll,ll> pii; const signed inf=0x3f3f3f3f; const double eps=1e-8; const double pi=acos(-1.0); template<class T>ll chkmin(T &a,T b){return a>b?a=b,1:0;} template<class T>ll chkmax(T &a,T b){return a<b?a=b,1:0;} template<class T>T sqr(T a){return a*a;} template<class T>T mmin(T a,T b){return a<b?a:b;} template<class T>T mmax(T a,T b){return a>b?a:b;} template<class T>T aabs(T a){return a<0?-a:a;} template<class T>ll dcmp(T a,T b){return a>b;} template<ll *a>ll cmp_a(ll x,ll y){return a[x]<a[y];} #define min mmin #define max mmax #define abs aabs namespace io { const ll SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; ll f, qr; // getchar #define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++) // prll the remaining part inline void flush () { fwrite (obuf, 1, oS - obuf, stdout); oS = obuf; } // putchar inline void putc (char x) { *oS ++ = x; if (oS == oT) flush (); } // input a signed lleger inline bool read (signed &x) { for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0; for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f; return 1; } inline bool read (long long &x) { for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0; for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f; return 1; } inline bool read (char &x) { x=gc(); return x!=EOF; } inline bool read(char *x){ while((*x=gc())=='\n' || *x==' '||*x=='\r')if(*x==EOF)return 0; while(!(*x=='\n'||*x==' '||*x=='\r'))*(++x)=gc(); *x=0; return 1; } template<typename A,typename ...B> inline bool read(A &x,B &...y){ return read(x)&&read(y...); } // prll a signed lleger inline bool write (signed x) { if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x; while (x) qu[++ qr] = x % 10 + '0', x /= 10; while (qr) putc (qu[qr --]); return 0; } inline bool write (long long x) { if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x; while (x) qu[++ qr] = x % 10 + '0', x /= 10; while (qr) putc (qu[qr --]); return 0; } inline bool write (char x) { putc(x); return 0; } inline bool write(const char *x){ while(*x){putc(*x);++x;} return 0; } inline bool write(char *x){ while(*x){putc(*x);++x;} return 0; } template<typename A,typename ...B> inline bool write(A x,B ...y){ return write(x)||write(y...); } //no need to call flush at the end manually! struct Flusher_ {~Flusher_(){flush();}}io_flusher_; } using io :: read; using io :: putc; using io :: write; ll a[100005],b[100005]; int main(){ #ifdef QAQAutoMaton freopen("b.in","r",stdin); freopen("b.out","w",stdout); #endif ll n,k,m; read(n,k); m=n-k; for(ll i=1;i<=n;++i)read(a[i]); for(ll i=1;i<=n;++i){ b[i]=(a[i]>0?a[i]:0)+b[i-1]; a[i]+=a[i-1]; } ll ans=0; for(ll i=0;i<=m;++i){ chkmax(ans,max(a[i+k]-a[i],0)+b[i]+b[n]-b[i+k]); } write(ans,'\n'); return 0; }
a.cc: In function 'int main()': a.cc:124:31: error: no matching function for call to 'mmax(ll, int)' 124 | chkmax(ans,max(a[i+k]-a[i],0)+b[i]+b[n]-b[i+k]); | ^ a.cc:24:20: note: candidate: 'template<class T> T mmax(T, T)' 24 | template<class T>T mmax(T a,T b){return a>b?a:b;} | ^~~~ a.cc:24:20: note: template argument deduction/substitution failed: a.cc:124:31: note: deduced conflicting types for parameter 'T' ('long long int' and 'int') 124 | chkmax(ans,max(a[i+k]-a[i],0)+b[i]+b[n]-b[i+k]); | ^
s893825095
p03839
C++
#include <iostream> #include <string> #include <vector> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <map> #include <stack> #include <queue> #include <set> #include <cstring> using namespace std; // ascending order #define vsort(v) sort(v.begin(), v.end()) // descending order #define vsort_r(v) sort(v.begin(), v.end(), greater<int>()) #define vunique(v) unique(v.begin(), v.end()) #define mp make_pair #define ts(x) to_string(x) #define rep(i, a, b) for(int i = (int)a; i < (int)b; i++) #define repm(i, a, b) for(int i = (int)a; i > (int)b; i--) #define bit(a) bitset<8>(a) #define des_priority_queue priority_queue<int, vector<int>, greater<int> > #define all(v) (v).begin(), (v).end() typedef long long ll; typedef pair<int, int> P; const ll INF = 1e18; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; ll a[N + 2], b[N + 2]; a[0] = a[N + 1] = b[0] = b[N + 1] = 0; rep(i, 1, N + 1) { cin >> a[i]; b[i] = max(a[i], 0); } rep(i, 1, N) { a[i + 1] += a[i]; b[i + 1] += b[i]; } ll rsl = 0; for(int i = 0; i + K <= N; i++) { ll tmp = a[i] + b[i + K] - b[i] + a[N] - a[i + K]; rsl = max(rsl, tmp); } cout << rsl << endl; }
a.cc: In function 'int main()': a.cc:41:27: error: no matching function for call to 'max(ll&, int)' 41 | b[i] = max(a[i], 0); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:41:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | b[i] = max(a[i], 0); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:7: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:41:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | b[i] = max(a[i], 0); | ~~~^~~~~~~~~
s025456285
p03839
C++
#include <bits/stdc++.h> using namespace std; #define countof(a) (sizeof(a)/sizeof(*a)) #define vi vector<int> #define vvi vector<vector<int> > #define vpi vector<pi > #define pi pair<int,int> #define mp make_pair #define fi first #define se second #define all(n) n.begin(), n.end() #define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++) #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) #define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--) #define FOR(var, to) UPTO(var, 0, (to)-1) #define DOWN(var, from) DOWNTO(var, (from)-1, 0) #define INIT(var, val) FOR(i,countof(var)) var[i] = val #define INPUT(var) FOR(i,countof(var)) cin >> var[i] #define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]-- #define SORT(v) qsort(v,countof(v),sizeof(*v),int_less) #define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater) #define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b) #define MOD 1000000007 #define INF ((1 << 30)-1) #define LINF ((1LL << 62)-1) typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; struct Comb { vector<vector<s64> > data; Comb(int n) { // O(n^2) data = vector<vector<s64> >(n+1,vector<s64>(n+1,1)); UPTO(i,1,n) { FOR(j,i+1) { if (!j || j == i) data[i][j] = 1; else data[i][j] = data[i-1][j-1] + data[i-1][j]; } } } s64 ncr(int n, int r) { return data[n][r]; } }; static inline int ri() { int a; scanf("%d", &a); return a; } int int_less(const void *a, const void *b) { return (*((const int*)a) - *((const int*)b)); } int int_greater(const void *a, const void *b) { return (*((const int*)b) - *((const int*)a)); } int main() { int n = ri(); int k = ri(); s64 sum[n]; s64 sum_g[n]; int a[n]; FOR(i,n) a[i] = ri(), sum[i] = i ? sum[i-1]+a[i] : a[i], sum_g[i] = i ? sum_g[i-1]+max(0,a[i]) : max(0,a[i]); s64 res = -LINF; FOR(i,n-k+1) { // do s64 r0 = sum[i+k-1]; if (i) r0 -= sum[i-1]; r0 = max(0LL,r0); if (i) r0 += sum_g[i-1]; r0 += sum_g[n-1]; r0 -= sum_g[i+k-1]; res = max(res,r0); } cout << res << endl; return 0; }
a.cc: In constructor 'Comb::Comb(int)': a.cc:47:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 47 | UPTO(i,1,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:48:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 48 | FOR(j,i+1) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:48:13: note: in expansion of macro 'FOR' 48 | FOR(j,i+1) { | ^~~ a.cc: In function 'int main()': a.cc:78:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 78 | FOR(i,n) a[i] = ri(), sum[i] = i ? sum[i-1]+a[i] : a[i], sum_g[i] = i ? sum_g[i-1]+max(0,a[i]) : max(0,a[i]); | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:78:9: note: in expansion of macro 'FOR' 78 | FOR(i,n) a[i] = ri(), sum[i] = i ? sum[i-1]+a[i] : a[i], sum_g[i] = i ? sum_g[i-1]+max(0,a[i]) : max(0,a[i]); | ^~~ a.cc:81:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 81 | FOR(i,n-k+1) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:81:9: note: in expansion of macro 'FOR' 81 | FOR(i,n-k+1) { | ^~~ a.cc:85:25: error: no matching function for call to 'max(long long int, s64&)' 85 | r0 = max(0LL,r0); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:85:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 's64' {aka 'long int'}) 85 | r0 = max(0LL,r0); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:85:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 85 | r0 = max(0LL,r0); | ~~~^~~~~~~~
s114549390
p03839
C++
#include <bits/stdc++.h> using namespace std; #define countof(a) (sizeof(a)/sizeof(*a)) #define vi vector<int> #define vvi vector<vector<int> > #define vpi vector<pi > #define pi pair<int,int> #define mp make_pair #define fi first #define se second #define all(n) n.begin(), n.end() #define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++) #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) #define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--) #define FOR(var, to) UPTO(var, 0, (to)-1) #define DOWN(var, from) DOWNTO(var, (from)-1, 0) #define INIT(var, val) FOR(i,countof(var)) var[i] = val #define INPUT(var) FOR(i,countof(var)) cin >> var[i] #define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]-- #define SORT(v) qsort(v,countof(v),sizeof(*v),int_less) #define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater) #define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b) typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; static const int MOD = 1000000007; static const int INF = ((1<<30)-1); static const s64 LINF = ((1LL << 62)-1); struct Comb { vector<vector<s64> > data; Comb(int n) { // O(n^2) data = vector<vector<s64> >(n+1,vector<s64>(n+1,1)); UPTO(i,1,n) { FOR(j,i+1) { if (!j || j == i) data[i][j] = 1; else data[i][j] = data[i-1][j-1] + data[i-1][j]; } } } s64 ncr(int n, int r) { return data[n][r]; } }; static inline int ri() { int a; scanf("%d", &a); return a; } int main() { int n = ri(); int k = ri(); int a[n]; INPUT(a); s64 s[n]; FOR(i,n) s[i] = i?s[i-1]+a[i]:a[i]; s64 ss[n]; FOR(i,n) ss[i] = i?ss[i-1]+(a[i]<0?0:a[i]):(a[i]<0?0:a[i]); s64 res = -LINF; FOR(i,n) { if (i+k > n) break; s64 base = max(0LL,s[i+k-1]-s[i-1]); if (i) base += ss[i-1]; base += ss[n-1]-ss[i+k-1]; res = max(res,base); } cout << res << endl; return 0; }
a.cc: In constructor 'Comb::Comb(int)': a.cc:47:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 47 | UPTO(i,1,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:48:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 48 | FOR(j,i+1) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:48:13: note: in expansion of macro 'FOR' 48 | FOR(j,i+1) { | ^~~ a.cc: In function 'int main()': a.cc:23:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 23 | #define INPUT(var) FOR(i,countof(var)) cin >> var[i] | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:23:20: note: in expansion of macro 'FOR' 23 | #define INPUT(var) FOR(i,countof(var)) cin >> var[i] | ^~~ a.cc:70:9: note: in expansion of macro 'INPUT' 70 | INPUT(a); | ^~~~~ a.cc:73:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 73 | FOR(i,n) s[i] = i?s[i-1]+a[i]:a[i]; | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:73:9: note: in expansion of macro 'FOR' 73 | FOR(i,n) s[i] = i?s[i-1]+a[i]:a[i]; | ^~~ a.cc:76:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 76 | FOR(i,n) ss[i] = i?ss[i-1]+(a[i]<0?0:a[i]):(a[i]<0?0:a[i]); | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:76:9: note: in expansion of macro 'FOR' 76 | FOR(i,n) ss[i] = i?ss[i-1]+(a[i]<0?0:a[i]):(a[i]<0?0:a[i]); | ^~~ a.cc:79:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 79 | FOR(i,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:79:9: note: in expansion of macro 'FOR' 79 | FOR(i,n) { | ^~~ a.cc:81:31: error: no matching function for call to 'max(long long int, s64)' 81 | s64 base = max(0LL,s[i+k-1]-s[i-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:81:31: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 's64' {aka 'long int'}) 81 | s64 base = max(0LL,s[i+k-1]-s[i-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:81:31: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 81 | s64 base = max(0LL,s[i+k-1]-s[i-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~
s038954022
p03839
C++
#include <bits/stdc++.h> #define INF 1e9 using namespace std; typedef long long ll; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<ll> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = max(a[i], 0); } vector<ll> sum1(n + 1), sum2(n + 1); sum1[0] = 0; sum2[0] = 0; for (int i = 0; i < n; i++) { sum2[i + 1] = sum2[i] + b[i]; sum1[i + 1] = sum1[i] + a[i]; } ll ans = 0; for (int i = 0; i + k <= n; i++) { ll tmp1 = max((ll)0, sum1[i + k] - sum1[i]); ll tmp2 = sum2[i] + sum2[n] - sum2[i + k]; ans = max(ans, tmp1 + tmp2); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:17:19: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)' 17 | b[i] = max(a[i], 0); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:17:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 17 | b[i] = max(a[i], 0); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:17:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 17 | b[i] = max(a[i], 0); | ~~~^~~~~~~~~
s305322302
p03839
C++
#include <iostream> #include <iomanip> #include <algorithm> #include <functional> #include <vector> #include <map> #include <stack> #include <string> #include <list> #include <set> #include <queue> #include <deque> #include <math.h> using namespace std; typedef pair<int, int> P; #define ll long long #define int ll #define INF (1LL<<60) #define mod 1000000007 int dx[4] = { 0, 1, 0, -1 }; int dy[4] = { 1, 0, -1, 0 }; signed main(){ int N, K, a[100005]; cin >> N >> K; for (int i = 0; i < N; i++) cin >> a[i]; // 連続するK個を選び int ma = -INF; int s = 0; for (int i = 0; i < K; i++){ s += a[i]; } ma = s; int r = 0; for (int i = 1; i + K-1 < N; i++){ s += a[i + K-1] - a[i - 1]; if (s > ma){ ma = s; r = i; } } for (int i = 0; i < N; i++){ if (a[i]>0 && (i < r || i >= r + K)) ma += a[i]; } // 連続するK個を選ばない int mi = INF; s = 0; for (int i = 0; i < K; i++){ s += a[i]; } mi = s; r = 0; for (int i = 1; i + K - 1 < N; i++){ s += a[i + K - 1] - a[i - 1]; if (s < mi){ mi = s; r = i; } } mi = max(0, mi); for (int i = 0; i < N; i++){ if (a[i]>0 && (i < r || i >= r + K)) mi += a[i]; } cout << max(ma, mi) << endl; return 0; }
a.cc: In function 'int main()': a.cc:70:17: error: no matching function for call to 'max(int, long long int&)' 70 | mi = max(0, mi); | ~~~^~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:70:17: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 70 | mi = max(0, mi); | ~~~^~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:70:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 70 | mi = max(0, mi); | ~~~^~~~~~~
s768960293
p03839
C++
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<utility> #include<numeric> #include<vector> #include<MAP> #include<unordered_MAP> #include<set> #include<tuple> #include<stack> #include<queue> #include<functional> #include<iterator> #include<cmath> #include<cctype> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; const int INF = 1e9; const ll LINF = 1e18; const int MOD = INF+7; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define rep(i,n) FOR(i,0,n) struct edge{int to,cost;}; void dump(ll *b,int n){ for(int i=0;i<n;i++){ cout << b[i] << " "; } cout << "\n"; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n,k; cin >> n >> k; int a[n]; ll rui[n+1]={}; ll seirui[n+1]={}; rep(i,n){ cin >> a[i]; rui[i+1]=rui[i]+a[i]; if(a[i]>0) seirui[i+1]=seirui[i]+a[i]; else seirui[i+1]=seirui[i]; } ll ans=0; for(int i=1;i<=n-k+1;i++){ // cout << seirui[n]-seirui[i+k-1]+seirui[i-1]+max(0LL,rui[i+k-1]-rui[i-1]) << "\n"; ans = max(ans,seirui[n]-seirui[i+k-1]+seirui[i-1]+max(0LL,rui[i+k-1]-rui[i-1])); } cout << ans << "\n"; return 0; }
a.cc:8:9: fatal error: MAP: No such file or directory 8 | #include<MAP> | ^~~~~ compilation terminated.
s201341022
p03839
C++
10 5 5 -4 -5 -8 -4 7 2 -4 0 7
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 10 5 | ^~
s970002385
p03839
C++
#include <bits/stdc++.h> #define mod 1000000007 #define pb push_back #define ll long long using namespace std; int main(){ int n,k; cin>>n>>k; vector<ll> a(n+2),psum(n+2),ksum(n+2); for(int i=1;i<=n;i++){ cin>>a[i]; psum[i] = psum[i-1] + max(a[i],0); } for(int i=1;i<=k;i++){ ksum[1]+=a[i]; } for(int i=k+1;i<=n;i++){ ksum[i-k+1] = ksum[i-k] + a[i] - a[i-k]; } ll ans=-1; for(int i=1;i<=n-k+1;i++){ ll tmp=0; tmp += max(ksum[i],0); tmp += psum[i-1]; tmp += psum[n] - psum[i+k-1]; if(ans<tmp)ans=tmp; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:12:42: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)' 12 | psum[i] = psum[i-1] + max(a[i],0); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:42: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 12 | psum[i] = psum[i-1] + max(a[i],0); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:12:42: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 12 | psum[i] = psum[i-1] + max(a[i],0); | ~~~^~~~~~~~ a.cc:23:27: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)' 23 | tmp += max(ksum[i],0); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:23:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 23 | tmp += max(ksum[i],0); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:23:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 23 | tmp += max(ksum[i],0); | ~~~^~~~~~~~~~~
s294444570
p03839
C++
/* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <iostream> #include <cstdint> #include <utility> #include <tuple> #include <vector> #include <stack> #include <queue> #include <unordered_map> #include <unordered_set> #include <map> #include <set> #include <algorithm> #include <limits> #include <numeric> #include <iomanip> #include <type_traits> #include <functional> #include <experimental/optional> /* import STL */ // stream using std::cout; using std::cerr; using std::cin; using std::endl; using std::flush; // basic types using std::nullptr_t; using std::experimental::optional; using std::pair; using std::tuple; using std::string; // function for basic types using std::experimental::make_optional; using std::make_pair; using std::make_tuple; using std::get; /* TODO remove them */ using std::vector; using std::queue; using std::stack; // algorithms using std::upper_bound; using std::lower_bound; using std::min_element; using std::max_element; using std::nth_element; using std::accumulate; /* macros */ // loops #define REP(i, n) for (i64 i = 0; i < static_cast<decltype(i)>(n); ++i) #define REPR(i, n) for (i64 i = (n) - 1; i >= static_cast<decltype(i)>(0); --i) #define FOR(i, n, m) for (i64 i = (n); i < static_cast<decltype(i)>(m); ++i) #define FORR(i, n, m) for (i64 i = (m) - 1; i >= static_cast<decltype(i)>(n); --i) #define EACH(x, xs) for (auto &x: (xs)) #define EACH_V(x, xs) for (auto x: (xs)) // helpers #define CTR(x) (x).begin(), (x).end() /* utils for std::tuple */ namespace internal { namespace tuple_utils { // TODO rename to "internal::tuple" template<size_t...> struct seq {}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template<class Tuple, size_t... Is> void read(std::istream &stream, Tuple &t, seq<Is...>) { static_cast<void>((int[]) {0, (void(stream >> get<Is>(t)), 0)...}); } template<class Tuple, size_t... Is> void print(std::ostream &stream, Tuple const &t, seq<Is...>) { static_cast<void>((int[]) {0, (void(stream << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}); } template<size_t I, class F, class A, class... Elems> struct ForEach { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } }; template<class F, class A, class... Elems> struct ForEach<0, F, A, Elems...> { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<0>(t)); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<0>(t)); } }; template<class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> const &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } template<class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } }} /* utils for Matrix (definition of Matrix) */ namespace internal { namespace matrix { template <typename V, int N> struct matrix_t { using type = std::vector<typename matrix_t<V, N-1>::type>; }; template <typename V> struct matrix_t<V, 0> { using type = V; }; template <typename V, int N> using Matrix = typename matrix_t<V, N>::type; template <typename V, typename It, int N> struct matrix_helper { static Matrix<V, N> create(const It &begin, const It &end, const V &default_value) { return Matrix<V, N>(*begin, matrix_helper<V, It, N - 1>::create(begin + 1, end, default_value)); } }; template <typename V, typename It> struct matrix_helper<V, It, 0> { static Matrix<V, 0> create(const It &begin __attribute__((unused)), const It &end __attribute__((unused)), const V &default_value) { return default_value; } }; }} /* Primitive types */ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using usize = size_t; /* Data structure type */ template <typename T> using Vector = std::vector<T>; template <typename V> using OrderedSet = std::set<V>; template <typename V> using HashSet = std::unordered_set<V>; template <typename K, typename V> using OrderedMap = std::map<K, V>; template <typename K, typename V> using HashMap = std::unordered_map<K, V>; template <typename T, int N> using Matrix = internal::matrix::Matrix<T, N>; template <typename T, typename Compare = std::less<T>, typename Container = std::vector<T>> using PriorityQueue = std::priority_queue<T, Container, Compare>; /* utils for Vector */ template <typename V> Vector<V> make_pre_allocated_vector(size_t N) { Vector<V> retval; retval.reserve(N); return retval; } /* utils for Matrix */ template <class V, int N> Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { return internal::matrix::matrix_helper<V, decltype(shape.begin()), N>::create(shape.begin(), shape.end(), default_value); } /* utils for STL iterators */ namespace internal { template <typename Iterator, typename F> struct MappedIterator { MappedIterator(const Iterator &it, const F &function) : it(it), function(function) {} auto operator *() const { return this->function(this->it); } void operator++() { ++this->it; } void operator+=(size_t n) { this->it += n; } auto operator+(size_t n) const { return MappedIterator<Iterator, F>(this->it + n, this->function); } bool operator==(const MappedIterator<Iterator, F> &rhs) const { return this->it == rhs.it; } bool operator!=(const MappedIterator<Iterator, F> &rhs) const { return !(*this == rhs); } private: Iterator it; F function; }; template <typename Iterator, typename P> struct FilteredIterator { FilteredIterator(const Iterator &it, const Iterator &end, const P &predicate) : it(it), end(end), predicate(predicate) { if (this->it != end) { if (!predicate(this->it)) { this->increment(); } } } decltype(auto) operator *() const { return *this->it; } auto operator ->() const { return this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP (i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FilteredIterator<Iterator, P> &rhs) const { return this->it == rhs.it; } bool operator!=(const FilteredIterator<Iterator, P> &rhs) const { return !(*this == rhs); } private: void increment() { if (this->it == this->end) { return ; } ++this->it; while (this->it != this->end && !this->predicate(this->it)) { ++this->it; } } Iterator it; Iterator end; P predicate; }; template <typename Iterator, typename ElementIterator> struct FlattenedIterator { FlattenedIterator(const Iterator &it, const Iterator &end) : it(make_pair(it, ElementIterator())), end(end) { if (this->it.first != this->end) { this->it.second = it->begin(); } this->find_valid(); } decltype(auto) operator *() const { return this->it; } const pair<Iterator, ElementIterator> *operator ->() const { return &this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP (i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { if (this->it.first != rhs.it.first) { return false; } if (this->it.first == this->end || rhs.it.first == rhs.end) { if (this->end == rhs.end) { return true; } else { return false; } } else { return this->it.second == rhs.it.second; } } bool operator!=(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { return !(*this == rhs); } private: bool is_end() const { return this->it.first == this->end; } bool is_valid() const { if (this->is_end()) return false; if (this->it.second == this->it.first->end()) return false; return true; } void _increment() { if (this->it.second == this->it.first->end()) { ++this->it.first; if (this->it.first != this->end) { this->it.second = this->it.first->begin(); } } else { ++this->it.second; } } void find_valid() { while (!this->is_end() && !this->is_valid()) { this->_increment(); } } void increment() { this->_increment(); while (!this->is_end() && !this->is_valid()) { this->_increment(); } } pair<Iterator, ElementIterator> it; Iterator end; }; } template <class Iterator> struct Container { Container(const Iterator &begin, const Iterator &end) : m_begin(begin), m_end(end) {} const Iterator& begin() const { return this->m_begin; } const Iterator& end() const { return this->m_end; } Iterator m_begin; Iterator m_end; }; template <typename C, typename F> auto iterator_map(const C &c, F function) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::MappedIterator<Iterator, F>>( internal::MappedIterator<Iterator, F>(c.begin(), function), internal::MappedIterator<Iterator, F>(c.end(), function)); } template <typename C, typename P> auto iterator_filter(const C &c, P predicate) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::FilteredIterator<Iterator, P>>( internal::FilteredIterator<Iterator, P>(c.begin(), c.end(), predicate), internal::FilteredIterator<Iterator, P>(c.end(), c.end(), predicate)); } template <typename C> auto iterator_flatten(const C &c) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; using ElementIterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin()->begin())>>; return Container<internal::FlattenedIterator<Iterator, ElementIterator>>( internal::FlattenedIterator<Iterator, ElementIterator>(c.begin(), c.end()), internal::FlattenedIterator<Iterator, ElementIterator>(c.end(), c.end())); } /* input */ template <class F, class S> std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { stream >> pair.first; stream >> pair.second; return stream; } template <class ...Args> std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { internal::tuple_utils::read(stream, tuple, internal::tuple_utils::gen_seq<sizeof...(Args)>()); return stream; } template <class T> T read() { T t; cin >> t; return t; } template <class F, class S> pair<F, S> read() { pair<F, S> p; cin >> p; return p; } template <class T1, class T2, class T3, class ...Args> tuple<T1, T2, T3, Args...> read() { tuple<T1, T2, T3, Args...> t; cin >> t; return t; } template <typename T, typename F = std::function<T()>> Vector<T> read(const usize length, F r) { auto retval = make_pre_allocated_vector<T>(length); REP (i, length) { retval.emplace_back(r()); } return retval; } template <class T> Vector<T> read(const usize length) { return read<T>(length, [] { return read<T>(); }); } template <class F, class S> Vector<pair<F, S>> read(const usize length) { return read<pair<F, S>>(length); } template <class T1, class T2, class T3, class ...Args> Vector<tuple<T1, T2, T3, Args...>> read(const usize length) { return read<tuple<T1, T2, T3, Args...>>(length); } namespace internal { template <typename T> struct oneline { std::string operator()(const T &t) const { std::ostringstream oss; oss << t; return oss.str(); } }; template <typename F, typename S> struct oneline<pair<F, S>> { std::string operator()(const pair<F, S> &p) const { std::ostringstream oss; oss << "{" << oneline<F>()(p.first) << ", " << oneline<S>()(p.second) << "}"; return oss.str(); } }; template <typename ...Args> struct oneline<tuple<Args...>> { struct oneline_tuple { template<class V> void operator()(Vector<std::string> &strs, const V &v) const { strs.emplace_back(oneline<V>()(v)); } }; std::string operator()(const tuple<Args...> &t) const { std::ostringstream oss; Vector<std::string> strs; internal::tuple_utils::for_each<oneline_tuple, Vector<std::string>, Args...>(strs, t); oss << "{"; REPR (i, strs.size()) { oss << strs[i]; if (i != 0) { oss << ", "; } } oss << "}"; return oss.str(); } }; template <> struct oneline<bool> { std::string operator()(const bool b) const { return b ? "true" : "false"; } }; template <typename X> struct oneline<Vector<X>> { std::string operator()(const Vector<X> &vec) const { std::string retval = "["; auto f = oneline<X>(); REP (i, vec.size()) { retval += f(vec[i]); if (i != static_cast<i64>(vec.size() - 1)) { retval += ", "; } } retval += "]"; return retval; } }; template <typename X> struct oneline<OrderedSet<X>> { std::string operator()(const OrderedSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH (x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename X> struct oneline<HashSet<X>> { std::string operator()(const HashSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH (x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<OrderedMap<K, V>> { std::string operator()(const OrderedMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH (x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<HashMap<K, V>> { std::string operator()(const HashMap<K,V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH (x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename V> struct keys { /* no implementation */ }; template <typename X> struct keys<std::vector<X>> { Vector<size_t> operator()(const Vector<X> &v) const { Vector<size_t> keys; REP (i, v.size()) { keys.emplace_back(i); } return keys; } }; template <typename K, typename V> struct keys<OrderedMap<K, V>> { Vector<K> operator()(const OrderedMap<K, V> &c) const { Vector<K> keys; EACH (elem, c) { keys.emplace_back(elem.first); } return keys; } }; template <typename K, typename V> struct keys<HashMap<K, V>> { Vector<K> operator()(const HashMap<K, V> &c) const { Vector<K> keys; EACH (elem, c) { keys.emplace_back(elem.first); } return keys; } }; } template <typename T> void dump(const T& t) { using namespace internal; std::cerr << oneline<T>()(t) << std::endl; } template <typename V1, typename V2, typename ...Args> void dump(const V1 &v1, const V2 &v2, const Args&... args) { using namespace internal; using F = typename oneline<tuple<V1, V2, Args...>>::oneline_tuple; auto x = std::make_tuple(v1, v2, args...); Vector<std::string> strs; internal::tuple_utils::for_each<F, Vector<std::string>, V1, V2, Args...>(strs, x); REPR (i, strs.size()) { std::cerr << strs[i]; if (i != 0) { std::cerr << ", "; } } std::cerr << std::endl; } template <typename C> std::string as_set(const C& ctr) { Vector<std::string> values; using namespace internal; EACH (x, ctr) { values.emplace_back(oneline<decltype(x)>()(x)); } std::string retval = "---\n"; REP (i, values.size()) { retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_map(const C& ctr) { using namespace internal; auto ks = keys<C>()(ctr); Vector<std::string> keys; Vector<std::string> values; EACH (key, ks) { keys.emplace_back(oneline<decltype(key)>()(key)); values.emplace_back(oneline<decltype(ctr.at(key))>()(ctr.at(key))); } size_t l = 0; EACH (key, keys) { l = std::max(l, key.size()); } std::string retval = "---\n"; REP (i, values.size()) { retval += keys[i]; REP (j, l - keys[i].size()) { retval += " "; } retval += ": "; retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_table(const C &ctr) { using namespace internal; auto rkeys = keys<C>()(ctr); auto ckeys = OrderedSet<std::string>(); auto values = Vector<pair<std::string, OrderedMap<std::string, std::string>>>(); /* Stringify all data */ EACH (rkey, rkeys) { auto rkey_str = oneline<decltype(rkey)>()(rkey); values.emplace_back(rkey_str, OrderedMap<std::string, std::string>()); auto row = ctr.at(rkey); auto ks = keys<decltype(row)>()(row); EACH (ckey, ks) { auto ckey_str = oneline<decltype(ckey)>()(ckey); ckeys.emplace(ckey_str); values.back().second.emplace(ckey_str, oneline<decltype(row.at(ckey))>()(row.at(ckey))); } } /* Calculate string length */ size_t max_row_key_length = 0; EACH (value, values) { max_row_key_length = std::max(max_row_key_length, value.first.size()); } OrderedMap<std::string, size_t> max_col_length; EACH (ckey, ckeys) { max_col_length.emplace(ckey, ckey.size()); } EACH (value, values) { EACH (elem, value.second) { auto ckey = elem.first; auto value = elem.second; max_col_length[ckey] = std::max(max_col_length[ckey], value.size()); } } std::string retval = "---\n"; /* Header */ REP(i, max_row_key_length) { retval += " "; } retval += " "; size_t cnt = 0; EACH (ckey, ckeys) { retval += ckey; REP (j, max_col_length[ckey] - ckey.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n------\n"; /* Values */ EACH (value, values) { retval += value.first; REP(i, max_row_key_length - value.first.size()) { retval += " "; } retval += "| "; size_t cnt = 0; EACH (ckey, ckeys) { auto v = std::string(""); if (value.second.find(ckey) != value.second.end()) { v = value.second.at(ckey); } retval += v; REP (j, max_col_length[ckey] - v.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n"; } retval += "---"; return retval; } // Hash namespace std { template <class F, class S> struct hash<pair<F, S>> { size_t operator ()(const pair<F, S> &p) const { return hash<F>()(p.first) ^ hash<S>()(p.second); } }; template <class ...Args> struct hash<tuple<Args...>> { struct hash_for_element { template<class V> void operator()(size_t &size, const V &v) const { size ^= std::hash<V>()(v); } }; size_t operator ()(const tuple<Args...> &t) const { size_t retval = 0; internal::tuple_utils::for_each<hash_for_element, size_t, Args...>(retval, t); return retval; } }; } #define MAIN void body(); // main function (DO NOT EDIT) int main (int argc, char **argv) { cin.tie(0); std::ios_base::sync_with_stdio(false); cout << std::fixed; body(); return 0; } void body() { auto N = read<i64>(); auto K = read<i64>(); auto as = read<i64>(N); i64 all_positive_numbers = 0; EACH (a, as) { if (a < 0) continue; all_positive_numbers += a; } i64 pmin_white_K = 0; i64 max_black_K = 0; i64 pmax_black_K = 0; REP (i, K) { pmin_white_K += std::max(0L, as[i]); pmax_black_K += std::max(0L, as[i]); max_black_K += as[i]; } i64 pmin = pmin_white_K, pmax = pmax_black_K, m = max_black_K; FOR (i, 1, N - K + 1) { auto t = pmin; t -= std::max(0L, as[i - 1]); t += std::max(0L, as[i + K - 1]); if (t < pmin_white_K) { pmin_white_K = t; } auto s1 = pmax; s1 -= std::max(0L, as[i - 1]); s1 += std::max(0L, as[i + K - 1]); auto s2 = m; s2 -= as[i - 1]; s2 += as[i + K - 1]; if (s2 > max_black_K) { max_black_K = s2; pmax_black_K = s1; } pmin = t; pmax = s1; m = s2; } auto c1 = all_positive_numbers - pmin_white_K; auto c2 = all_positive_numbers - pmax_black_K + max_black_K; cout << std::max(c1, c2) << endl; } /* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <iostream> #include <cstdint> #include <utility> #include <tuple> #include <vector> #include <stack> #include <queue> #include <unordered_map> #include <unordered_set> #include <map> #include <set> #include <algorithm> #include <limits> #include <numeric> #include <iomanip> #include <type_traits> #include <functional> #include <experimental/optional> /* import STL */ // stream using std::cout; using std::cerr; using std::cin; using std::endl; using std::flush; // basic types using std::nullptr_t; using std::experimental::optional; using std::pair; using std::tuple; using std::string; // function for basic types using std::experimental::make_optional; using std::make_pair; using std::make_tuple; using std::get; /* TODO remove them */ using std::vector; using std::queue; using std::stack; // algorithms using std::upper_bound; using std::lower_bound; using std::min_element; using std::max_element; using std::nth_element; using std::accumulate; /* macros */ // loops #define REP(i, n) for (i64 i = 0; i < static_cast<decltype(i)>(n); ++i) #define REPR(i, n) for (i64 i = (n) - 1; i >= static_cast<decltype(i)>(0); --i) #define FOR(i, n, m) for (i64 i = (n); i < static_cast<decltype(i)>(m); ++i) #define FORR(i, n, m) for (i64 i = (m) - 1; i >= static_cast<decltype(i)>(n); --i) #define EACH(x, xs) for (auto &x: (xs)) #define EACH_V(x, xs) for (auto x: (xs)) // helpers #define CTR(x) (x).begin(), (x).end() /* utils for std::tuple */ namespace internal { namespace tuple_utils { // TODO rename to "internal::tuple" template<size_t...> struct seq {}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template<class Tuple, size_t... Is> void read(std::istream &stream, Tuple &t, seq<Is...>) { static_cast<void>((int[]) {0, (void(stream >> get<Is>(t)), 0)...}); } template<class Tuple, size_t... Is> void print(std::ostream &stream, Tuple const &t, seq<Is...>) { static_cast<void>((int[]) {0, (void(stream << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}); } template<size_t I, class F, class A, class... Elems> struct ForEach { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } }; template<class F, class A, class... Elems> struct ForEach<0, F, A, Elems...> { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<0>(t)); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<0>(t)); } }; template<class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> const &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } template<class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } }} /* utils for Matrix (definition of Matrix) */ namespace internal { namespace matrix { template <typename V, int N> struct matrix_t { using type = std::vector<typename matrix_t<V, N-1>::type>; }; template <typename V> struct matrix_t<V, 0> { using type = V; }; template <typename V, int N> using Matrix = typename matrix_t<V, N>::type; template <typename V, typename It, int N> struct matrix_helper { static Matrix<V, N> create(const It &begin, const It &end, const V &default_value) { return Matrix<V, N>(*begin, matrix_helper<V, It, N - 1>::create(begin + 1, end, default_value)); } }; template <typename V, typename It> struct matrix_helper<V, It, 0> { static Matrix<V, 0> create(const It &begin __attribute__((unused)), const It &end __attribute__((unused)), const V &default_value) { return default_value; } }; }} /* Primitive types */ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using usize = size_t; /* Data structure type */ template <typename T> using Vector = std::vector<T>; template <typename V> using OrderedSet = std::set<V>; template <typename V> using HashSet = std::unordered_set<V>; template <typename K, typename V> using OrderedMap = std::map<K, V>; template <typename K, typename V> using HashMap = std::unordered_map<K, V>; template <typename T, int N> using Matrix = internal::matrix::Matrix<T, N>; template <typename T, typename Compare = std::less<T>, typename Container = std::vector<T>> using PriorityQueue = std::priority_queue<T, Container, Compare>; /* utils for Vector */ template <typename V> Vector<V> make_pre_allocated_vector(size_t N) { Vector<V> retval; retval.reserve(N); return retval; } /* utils for Matrix */ template <class V, int N> Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { return internal::matrix::matrix_helper<V, decltype(shape.begin()), N>::create(shape.begin(), shape.end(), default_value); } /* utils for STL iterators */ namespace internal { template <typename Iterator, typename F> struct MappedIterator { MappedIterator(const Iterator &it, const F &function) : it(it), function(function) {} auto operator *() const { return this->function(this->it); } void operator++() { ++this->it; } void operator+=(size_t n) { this->it += n; } auto operator+(size_t n) const { return MappedIterator<Iterator, F>(this->it + n, this->function); } bool operator==(const MappedIterator<Iterator, F> &rhs) const { return this->it == rhs.it; } bool operator!=(const MappedIterator<Iterator, F> &rhs) const { return !(*this == rhs); } private: Iterator it; F function; }; template <typename Iterator, typename P> struct FilteredIterator { FilteredIterator(const Iterator &it, const Iterator &end, const P &predicate) : it(it), end(end), predicate(predicate) { if (this->it != end) { if (!predicate(this->it)) { this->increment(); } } } decltype(auto) operator *() const { return *this->it; } auto operator ->() const { return this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP (i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FilteredIterator<Iterator, P> &rhs) const { return this->it == rhs.it; } bool operator!=(const FilteredIterator<Iterator, P> &rhs) const { return !(*this == rhs); } private: void increment() { if (this->it == this->end) { return ; } ++this->it; while (this->it != this->end && !this->predicate(this->it)) { ++this->it; } } Iterator it; Iterator end; P predicate; }; template <typename Iterator, typename ElementIterator> struct FlattenedIterator { FlattenedIterator(const Iterator &it, const Iterator &end) : it(make_pair(it, ElementIterator())), end(end) { if (this->it.first != this->end) { this->it.second = it->begin(); } this->find_valid(); } decltype(auto) operator *() const { return this->it; } const pair<Iterator, ElementIterator> *operator ->() const { return &this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP (i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { if (this->it.first != rhs.it.first) { return false; } if (this->it.first == this->end || rhs.it.first == rhs.end) { if (this->end == rhs.end) { return true; } else { return false; } } else { return this->it.second == rhs.it.second; } } bool operator!=(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { return !(*this == rhs); } private: bool is_end() const { return this->it.first == this->end; } bool is_valid() const { if (this->is_end()) return false; if (this->it.second == this->it.first->end()) return false; return true; } void _increment() { if (this->it.second == this->it.first->end()) { ++this->it.first; if (this->it.first != this->end) { this->it.second = this->it.first->begin(); } } else { ++this->it.second; } } void find_valid() { while (!this->is_end() && !this->is_valid()) { this->_increment(); } } void increment() { this->_increment(); while (!this->is_end() && !this->is_valid()) { this->_increment(); } } pair<Iterator, ElementIterator> it; Iterator end; }; } template <class Iterator> struct Container { Container(const Iterator &begin, const Iterator &end) : m_begin(begin), m_end(end) {} const Iterator& begin() const { return this->m_begin; } const Iterator& end() const { return this->m_end; } Iterator m_begin; Iterator m_end; }; template <typename C, typename F> auto iterator_map(const C &c, F function) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::MappedIterator<Iterator, F>>( internal::MappedIterator<Iterator, F>(c.begin(), function), internal::MappedIterator<Iterator, F>(c.end(), function)); } template <typename C, typename P> auto iterator_filter(const C &c, P predicate) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::FilteredIterator<Iterator, P>>( internal::FilteredIterator<Iterator, P>(c.begin(), c.end(), predicate), internal::FilteredIterator<Iterator, P>(c.end(), c.end(), predicate)); } template <typename C> auto iterator_flatten(const C &c) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; using ElementIterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin()->begin())>>; return Container<internal::FlattenedIterator<Iterator, ElementIterator>>( internal::FlattenedIterator<Iterator, ElementIterator>(c.begin(), c.end()), internal::FlattenedIterator<Iterator, ElementIterator>(c.end(), c.end())); } /* input */ template <class F, class S> std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { stream >> pair.first; stream >> pair.second; return stream; } template <class ...Args> std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { internal::tuple_utils::read(stream, tuple, internal::tuple_utils::gen_seq<sizeof...(Args)>()); return stream; } template <class T> T read() { T t; cin >> t; return t; } template <class F, class S> pair<F, S> read() { pair<F, S> p; cin >> p; return p; } template <class T1, class T2, class T3, class ...Args> tuple<T1, T2, T3, Args...> read() { tuple<T1, T2, T3, Args...> t; cin >> t; return t; } template <typename T, typename F = std::function<T()>> Vector<T> read(const usize length, F r) { auto retval = make_pre_allocated_vector<T>(length); REP (i, length) { retval.emplace_back(r()); } return retval; } template <class T> Vector<T> read(const usize length) { return read<T>(length, [] { return read<T>(); }); } template <class F, class S> Vector<pair<F, S>> read(const usize length) { return read<pair<F, S>>(length); } template <class T1, class T2, class T3, class ...Args> Vector<tuple<T1, T2, T3, Args...>> read(const usize length) { return read<tuple<T1, T2, T3, Args...>>(length); } namespace internal { template <typename T> struct oneline { std::string operator()(const T &t) const { std::ostringstream oss; oss << t; return oss.str(); } }; template <typename F, typename S> struct oneline<pair<F, S>> { std::string operator()(const pair<F, S> &p) const { std::ostringstream oss; oss << "{" << oneline<F>()(p.first) << ", " << oneline<S>()(p.second) << "}"; return oss.str(); } }; template <typename ...Args> struct oneline<tuple<Args...>> { struct oneline_tuple { template<class V> void operator()(Vector<std::string> &strs, const V &v) const { strs.emplace_back(oneline<V>()(v)); } }; std::string operator()(const tuple<Args...> &t) const { std::ostringstream oss; Vector<std::string> strs; internal::tuple_utils::for_each<oneline_tuple, Vector<std::string>, Args...>(strs, t); oss << "{"; REPR (i, strs.size()) { oss << strs[i]; if (i != 0) { oss << ", "; } } oss << "}"; return oss.str(); } }; template <> struct oneline<bool> { std::string operator()(const bool b) const { return b ? "true" : "false"; } }; template <typename X> struct oneline<Vector<X>> { std::string operator()(const Vector<X> &vec) const { std::string retval = "["; auto f = oneline<X>(); REP (i, vec.size()) { retval += f(vec[i]); if (i != static_cast<i64>(vec.size() - 1)) { retval += ", "; } } retval += "]"; return retval; } }; template <typename X> struct oneline<OrderedSet<X>> { std::string operator()(const OrderedSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH (x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename X> struct oneline<HashSet<X>> { std::string operator()(const HashSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH (x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<OrderedMap<K, V>> { std::string operator()(const OrderedMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH (x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<HashMap<K, V>> { std::string operator()(const HashMap<K,V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH (x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename V> struct keys { /* no implementation */ }; template <typename X> struct keys<std::vector<X>> { Vector<size_t> operator()(const Vector<X> &v) const { Vector<size_t> keys; REP (i, v.size()) { keys.emplace_back(i); } return keys; } }; template <typename K, typename V> struct keys<OrderedMap<K, V>> { Vector<K> operator()(const OrderedMap<K, V> &c) const { Vector<K> keys; EACH (elem, c) { keys.emplace_back(elem.first); } return keys; } }; template <typename K, typename V> struct keys<HashMap<K, V>> { Vector<K> operator()(const HashMap<K, V> &c) const { Vector<K> keys; EACH (elem, c) { keys.emplace_back(elem.first); } return keys; } }; } template <typename T> void dump(const T& t) { using namespace internal; std::cerr << oneline<T>()(t) << std::endl; } template <typename V1, typename V2, typename ...Args> void dump(const V1 &v1, const V2 &v2, const Args&... args) { using namespace internal; using F = typename oneline<tuple<V1, V2, Args...>>::oneline_tuple; auto x = std::make_tuple(v1, v2, args...); Vector<std::string> strs; internal::tuple_utils::for_each<F, Vector<std::string>, V1, V2, Args...>(strs, x); REPR (i, strs.size()) { std::cerr << strs[i]; if (i != 0) { std::cerr << ", "; } } std::cerr << std::endl; } template <typename C> std::string as_set(const C& ctr) { Vector<std::string> values; using namespace internal; EACH (x, ctr) { values.emplace_back(oneline<decltype(x)>()(x)); } std::string retval = "---\n"; REP (i, values.size()) { retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_map(const C& ctr) { using namespace internal; auto ks = keys<C>()(ctr); Vector<std::string> keys; Vector<std::string> values; EACH (key, ks) { keys.emplace_back(oneline<decltype(key)>()(key)); values.emplace_back(oneline<decltype(ctr.at(key))>()(ctr.at(key))); } size_t l = 0; EACH (key, keys) { l = std::max(l, key.size()); } std::string retval = "---\n"; REP (i, values.size()) { retval += keys[i]; REP (j, l - keys[i].size()) { retval += " "; } retval += ": "; retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_table(const C &ctr) { using namespace internal; auto rkeys = keys<C>()(ctr); auto ckeys = OrderedSet<std::string>(); auto values = Vector<pair<std::string, OrderedMap<std::string, std::string>>>(); /* Stringify all data */ EACH (rkey, rkeys) { auto rkey_str = oneline<decltype(rkey)>()(rkey); values.emplace_back(rkey_str, OrderedMap<std::string, std::string>()); auto row = ctr.at(rkey); auto ks = keys<decltype(row)>()(row); EACH (ckey, ks) { auto ckey_str = oneline<decltype(ckey)>()(ckey); ckeys.emplace(ckey_str); values.back().second.emplace(ckey_str, oneline<decltype(row.at(ckey))>()(row.at(ckey))); } } /* Calculate string length */ size_t max_row_key_length = 0; EACH (value, values) { max_row_key_length = std::max(max_row_key_length, value.first.size()); } OrderedMap<std::string, size_t> max_col_length; EACH (ckey, ckeys) { max_col_length.emplace(ckey, ckey.size()); } EACH (value, values) { EACH (elem, value.second) { auto ckey = elem.first; auto value = elem.second; max_col_length[ckey] = std::max(max_col_length[ckey], value.size()); } } std::string retval = "---\n"; /* Header */ REP(i, max_row_key_length) { retval += " "; } retval += " "; size_t cnt = 0; EACH (ckey, ckeys) { retval += ckey; REP (j, max_col_length[ckey] - ckey.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n------\n"; /* Values */ EACH (value, values) { retval += value.first; REP(i, max_row_key_length - value.first.size()) { retval += " "; } retval += "| "; size_t cnt = 0; EACH (ckey, ckeys) { auto v = std::string(""); if (value.second.find(ckey) != value.second.end()) { v = value.second.at(ckey); } retval += v; REP (j, max_col_length[ckey] - v.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n"; } retval += "---"; return retval; } // Hash namespace std { template <class F, class S> struct hash<pair<F, S>> { size_t operator ()(const pair<F, S> &p) const { return hash<F>()(p.first) ^ hash<S>()(p.second); } }; template <class ...Args> struct hash<tuple<Args...>> { struct hash_for_element { template<class V> void operator()(size_t &size, const V &v) const { size ^= std::hash<V>()(v); } }; size_t operator ()(const tuple<Args...> &t) const { size_t retval = 0; internal::tuple_utils::for_each<hash_for_element, size_t, Args...>(retval, t); return retval; } }; } #define MAIN void body(); // main function (DO NOT EDIT) int main (int argc, char **argv) { cin.tie(0); std::ios_base::sync_with_stdio(false); cout << std::fixed; body(); return 0; } void body() { auto N = read<i64>(); auto K = read<i64>(); auto as = read<i64>(N); i64 all_positive_numbers = 0; EACH (a, as) { if (a < 0) continue; all_positive_numbers += a; } i64 pmin_white_K = 0; i64 max_black_K = 0; i64 pmax_black_K = 0; REP (i, K) { pmin_white_K += std::max(0L, as[i]); pmax_black_K += std::max(0L, as[i]); max_black_K += as[i]; } i64 pmin = pmin_white_K, pmax = pmax_black_K, m = max_black_K; FOR (i, 1, N - K + 1) { auto t = pmin; t -= std::max(0L, as[i - 1]); t += std::max(0L, as[i + K - 1]); if (t < pmin_white_K) { pmin_white_K = t; } auto s1 = pmax; s1 -= std::max(0L, as[i - 1]); s1 += std::max(0L, as[i + K - 1]); auto s2 = m; s2 -= as[i - 1]; s2 += as[i + K - 1]; if (s2 > max_black_K) { max_black_K = s2; pmax_black_K = s1; } pmin = t; pmax = s1; m = s2; } auto c1 = all_positive_numbers - pmin_white_K; auto c2 = all_positive_numbers - pmax_black_K + max_black_K; cout << std::max(c1, c2) << endl; }
a.cc:939:12: error: redefinition of 'struct internal::tuple_utils::seq<<anonymous> >' 939 | struct seq {}; | ^~~ a.cc:80:12: note: previous definition of 'struct internal::tuple_utils::seq<<anonymous> >' 80 | struct seq {}; | ^~~ a.cc:942:12: error: redefinition of 'struct internal::tuple_utils::gen_seq<N, Is>' 942 | struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; | ^~~~~~~ a.cc:83:12: note: previous definition of 'struct internal::tuple_utils::gen_seq<N, Is>' 83 | struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; | ^~~~~~~ a.cc:945:12: error: redefinition of 'struct internal::tuple_utils::gen_seq<0, Is ...>' 945 | struct gen_seq<0, Is...> : seq<Is...> {}; | ^~~~~~~~~~~~~~~~~ a.cc:86:12: note: previous definition of 'struct internal::tuple_utils::gen_seq<0, Is ...>' 86 | struct gen_seq<0, Is...> : seq<Is...> {}; | ^~~~~~~~~~~~~~~~~ a.cc:948:10: error: redefinition of 'template<class Tuple, long unsigned int ...Is> void internal::tuple_utils::read(std::istream&, Tuple&, seq<Is ...>)' 948 | void read(std::istream &stream, Tuple &t, seq<Is...>) { | ^~~~ a.cc:89:10: note: 'template<class Tuple, long unsigned int ...Is> void internal::tuple_utils::read(std::istream&, Tuple&, seq<Is ...>)' previously declared here 89 | void read(std::istream &stream, Tuple &t, seq<Is...>) { | ^~~~ a.cc:953:10: error: redefinition of 'template<class Tuple, long unsigned int ...Is> void internal::tuple_utils::print(std::ostream&, const Tuple&, seq<Is ...>)' 953 | void print(std::ostream &stream, Tuple const &t, seq<Is...>) { | ^~~~~ a.cc:94:10: note: 'template<class Tuple, long unsigned int ...Is> void internal::tuple_utils::print(std::ostream&, const Tuple&, seq<Is ...>)' previously declared here 94 | void print(std::ostream &stream, Tuple const &t, seq<Is...>) { | ^~~~~ a.cc:958:12: error: redefinition of 'struct internal::tuple_utils::ForEach<I, F, A, Elems>' 958 | struct ForEach { | ^~~~~~~ a.cc:99:12: note: previous definition of 'struct internal::tuple_utils::ForEach<I, F, A, Elems>' 99 | struct ForEach { | ^~~~~~~ a.cc:971:12: error: redefinition of 'struct internal::tuple_utils::ForEach<0, F, A, Elems ...>' 971 | struct ForEach<0, F, A, Elems...> { | ^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:112:12: note: previous definition of 'struct internal::tuple_utils::ForEach<0, F, A, Elems ...>' 112 | struct ForEach<0, F, A, Elems...> { | ^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:982:10: error: redefinition of 'template<class F, class A, class ... Elems> void internal::tuple_utils::for_each(A&, const std::tuple<_Tp ...>&)' 982 | void for_each(A &arg, tuple<Elems...> const &t) { | ^~~~~~~~ a.cc:123:10: note: 'template<class F, class A, class ... Elems> void internal::tuple_utils::for_each(A&, const std::tuple<_Tp ...>&)' previously declared here 123 | void for_each(A &arg, tuple<Elems...> const &t) { | ^~~~~~~~ a.cc:987:10: error: redefinition of 'template<class F, class A, class ... Elems> void internal::tuple_utils::for_each(A&, std::tuple<_Tp ...>&)' 987 | void for_each(A &arg, tuple<Elems...> &t) { | ^~~~~~~~ a.cc:128:10: note: 'template<class F, class A, class ... Elems> void internal::tuple_utils::for_each(A&, std::tuple<_Tp ...>&)' previously declared here 128 | void for_each(A &arg, tuple<Elems...> &t) { | ^~~~~~~~ a.cc:995:12: error: redefinition of 'struct internal::matrix::matrix_t<V, N>' 995 | struct matrix_t { | ^~~~~~~~ a.cc:136:12: note: previous definition of 'struct internal::matrix::matrix_t<V, N>' 136 | struct matrix_t { | ^~~~~~~~ a.cc:999:12: error: redefinition of 'struct internal::matrix::matrix_t<V, 0>' 999 | struct matrix_t<V, 0> { | ^~~~~~~~~~~~~~ a.cc:140:12: note: previous definition of 'struct internal::matrix::matrix_t<V, 0>' 140 | struct matrix_t<V, 0> { | ^~~~~~~~~~~~~~ a.cc:1007:12: error: redefinition of 'struct internal::matrix::matrix_helper<V, It, N>' 1007 | struct matrix_helper { | ^~~~~~~~~~~~~ a.cc:148:12: note: previous definition of 'struct internal::matrix::matrix_helper<V, It, N>' 148 | struct matrix_helper { | ^~~~~~~~~~~~~ a.cc:1013:12: error: redefinition of 'struct internal::matrix::matrix_helper<V, It, 0>' 1013 | struct matrix_helper<V, It, 0> { | ^~~~~~~~~~~~~~~~~~~~~~~ a.cc:154:12: note: previous definition of 'struct internal::matrix::matrix_helper<V, It, 0>' 154 | struct matrix_helper<V, It, 0> { | ^~~~~~~~~~~~~~~~~~~~~~~ a.cc:1041:11: error: redefinition of 'template<class V> Vector<V> make_pre_allocated_vector(size_t)' 1041 | Vector<V> make_pre_allocated_vector(size_t N) { | ^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:182:11: note: 'template<class V> Vector<V> make_pre_allocated_vector(size_t)' previously declared here 182 | Vector<V> make_pre_allocated_vector(size_t N) { | ^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:1049:14: error: redefinition of 'template<class V, int N> Matrix<V, N> make_matrix(const std::array<long unsigned int, N>&, V)' 1049 | Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { | ^~~~~~~~~~~ a.cc:190:14: note: 'template<class V, int N> Matrix<V, N> make_matrix(const std::array<long unsigned int, N>&, V)' previously declared here 190 | Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { | ^~~~~~~~~~~ a.cc:1056:12: error: redefinition of 'struct internal::MappedIterator<Iterator, F>' 1056 | struct MappedIterator { | ^~~~~~~~~~~~~~ a.cc:197:12: note: previous definition of 'struct internal::MappedIterator<Iterator, F>' 197 | struct MappedIterator { | ^~~~~~~~~~~~~~ a.cc:1077:12: error: redefinition of 'struct internal::FilteredIterator<Iterator, P>' 1077 | struct FilteredIterator { | ^~~~~~~~~~~~~~~~ a.cc:218:12: note: previous definition of 'struct internal::FilteredIterator<Iterator, P>' 218 | struct FilteredIterator { | ^~~~~~~~~~~~~~~~ a.cc:1126:12: error: redefinition of 'struct internal::FlattenedIterator<Iterator, ElementIterator>' 1126 | struct FlattenedIterator { | ^~~~~~~~~~~~~~~~~ a.cc:267:12: note: previous definition of 'struct internal::FlattenedIterator<Iterator, ElementIterator>' 267 | struct FlattenedIterator { | ^~~~~~~~~~~~~~~~~ a.cc:1206:8: error: redefinition of 'struct Container<Iterator>' 1206 | struct Container { | ^~~~~~~~~ a.cc:347:8: note: previous definition of 'struct Container<Iterator>' 347 | struct Container { | ^~~~~~~~~ a.cc:1219:6: error: redefinition of 'template<class C, class F> auto iterator_map(const C&, F)' 1219 | auto iterator_map(const C &c, F function) { | ^~~~~~~~~~~~ a.cc:360:6: note: 'template<class C, class F> auto iterator_map(const C&, F)' previously declared here 360 | auto iterator_map(const C &c, F function) { | ^~~~~~~~~~~~ a.cc:1227:6: error: redefinition of 'template<class C, class P> auto iterator_filter(const C&, P)' 1227 | auto iterator_filter(const C &c, P predicate) { | ^~~~~~~~~~~~~~~ a.cc:368:6: note: 'template<class C, class P> auto iterator_filter(const C&, P)' previously declared here 368 | auto iterator_filter(const C &c, P predicate) { | ^~~~~~~~~~~~~~~ a.cc:1235:6: error: redefinition of 'template<class C> auto iterator_flatten(const C&)' 1235 | auto iterator_flatten(const C &c) { | ^~~~~~~~~~~~~~~~ a.cc:376:6: note: 'template<class C> auto iterator_flatten(const C&)' previously declared here 376 | auto iterator_flatten(const C &c) { | ^~~~~~~~~~~~~~~~ a.cc:1245:15: error: redefinition of 'template<class F, class S> std::istream& operator>>(std::istream&, std::pair<_T1, _T2>&)' 1245 | std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { | ^~~~~~~~ a.cc:386:15: note: 'template<class F, class S> std::istream& operator>>(std::istream&, std::pair<_T1, _T2>&)' previously declared here 386 | std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { | ^~~~~~~~ a.cc:1251:15: error: redefinition of 'template<class ... Args> std::istream& operator>>(std::istream&, std::tuple<_UTypes ...>&)' 1251 | std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { | ^~~~~~~~ a.cc:392:15: note: 'template<class ... Args> std::istream& operator>>(std::istream&, std::tuple<_UTypes ...>&)' previously declared here 392 | std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { | ^~~~~~~~ a.cc:1257:3: error: redefinition of 'template<class T> T read()' 1257 | T read() { | ^~~~ a.cc:398:3: note: 'template<class T> T read()' previously declared here 398 | T read() { | ^~~~ a.cc:1263:12: error: redefinition of 'template<class F, class S> std::pair<_T1, _T2> read()' 1263 | pair<F, S> read() { | ^~~~ a.cc:404:12: note: 'template<class F, class S> std::pair<_T1, _T2> read()' previously declared here 404 | pair<F, S> read() { | ^~~~ a.cc:1269:28: error: redefinition of 'template<class T1, class T2, class T3, class ... Args> std::tuple<T1, T2, T3, Args ...> read()' 1269 | tuple<T1, T2, T3, Args...> read() { | ^~~~ a.cc:410:28: note: 'template<class T1, class T2, class T3, class ... Args> std::tuple<T1, T2, T3, Args ...> read()' previously declared here 410 | tuple<T1, T2, T3, Args...> read() { | ^~~~ a.cc:1275:11: error: redefinition of 'template<class T, class F> Vector<V> read(usize, F)' 1275 | Vector<T> read(const usize length, F r) { | ^~~~ a.cc:416:11: note: 'template<class T, c
s582478271
p03839
C++
#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i,n) for( int i = 0; i < n; i++ ) #define rrep(i,n) for( int i = n; i >= 0; i-- ) #define REP(i,s,t) for( int i = s; i <= t; i++ ) #define RREP(i,s,t) for( int i = s; i >= t; i-- ) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 #define int long long signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; int a[N]; rep(i, N) cin >> a[i]; int ans = 0; int tmp = 0; rep(i, N - K) tmp += max(0, a[i]); int left = 0; rep(i, K) left += a[N - K + i]; ans = max(ans, tmp + max(0, left)); rep(i, N - K) { //cout << tmp << " " << left << " " << ans << endl; //cout << N - K - i - 1 << " " << N - i - 1 << endl; left = left + a[N - K - i - 1] - a[N - i - 1]; tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); ans = max(ans, tmp + max(0, left)); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:24:33: error: no matching function for call to 'max(int, long long int&)' 24 | rep(i, N - K) tmp += max(0, a[i]); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:24:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 24 | rep(i, N - K) tmp += max(0, a[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:24:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 24 | rep(i, N - K) tmp += max(0, a[i]); | ~~~^~~~~~~~~ a.cc:27:33: error: no matching function for call to 'max(int, long long int&)' 27 | ans = max(ans, tmp + max(0, left)); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:27:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 27 | ans = max(ans, tmp + max(0, left)); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:27:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 27 | ans = max(ans, tmp + max(0, left)); | ~~~^~~~~~~~~ a.cc:32:32: error: no matching function for call to 'max(int, long long int&)' 32 | tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:32: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 32 | tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 32 | tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~ a.cc:32:59: error: no matching function for call to 'max(int, long long int&)' 32 | tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:59: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 32 | tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:59: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 32 | tmp = tmp - max(0, a[N - K - i - 1]) + max(0, a[N - i - 1]); | ~~~^~~~~~~~~~~~~~~~~ a.cc:33:41: error: no matching function for call to 'max(int, long long int&)' 33 | ans = max(ans, tmp + max(0, left)); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:33:41: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 33 | ans = max(ans, tmp + max(0, left)); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:33:41: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 33 | ans = max(ans, tmp + max(0, left)); | ~~~^~~~~~~~~
s813411929
p03839
C++
10 5 5 -4 -5 -8 -4 7 2 -4 0 7
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 10 5 | ^~
s116676395
p03839
C++
#include <bits/stdc++.h> using namespace std; int N, K; int A[100001]; long long res; long long around, center; int main() { cin >> N >> K; for(int i = 0; i < N; ++i) cin >> A[i]; for(int i = K; i < N; ++i) around += max(0LL, A[i]); for(int i = 0; i < K; ++i) center += A[i]; for(int i = 0; i < N - K; ++i) { res = max(res, around + max(0LL, center)); center -= A[i]; center += A[i + K]; around += max(0LL, A[i]); around -= max(0LL, A[i + K]); } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:43: error: no matching function for call to 'max(long long int, int&)' 12 | for(int i = K; i < N; ++i) around += max(0LL, A[i]); | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:43: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 12 | for(int i = K; i < N; ++i) around += max(0LL, A[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:12:43: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 12 | for(int i = K; i < N; ++i) around += max(0LL, A[i]); | ~~~^~~~~~~~~~~ a.cc:17:18: error: no matching function for call to 'max(long long int, int&)' 17 | around += max(0LL, A[i]); around -= max(0LL, A[i + K]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:17:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 17 | around += max(0LL, A[i]); around -= max(0LL, A[i + K]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:17:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 17 | around += max(0LL, A[i]); around -= max(0LL, A[i + K]); | ~~~^~~~~~~~~~~ a.cc:17:44: error: no matching function for call to 'max(long long int, int&)' 17 | around += max(0LL, A[i]); around -= max(0LL, A[i + K]); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:17:44: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 17 | around += max(0LL, A[i]); around -= max(0LL, A[i + K]); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:17:44: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 17 | around += max(0LL, A[i]); around -= max(0LL, A[i + K]); | ~~~^~~~~~~~~~~~~~~
s891641852
p03839
C++
#include <bits/stdc++.h> using namespace std; int N, K; long long res, sub; int main() { cin >> N >> K; for(int i = 0; i < N; ++i) { int a; cin >> a; if(i < K && (N - i) <= K) sub += a; else res += min(0, a); } res += min(0, sub); cout << res; }
a.cc: In function 'int main()': a.cc:14:13: error: no matching function for call to 'min(int, long long int&)' 14 | res += min(0, sub); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:14:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 14 | res += min(0, sub); | ~~~^~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:14:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 14 | res += min(0, sub); | ~~~^~~~~~~~
s133705469
p03839
C++
#include <iostream> #include <cmath> using namespace std; typedef long long ll; int N,K; ll A[100010] = {0},S[100010] = {0},T[100010] = {0}; int main(){ cin >> N >> K; for(int i=1;i<=N;i++){ cin >> A[i]; S[i] = S[i-1] + A[i]; T[i] = T[i-1] + max(0,A[i]); } ll ans = 0; for(int i=1;i<=N-K+1;i++){ ans = max(ans,max(T[i-1] + S[i+K-1]-S[i-1] + T[N]-T[i+K-1], T[i-1] + T[N]-T[i+K-1])); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:14:36: error: no matching function for call to 'max(int, ll&)' 14 | T[i] = T[i-1] + max(0,A[i]); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:14:36: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 14 | T[i] = T[i-1] + max(0,A[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
s724557672
p03839
C++
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_fast32_t; using int64 = int_fast64_t; using uint64 = uint_fast64_t; using PII = pair<int32, int32>; using PLL = pair<int64, int64>; const double eps = 1e-10; template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;} template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;} const int64 mod = 1e9+7; int main(void){ int32 N; int32 K; vector<int64> a, sum, l, r; cin >> N >> K; a.resize(N); sum.resize(N+1, 0); l.resize(N+1, 0); r.resize(N+1, 0); REP(i, N) cin >> a[i]; REP(i, N){ sum[i+1] += sum[i]+a[i]; l[i+1] += l[i]+max(0LL, a[i]); } for(int32 i = N-1;i >= 0;i--){ r[i] += r[i+1]+max(0LL, a[i]); } int64 res = -INF_LL; REP(i, N-K+1){ chmax(res, l[i]+max(0LL, sum[i+K]-sum[i])+r[i+K]); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:38:35: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&)' 38 | l[i+1] += l[i]+max(0LL, a[i]); | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:38:35: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'}) 38 | l[i+1] += l[i]+max(0LL, a[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:38:35: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 38 | l[i+1] += l[i]+max(0LL, a[i]); | ~~~^~~~~~~~~~~ a.cc:41:35: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&)' 41 | r[i] += r[i+1]+max(0LL, a[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:41:35: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'}) 41 | r[i] += r[i+1]+max(0LL, a[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:41:35: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | r[i] += r[i+1]+max(0LL, a[i]); | ~~~^~~~~~~~~~~ a.cc:45:36: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)' 45 | chmax(res, l[i]+max(0LL, sum[i+K]-sum[i])+r[i+K]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:45:36: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'}) 45 | chmax(res, l[i]+max(0LL, sum[i+K]-sum[i])+r[i+K]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:45:36: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 45 | chmax(res, l[i]+max(0LL, sum[i+K]-sum[i])+r[i+K]); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s099290790
p03839
C++
# include <iostream> # include <algorithm> #include <array> # include <cassert> #include <cctype># include <iostream> # include <algorithm> #include <array> # include <cassert> #include <cctype> #include <climits> #include <numeric> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr long long MOD = 1000000000 + 7; constexpr long long INF = 1e17 - 10; const double PI = acos(-1); typedef pair<LL, LL> Pll; typedef pair<LL, pair<LL, LL>> Ppll; typedef pair<LL, pair<LL, bitset<100001>>> Pbll; typedef pair<LL, pair<LL, vector<LL>>> Pvll; typedef pair<LL, LL> Vec2; struct Tll { LL first, second, third; }; typedef pair<LL, Tll> Ptll; #define rep(i,rept) for(LL i=0;i<rept;i++) #define Mfor(i,mf) for(LL i=mf-1;i>=0;i--) int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }; struct Edge { LL to, cost; }; LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; bool flag; int main() { cin >> n >> m; t[0] = 0; rep(i, n) { w = 0; cin >> a[i]; if (a[i] < 0) t[i + 1] = -a[i]; t[i + 1] += t[i]; if (a[i] > 0)sum += a[i]; if (i >= m) { s = min(s, t[i + 1] - t[i - m + 1]); } if (a[i] > 0) { h++, k = 0; } else if (a[i] < 0) { k++, h = 0; } else { k++, h++; } if (k == m || h == m)flag = 1; } cout << (flag == 1 ? sum : sum - s) << endl; return 0; } #include <climits> #include <numeric> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr long long MOD = 1000000000 + 7; constexpr long long INF = 1e17 - 10; const double PI = acos(-1); typedef pair<LL, LL> Pll; typedef pair<LL, pair<LL, LL>> Ppll; typedef pair<LL, pair<LL, bitset<100001>>> Pbll; typedef pair<LL, pair<LL, vector<LL>>> Pvll; typedef pair<LL, LL> Vec2; struct Tll { LL first, second, third; }; typedef pair<LL, Tll> Ptll; #define rep(i,rept) for(LL i=0;i<rept;i++) #define Mfor(i,mf) for(LL i=mf-1;i>=0;i--) int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }; struct Edge { LL to, cost; }; LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; bool flag; int main() { cin >> n >> m; rep(i, n) { w = 0; cin >> a[i]; if (a[i] > 0)sum += a[i]; if (i >= m) { rep(j, m) { if (a[i - j] <= 0)w -= a[i - j]; } s = min(w, s); } if (a[i] > 0) { h++, k = 0; } else if (a[i] < 0) { k++, h = 0; } else { k++, h++; } if (k == m || h == m)flag = 1; } cout << (flag == 1 ? sum : sum - s) << endl; return 0; }
a.cc:5:18: warning: extra tokens at end of #include directive 5 | #include <cctype># include <iostream> | ^ a.cc:102:21: error: redefinition of 'constexpr const long long int MOD' 102 | constexpr long long MOD = 1000000000 + 7; | ^~~ a.cc:37:21: note: 'constexpr const long long int MOD' previously defined here 37 | constexpr long long MOD = 1000000000 + 7; | ^~~ a.cc:103:21: error: redefinition of 'constexpr const long long int INF' 103 | constexpr long long INF = 1e17 - 10; | ^~~ a.cc:38:21: note: 'constexpr const long long int INF' previously defined here 38 | constexpr long long INF = 1e17 - 10; | ^~~ a.cc:104:14: error: redefinition of 'const double PI' 104 | const double PI = acos(-1); | ^~ a.cc:39:14: note: 'const double PI' previously defined here 39 | const double PI = acos(-1); | ^~ a.cc:110:8: error: redefinition of 'struct Tll' 110 | struct Tll { LL first, second, third; }; | ^~~ a.cc:45:8: note: previous definition of 'struct Tll' 45 | struct Tll { LL first, second, third; }; | ^~~ a.cc:114:5: error: redefinition of 'int dx [4]' 114 | int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }; | ^~ a.cc:49:5: note: 'int dx [4]' previously defined here 49 | int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }; | ^~ a.cc:114:30: error: redefinition of 'int dy [4]' 114 | int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }; | ^~ a.cc:49:30: note: 'int dy [4]' previously defined here 49 | int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }; | ^~ a.cc:115:8: error: redefinition of 'struct Edge' 115 | struct Edge { LL to, cost; }; | ^~~~ a.cc:50:8: note: previous definition of 'struct Edge' 50 | struct Edge { LL to, cost; }; | ^~~~ a.cc:116:4: error: redefinition of 'LL h' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:4: note: 'LL h' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:7: error: redefinition of 'LL w' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:7: note: 'LL w' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:10: error: redefinition of 'LL n' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:10: note: 'LL n' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:13: error: redefinition of 'LL m' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:13: note: 'LL m' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:16: error: redefinition of 'LL s' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:16: note: 'LL s' previously defined here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:23: error: redefinition of 'LL k' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:23: note: 'LL k' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:26: error: redefinition of 'LL sum' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^~~ a.cc:51:26: note: 'LL sum' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^~~ a.cc:116:31: error: redefinition of 'LL ans' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^~~ a.cc:51:31: note: 'LL ans' previously defined here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^~~ a.cc:116:40: error: redefinition of 'LL t [100001]' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:40: note: 'LL t [100001]' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:116:51: error: redefinition of 'LL a [100000]' 116 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:51:51: note: 'LL a [100000]' previously declared here 51 | LL h, w, n, m, s=INF, k, sum, ans = 0, t[100001], a[100000]; | ^ a.cc:117:8: error: redefinition of 'std::string YES' 117 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~~ a.cc:52:8: note: 'std::string YES' previously declared here 52 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~~ a.cc:117:21: error: redefinition of 'std::string Yes' 117 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~~ a.cc:52:21: note: 'std::string Yes' previously declared here 52 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~~ a.cc:117:34: error: redefinition of 'std::string NO' 117 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~ a.cc:52:34: note: 'std::string NO' previously declared here 52 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~ a.cc:117:45: error: redefinition of 'std::string No' 117 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~ a.cc:52:45: note: 'std::string No' previously declared here 52 | string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; | ^~ a.cc:118:6: error: redefinition of 'bool flag' 118 | bool flag; | ^~~~ a.cc:53:6: note: 'bool flag' previously declared here 53 | bool flag; | ^~~~ a.cc:119:5: error: redefinition of 'int main()' 119 | int main() { | ^~~~ a.cc:54:5: note: 'int main()' previously defined here 54 | int main() { | ^~~~
s431314400
p03839
C++
#include<iostream> #include<algorithm> #include<string> #define LL long long int N, K; LL ans; LL a[100010]; bool D[100010]; int main() { std::cin >> N >> K; for (int i = 0; i < N; i++) { std::cin >> a[i]; } for (int i = 0; i < N - K; i++) { if (a[i] > 0) { ans += a[i]; } } LL add = 0; LL bdd = 0; for (int i = N - K; i < N; i++) { if (D[i])add += a[i]; bdd += a[i]; } ans += std::max(add, bdd, 0); std::cout << ans << std::endl; }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = int]': a.cc:25:17: required from here 25 | ans += std::max(add, bdd, 0); | ~~~~~~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~
s425506308
p03839
C++
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define each(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define mp(a,b) make_pair(a,b) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define maxch(x,y) x=max(x,y) #define minch(x,y) x=min(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) #define exist(x,y) (find(all(x),y)!=x.end()) #define bcnt(x) bitset<32>(x).count() typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<P, int> PPI; typedef pair<ll, ll> PL; typedef pair<P, ll> PPL; #define INF INT_MAX/3 #define MAX_N 1000 ll n,k; ll a[111111]; ll sum[111111]; ll psum[111111]; int main(){ cin.sync_with_stdio(false); cin>>n>>k; rep(i,n)cin>>a[i]; rep(i,n){ sum[i+1]=sum[i]+a[i]; psum[i+1]=psum[i]+max(0LL,a[i]); } ll res=0; rep(i,n-k+1){ maxch(res,max(0LL,sum[i]+sum[n]-sum[i+k]); } cout<<res<<endl; return 0; }
a.cc:49:2: error: unterminated argument list invoking macro "maxch" 49 | } | ^ a.cc: In function 'int main()': a.cc:45:5: error: 'maxch' was not declared in this scope 45 | maxch(res,max(0LL,sum[i]+sum[n]-sum[i+k]); | ^~~~~ a.cc:45:10: error: expected '}' at end of input 45 | maxch(res,max(0LL,sum[i]+sum[n]-sum[i+k]); | ^ a.cc:44:15: note: to match this '{' 44 | rep(i,n-k+1){ | ^ a.cc:45:10: error: expected '}' at end of input 45 | maxch(res,max(0LL,sum[i]+sum[n]-sum[i+k]); | ^ a.cc:35:11: note: to match this '{' 35 | int main(){ | ^
s317703765
p03839
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N, K; cin >> N >> K; vector<ll> a(N), sum(N + 1), good(N + 1); for (int i = 0; i < N; i++) { cin >> a[i]; sum[i + 1] = sum[i] + a[i]; good[i + 1] = good[i] + max(a[i], 0); } ll res = 0; for (int i = 0; i <= N - K; i++) { res = max(res, good[N] - good[i + K] + good[i] - good[0]); res = max(res, good[N] - good[i + K] + good[i] - good[0] + sum[i + K] - sum[i]); } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:44: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)' 13 | good[i + 1] = good[i] + max(a[i], 0); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:13:44: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 13 | good[i + 1] = good[i] + max(a[i], 0); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:13:44: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 13 | good[i + 1] = good[i] + max(a[i], 0); | ~~~^~~~~~~~~
s078962319
p03839
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <stdio.h> #include <string.h> #include <math.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int64_t> s(n + 1), t(n + 1); for (int i = 0; i < n; i++) { int a; cin >> a; s[i + 1] = s[i] + a; t[i + 1] = t[i] + (a < 0 ? 0 : a); } int64_t r = 0; for (int i = 0; i <= n - k; i++) { int64_t u = max(s[i + k] - s[i], 0LL); u += t[i] - t[0]; u += t[n] - t[i + k]; r = max(r, u); } cout << r << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:24: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type, long long int)' 27 | int64_t u = max(s[i + k] - s[i], 0LL); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:27:24: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 27 | int64_t u = max(s[i + k] - s[i], 0LL); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:27:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 27 | int64_t u = max(s[i + k] - s[i], 0LL); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s368839219
p03839
C++
// 簡易競プロテンプレ #include <bits/stdc++.h> #define ll long long using namespace std; ll n, k; ll a[114514]; int main(void){ cin >> n >> k; for(int i=0;i<n;i++) cin >> a[i]; ll ans = 0, ans2 = 0; for(int i=0;i<n;i++){ if (i>=k && a[i]>0) ans += a[i]; if (i<k) ans += a[i]; if (i+1==k) ans = max(ans, 0); } for(int i=n-1;i>=0;i--){ if (i<n-k && a[i]>0) ans2 += a[i]; if (i>=n-k) ans2 += a[i]; if (i==n-k) ans2 = max(ans2, 0); } cout << max(ans, ans2) << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:24: error: no matching function for call to 'max(long long int&, int)' 14 | if (i+1==k) ans = max(ans, 0); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:14:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 14 | if (i+1==k) ans = max(ans, 0); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:14:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 14 | if (i+1==k) ans = max(ans, 0); | ~~~^~~~~~~~ a.cc:19:25: error: no matching function for call to 'max(long long int&, int)' 19 | if (i==n-k) ans2 = max(ans2, 0); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:19:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 19 | if (i==n-k) ans2 = max(ans2, 0); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 19 | if (i==n-k) ans2 = max(ans2, 0); | ~~~^~~~~~~~~
s304830080
p03839
C++
#include <bits/stdc++.h> using namespace std; typedef long long int lli; int main(){ int n,k; scanf("%d%d",&n,&k); if(n<k){ printf("0"); return 0; } lli qsp[n+1],qsn[n+1],a; for(int i=1;i<=n;++i){ scanf("%lld",&a); qsp[i]=qsp[i-1]; qsn[i]=qsn[i-1]; if(a>0) qsp[i]+=a; else qsn[i]+=a; } lli min=qsp[k],max=qsp[k]+qsn[k],maxidx=k; for(int i=k;i<=n;++i){ if(qsp[i]-qsp[i-k]<min) min=qsp[i]-qsp[i-k]; if(max<qsp[i]-qsp[i-k]+qsn[i]-qsn[i-k]){ max=qsp[i]-qsp[i-k]+qsn[i]-qsn[i-k]; maxidx=i; } } if(max<0) printf("%lld",qs[n]-min); else printf("%lld",qs[n]+qsn[maxidx]-qsn[maxidx-k]); } /* 10 5 5 -4 -5 -8 -4 7 2 -4 0 7 */
a.cc: In function 'int main()': a.cc:31:31: error: 'qs' was not declared in this scope; did you mean 'qsn'? 31 | printf("%lld",qs[n]-min); | ^~ | qsn a.cc:33:31: error: 'qs' was not declared in this scope; did you mean 'qsn'? 33 | printf("%lld",qs[n]+qsn[maxidx]-qsn[maxidx-k]); | ^~ | qsn
s423508965
p03839
C++
#include<bits/stdc++.h> using namespace std; long long qsum[100010]; long long best[100010]; int main() { int n,k; long long a; cin >> n >> k; for ( int c=1 ; c<=n ; c++ ) { cin >> a; qsum[c] = qsum[c-1] + a; if ( a > 0 ) best[c] = best[c-1] + a; else best[c] = best[c-1]; } long long ans = 0; for ( int i=1 ; i<=n-k+1 ; i++) { long long other = best[i-1] + best[n] - best[i+k-1]; //cout << other << endl; if ( qsum[i+k-1] - qsum[i-1] > 0 ) other += qsum[i+k-1] - qsum[i-1]; ans = max ( ans , other); } cout << ans; } #include<bits/stdc++.h> using namespace std; long long qsum[100010]; long long best[100010]; int main() { int n,k; long long a; cin >> n >> k; for ( int c=1 ; c<=n ; c++ ) { cin >> a; qsum[c] = qsum[c-1] + a; if ( a > 0 ) best[c] = best[c-1] + a; else best[c] = best[c-1]; } long long ans = 0; for ( int i=1 ; i<=n-k+1 ; i++) { long long other = best[i-1] + best[n] - best[i+k-1]; //cout << other << endl; if ( qsum[i+k-1] - qsum[i-1] > 0 ) other += qsum[i+k-1] - qsum[i-1]; ans = max ( ans , other); } cout << ans; }
a.cc:34:11: error: redefinition of 'long long int qsum [100010]' 34 | long long qsum[100010]; | ^~~~ a.cc:5:11: note: 'long long int qsum [100010]' previously declared here 5 | long long qsum[100010]; | ^~~~ a.cc:36:11: error: redefinition of 'long long int best [100010]' 36 | long long best[100010]; | ^~~~ a.cc:7:11: note: 'long long int best [100010]' previously declared here 7 | long long best[100010]; | ^~~~ a.cc:38:5: error: redefinition of 'int main()' 38 | int main() { | ^~~~ a.cc:9:5: note: 'int main()' previously defined here 9 | int main() { | ^~~~
s090226084
p03839
C++
#include<iostream> #include<iomanip> #include<map> #include<unordered_map> #include<set> #include<unordered_set> #include<vector> #include<array> #include<string> #include<stack> #include<queue> #include<algorithm> #include<cassert> #include<functional> #include<random> #include<complex> #include<bitset> #include<chrono> //#include<boost/multiprecision/cpp_int.hpp> #define int int64_t #define uint uint64_t #define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++) #define rep(i, a) REP(i, 0, a) #define SZ(X) ((int64_t)((X).size())) #define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define HAS(a, x) (a.find(x) != a.end()) #define Min(x) *min_element(ALL(x)) #define Max(x) *max_element(ALL(x)) #define Unique(L) (L.erase(unique(ALL(L)), L.end())) #define intmax (std::numeric_limits<int64_t>::max() / 4) #define doublemax (std::numeric_limits<double>::max() / 4) using namespace std; //typedef boost::multiprecision::cpp_int bigint; const double EPS = 1e-9; const double PI = acos(-1.0); //sort(ALL(v),greater<int>()); signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; vector<int>a(N); rep(i, N)cin >> a[i]; int ksum = 0; rep(i, K)ksum += a[i]; int ksummax = ksum, ksmindex = 0; REP(i, K, N) { ksum += a[i]; ksum -= a[i - K]; if (ksummax < ksum) { ksummax = ksum; ksmindex = i-K+1; } } int ans = max(ksummax,0); rep(i, ksmindex)if (0 < a[i])ans += a[i]; REP(i, ksmindex + K, N)if (0 < a[i])ans += a[i]; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:62:22: error: no matching function for call to 'max(int64_t&, int)' 62 | int ans = max(ksummax,0); | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:62:22: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 62 | int ans = max(ksummax,0); | ~~~^~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:12: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:62:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 62 | int ans = max(ksummax,0); | ~~~^~~~~~~~~~~
s322008839
p03839
C++
#include <iostream> #include <cstring> #include <algorithm> #define MAX_N 100000 using namespace std; #define debug(x) cout << #x << "==" << x << endl; //入力 int K; int N; int a[MAX_N + 1]; typedef long long ll; int main() { cin >> N >> K; for(int i = 0; i < N; i++) { cin >> a[i]; } ll cumsum[MAX_N + 1]; ll cumsum_pos[MAX_N + 1]; cumsum[0] = 0; cumsum_pos[0] = 0; for(int i = 1; i < N+1; i++) { cumsum[i] = cumsum[i-1] + a[i-1]; cumsum_pos[i] = cumsum_pos[i-1] + max(0, a[i-1]); } ll mx = 0; for(int i = 0; i < N - K + 1; i++) { ll all_black = cumsum[i+K] - cumsum[i]; ll all_white = 0; ll other = cumsum_pos[i] + (cumsum_pos[N] - cumsum_pos[i+K]) ; mx = max(mx, other + max(black, white)); } cout << mx << endl; return 0; }
a.cc: In function 'int main()': a.cc:43:30: error: 'black' was not declared in this scope 43 | mx = max(mx, other + max(black, white)); | ^~~~~ a.cc:43:37: error: 'white' was not declared in this scope; did you mean 'fwrite'? 43 | mx = max(mx, other + max(black, white)); | ^~~~~ | fwrite
s216295911
p03839
C++
#include <iostream> #include <cstring> #include <algorithm> #define MAX_N 100000 using namespace std; #define debug(x) cout << #x << "==" << x << endl; //入力 int K; int N; int a[MAX_N + 1]; typedef long long ll; int main() { cin >> N >> K; for(int i = 0; i < N; i++) { cin >> a[i]; } ll cumsum[MAX_N + 1]; ll cumsum_pos[MAX_N + 1]; cumsum[0] = 0; cumsum_pos[0] = 0; for(int i = 1; i <= N; i++) { cumsum[i] = cumsum[i-1] + a[i-1]; cumsum_pos[i] = cumsum_pos[i-1] + max(0, a[i-1]); } ll mx = 0; for(int i = 0; i <= N - K; i++) { ll black = cumsum[i+K] - cumsum[i]; ll white = 0; ll other = (cumsum_pos[N-k] - cumsum_pos[i+K-1]) + cumsum_pos[i-1]; mx = max(mx, other + max(black, white)); } cout << mx << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:30: error: 'k' was not declared in this scope 41 | ll other = (cumsum_pos[N-k] - cumsum_pos[i+K-1]) + cumsum_pos[i-1]; | ^
s396109675
p03839
C++
#include <bits/stdc++.h> using namespace std; using namespace placeholders; using ll = long long; class sum_class{ vector<ll> v; public: sum_class(const vector<ll>& vv){ v.resize(vv.size() + 1, 0); partial_sum(begin(vv), end(vv), begin(v) + 1); } ll operator()(const ll x, const ll y){ return v[y+1] - v[x]; } }; int main(){ ll n, k; cin >> n >> k; vector<ll> v(n); for(auto& x : v) cin >> x; vector<ll> pv(n); transform(begin(v), end(v), begin(pv), [](const ll x){ return max(x, 0); }); sum_class sv(v), spv(pv); ll rez = accumulate(begin(v), end(v), 0); for(ll i = 0, j = k-1; j < n; ++i, ++j){ rez = max(rez, spv(0, i-1) + max(sv(i, j), 0) + spv(j+1, n-1)); } cout << rez << endl; return 0; }
a.cc: In lambda function: a.cc:23:74: error: no matching function for call to 'max(const ll&, int)' 23 | transform(begin(v), end(v), begin(pv), [](const ll x){ return max(x, 0); }); | ~~~^~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:23:74: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 23 | transform(begin(v), end(v), begin(pv), [](const ll x){ return max(x, 0); }); | ~~~^~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:23:74: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 23 | transform(begin(v), end(v), begin(pv), [](const ll x){ return max(x, 0); }); | ~~~^~~~~~ a.cc: In function 'int main()': a.cc:30:49: error: no matching function for call to 'max(ll, int)' 30 | rez = max(rez, spv(0, i-1) + max(sv(i, j), 0) + spv(j+1, n-1)); } | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:49: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 30 | rez = max(rez, spv(0, i-1) + max(sv(i, j), 0) + spv(j+1, n-1)); } | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:49: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 30 | rez = max(rez, spv(0, i-1) + max(sv(i, j), 0) + spv(j+1, n-1)); } | ~~~^~~~~~~~~~~~~
s049701594
p03839
C++
#include<cstdio> #include<algorithm> using std::max; const int N=1e5+3; int i,n,k,a[N]; long long x,r,l[N],s[N]; int main() { scanf("%d%d",&n,&k); for(i=1;i<=n;++i) { scanf("%d",a+i); s[i]=s[i-1]+a[i]; l[i]=l[i-1]+max(0,a[i]); } for(i=n;i>=k;x+=max(0,a[i--])) r=max(r,x+l[i-k]+max(0ll,s[i]-s[i-k])); for(i=0;i<20000;++i)for(j=0;j<i;++j); printf("%lld",r); }
a.cc: In function 'int main()': a.cc:18:33: error: 'j' was not declared in this scope 18 | for(i=0;i<20000;++i)for(j=0;j<i;++j); | ^
s746349695
p03839
C++
#include<cstdio> #include<algorithm> using std::max; const int N=1e5+3; int i,n,k,a[N]; long long x,r,l[N],s[N]; int main() { scanf("%d%d",&n,&k); for(i=1;i<=n;++i) { scanf("%d",a+i); s[i]=s[i-1]+a[i]; l[i]=l[i-1]+max(0,a[i]); } for(i=n;i>=k;x+=max(0,a[i--])) r=max(r,x+l[i-k]+max(0,s[i]-s[i-k])); printf("%d",r); }
a.cc: In function 'int main()': a.cc:17:37: error: no matching function for call to 'max(int, long long int)' 17 | r=max(r,x+l[i-k]+max(0,s[i]-s[i-k])); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:17:37: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 17 | r=max(r,x+l[i-k]+max(0,s[i]-s[i-k])); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/algorithm:60: /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:17:37: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 17 | r=max(r,x+l[i-k]+max(0,s[i]-s[i-k])); | ~~~^~~~~~~~~~~~~~~
s731591011
p03839
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define lim 10000007 #define mod 1000000007 #define mp make_pair #define sd(n) scanf("%lld",&n) #define pb push_back #define FIO() freopen("in.txt","r",stdin) #define F first #define S second #define db double #define INF 1e12 #define pd(n) printf("%lld\n",n) #define pdd(n) printf("%.20lf\n",n) #define pii pair<ll,ll> int main() { //FIO(); ll n,k; ll ans=0; cin>>n>>k; ll sum=0; while(n--) { cin>>x; sum+=max(0LL,x); } cout<<sum<<endl; }
a.cc: In function 'int main()': a.cc:27:10: error: 'x' was not declared in this scope 27 | cin>>x; | ^
s223400461
p03839
C++
#include <iostream> #include <vector> using namespace std; typedef long long int ll; int main(void){ // Here your code ! int n,k; cin >> n >> k; vector<ll> a(n+10); vector<ll> rui(n+10); vector<ll> rui2(n+10); for(int i = 1; i <= n; i++){ cin >> a[i]; rui[i] = rui[i-1] + a[i]; if(a[i] > 0) rui2[i] = rui2[i-1] + a[i]; else rui2[i] = rui2[i-1]; } ll res = 0; for(int i = k; i <= n; i++){ int tmp = rui[i] - rui[i-k]; if(tmp < 0) tmp = 0; tmp += rui2[i-k] + rui2[n] - rui2[i]; res = max(tmp,res); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:35:18: error: no matching function for call to 'max(int&, ll&)' 35 | res = max(tmp,res); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:35:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 35 | res = max(tmp,res); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
s871759475
p03839
C++
#include <cstdio> #include <algorithm> #include <iostream> #include <vector> #include <math.h> using namespace std; long long int a[111111]; long long int kuro[111111]; long long int b[111111]; int main(void){ int N,K,x,i,j,k; long long int res,tmp; res=tmp=0; scanf("%d %d",&N,&K); for(i=1;i<=N;i++){ scanf("%d",&a[i]); } for(i=1;i<=K;i++){ kuro[1]+=a[i]; } for(i=2;i<=N-K+1;i++){ kuro[i]=kuro[i-1]+a[i+K-1]-a[i-1]; } b[1]=max(0,a[1]); for(i=2;i<=N;i++){ b[i]=b[i-1]+max(0,a[i]); } for(i=1;i<=N-K+1;i++){ tmp=kuro[i]+b[i-1]+(b[N]-b[i+K-1]); res=max(res,tmp); } for(i=1;i<=N-K+1;i++){ tmp=b[i-1]+(b[N]-b[i+K-1]); res=max(res,tmp); } printf("%lld\n",res); return 0; }
a.cc: In function 'int main()': a.cc:26:11: error: no matching function for call to 'max(int, long long int&)' 26 | b[1]=max(0,a[1]); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:11: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 26 | b[1]=max(0,a[1]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:11: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 26 | b[1]=max(0,a[1]); | ~~~^~~~~~~~ a.cc:28:20: error: no matching function for call to 'max(int, long long int&)' 28 | b[i]=b[i-1]+max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:28:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 28 | b[i]=b[i-1]+max(0,a[i]); | ~~~^~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:28:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 28 | b[i]=b[i-1]+max(0,a[i]); | ~~~^~~~~~~~
s833907721
p03839
C++
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define mp make_pair #define pb push_back #define CLEAR(a) memset(a,0,sizeof a) #define REP(i,n) for(int i=0;i<n;i++) #define FOR(i,a,b) for(int i=a;i<=b;i++) #define fr freopen("input.txt", "r", stdin); #define fw freopen("output.txt", "w", stdout); #define int long long typedef long long LL; typedef pair<int,int> pii; const int MOD = 1e9 + 7; const int MAX = 1e5 + 5; int a[MAX], rghtt[MAX], lfft[MAX], pre[MAX]; main() { //fr; int n, k; cin >> n >> k; FOR(i,1,n) cin >> a[i]; FOR(i,1,n){ pre[i] = pre[i-1] + a[i]; lfft[i] = lfft[i-1] + max(0, a[i]); } for(int i=n;i>=1;i--){ rghtt[i] = rghtt[i+1] + max(0, a[i]); } int ret = 0; for(int i=1;i<=n-k+1;i++){ ret = max(ret, lfft[i-1] + max(0,pre[i+k-1]-pre[i-1]) + rghtt[i+k]); } cout << ret; return 0; }
a.cc:19:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 19 | main() { | ^~~~ a.cc: In function 'int main()': a.cc:27:34: error: no matching function for call to 'max(int, long long int&)' 27 | lfft[i] = lfft[i-1] + max(0, a[i]); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:27:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 27 | lfft[i] = lfft[i-1] + max(0, a[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:27:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 27 | lfft[i] = lfft[i-1] + max(0, a[i]); | ~~~^~~~~~~~~ a.cc:31:36: error: no matching function for call to 'max(int, long long int&)' 31 | rghtt[i] = rghtt[i+1] + max(0, a[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:36: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 31 | rghtt[i] = rghtt[i+1] + max(0, a[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:36: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 31 | rghtt[i] = rghtt[i+1] + max(0, a[i]); | ~~~^~~~~~~~~ a.cc:37:39: error: no matching function for call to 'max(int, long long int)' 37 | ret = max(ret, lfft[i-1] + max(0,pre[i+k-1]-pre[i-1]) + rghtt[i+k]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:37:39: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 37 | ret = max(ret, lfft[i-1] + max(0,pre[i+k-1]-pre[i-1]) + rghtt[i+k]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:37:39: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 37 | ret = max(ret, lfft[i-1] + max(0,pre[i+k-1]-pre[i-1]) + rghtt[i+k]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~
s843381507
p03839
C++
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <queue> #include <algorithm> #include <utility> #include <cmath> #define INF_LL 9000000000000000000 #define INF 2000000000 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) using namespace std; typedef long long ll; typedef pair<int, int> PII; class Union_find{ private: vector<int> par; vector<int> rank; int n; public: Union_find(int a){ n = a; for(int i = 0;i < n;i++){ par.push_back(i); rank.push_back(0); } } int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; }else{ par[y] = x; if(rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y){ return find(x) == find(y); } }; int main(void){ int n, k; int a[100000]; int sum_k[100000]; int res = 0; cin >> n >> k; memset(sum_k, 0, sizeof(sum_k)); REP(i, n){ cin >> a[i]; for(int j = max(0, i-k+1);j <= i;j++){ sum_k[j] += a[i]; } } REP(i, n-k+1){ int tmp = max(0, sum_k[i]); REP(j, i){ if(a[j] > 0) tmp+= a[j]; } for(int j = i+k;j < n;j++){ if(a[j] > 0) tmp += a[j]; } res = max(res, tmp); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:69:9: error: 'memset' was not declared in this scope 69 | memset(sum_k, 0, sizeof(sum_k)); | ^~~~~~ a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include <cmath> +++ |+#include <cstring> 9 |
s704507435
p03839
C++
10 5 5 -4 -5 -8 -4 7 2 -4 0 7
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 10 5 | ^~
s975667603
p03839
C++
#include <iostream> #include <vector> #include <numeric> #include <limits> #define int long long signed main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, k; std::cin >> n >> k; std::vector<int> pts(n), positive(n); for (int i = 0; i < n; i++) { std::cin >> pts[i]; positive[i] = std::max(0ll, pts[i]); } std::vector<int> accum = {0}, pos_accum = {0}; std::partial_sum(std::begin(pts), std::end(pts), std::back_inserter(accum)); std::partial_sum(std::begin(positive), std::end(positive), std::back_inserter(pos_accum)); int result = std::numeric_limits<int>::min() / 2; for (int i = 0; i < n - k + 1; i++) { int range_sum = accum[i + k] - accum[i], other_sum = pos_accum[n] - pos_accum[i + k] + pos_accum[i]; result = std::max({result, range_sum + other_sum, other_sum}); } std::cout << result << std::endl; }
a.cc: In function 'int main()': a.cc:24:22: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 24 | result = std::max({result, range_sum + other_sum, other_sum}); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided
s113146690
p03839
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,k; long long int a[100000]; cin >> n >> k; for(int i = 0;i < n;i++) cin >> a[i]; sort(a,a + n,greater<long long int>()); long long int res = 0; for(int i = 0;i < n;i++){ if(a[i] >= 0) res += a[i]; else{ if(k % 2 == 1) res += a[i]; break; } } cout << max(0,res) << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:20: error: no matching function for call to 'max(int, long long int&)' 19 | cout << max(0,res) << endl; | ~~~^~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:19:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 19 | cout << max(0,res) << endl; | ~~~^~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:19:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 19 | cout << max(0,res) << endl; | ~~~^~~~~~~
s821312331
p03839
C++
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long int64; const int64 INF = 1LL << 58; struct CumulativeSum { vector< int64 > data; CumulativeSum(int sz) : data(++sz, 0) {}; inline void add(int k, int x) { data[k] += x; } void build() { for(int i = 1; i < data.size(); i++) { data[i] += data[i - 1]; } } inline int64 query(int k) { if(k < 0) return (0); return (data[min(k, (int) data.size() - 1)]); } }; CumulativeSum sum(100000), sum2(100000); int dp[100000][3]; int A[100000]; int N, K; int64 sums1(int l, int r) { return (sum.query(r) - sum.query(l)); } int64 sums2(int l, int r) { return (sum2.query(r) - sum2.query(l)); } signed main() { cin >> N >> K; int64 all = 0; for(int i = 0; i < N; i++) { cin >> A[i]; sum.add(i, max(0, A[i])); sum2.add(i, A[i]); all += A[i]; } sum.build(); sum2.build(); int64 ret = 0; for(int i = 0; i <= N - K; i++) { ret = max(ret, sums1(-1, i - 1) + sums1(i + K - 1, N - 1) + sums2(i - 1, i + K - 1)); ret = max(ret, sums2(-1, i - 1) + sums2(i + K - 1, N - 1) + sums1(i - 1, i + K - 1)); } cout << ret << endl; }
a.cc: In function 'int main()': a.cc:56:19: error: no matching function for call to 'max(int, long long int&)' 56 | sum.add(i, max(0, A[i])); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:56:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 56 | sum.add(i, max(0, A[i])); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:56:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 56 | sum.add(i, max(0, A[i])); | ~~~^~~~~~~~~
s184537411
p03839
C++
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long int64; const int64 INF = 1LL << 58; struct CumulativeSum { vector< int64 > data; CumulativeSum(int sz) : data(++sz, 0) {}; inline void add(int k, int x) { data[k] += x; } void build() { for(int i = 1; i < data.size(); i++) { data[i] += data[i - 1]; } } inline int64 query(int k) { if(k < 0) return (0); return (data[min(k, (int) data.size() - 1)]); } }; CumulativeSum sum(100000), sum2(100000); int dp[100000][3]; int A[100000]; int N, K; int64 sums1(int l, int r) { return (sum.query(r) - sum.query(l)); } int64 sums2(int l, int r) { return (sum2.query(r) - sum2.query(l)); } int64 main() { cin >> N >> K; int64 all = 0; for(int i = 0; i < N; i++) { cin >> A[i]; sum.add(i, max(0, A[i])); sum2.add(i, A[i]); all += A[i]; } sum.build(); sum2.build(); int64 ret = 0; for(int i = 0; i <= N - K; i++) { ret = max(ret, sums1(-1, i - 1) + sums1(i + K - 1, N - 1) + sums2(i - 1, i + K - 1)); ret = max(ret, sums2(-1, i - 1) + sums2(i + K - 1, N - 1) + sums1(i - 1, i + K - 1)); } cout << ret << endl; }
a.cc:49:1: error: '::main' must return 'int' 49 | int64 main() | ^~~~~ a.cc: In function 'int main()': a.cc:56:19: error: no matching function for call to 'max(int, long long int&)' 56 | sum.add(i, max(0, A[i])); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:56:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 56 | sum.add(i, max(0, A[i])); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:56:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 56 | sum.add(i, max(0, A[i])); | ~~~^~~~~~~~~
s974322126
p03839
C++
#include <bits/stdc++.h> #define fin(i, n) for (int i = 0; i < n; i++) #define fin2(i, a, b) for (int i = a; i < b; i++) #define ll long long using namespace std; int main() { ll n, k; scanf("%lld%lld", &n, &k); vector<ll> t(n); fin(i, n) scanf("%lld", &t[i]); ll sum = 0; fin(i, k) sum += t[i]; ll summ = sum; ll ind = 0; fin2(i, k, n) { sum += t[i] - t[i - k]; if (sum > summ) { summ = sum; ind = i - k + 1; } } ll sump = sum; fin(i, n) if (i < ind || i >= ind + k) sump += max(0, t[i]); cout << max(0, sump); }
a.cc: In function 'int main()': a.cc:25:59: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 25 | fin(i, n) if (i < ind || i >= ind + k) sump += max(0, t[i]); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:25:59: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 25 | fin(i, n) if (i < ind || i >= ind + k) sump += max(0, t[i]); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:25:59: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 25 | fin(i, n) if (i < ind || i >= ind + k) sump += max(0, t[i]); | ~~~^~~~~~~~~ a.cc:26:20: error: no matching function for call to 'max(int, long long int&)' 26 | cout << max(0, sump); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 26 | cout << max(0, sump); | ~~~^~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 26 | cout << max(0, sump); | ~~~^~~~~~~~~
s410408514
p03840
C++
#include<bits/stdc++.h> using namespace std; const int N = 2e5+7; int ans[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); long long I, O, J, L, temp; cin>>I>>O>>temp>>J>>L>>temp>>temp; long long ans = O + (I/2)*2 + (J/2)*2 + (L/2)*2; if (I && J && L) { I--, J--, L--; ans = min( O + (I/2)*2 + (J/2)*2 + (L/2)*2 + 3); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:16:18: error: no matching function for call to 'min(long long int)' 16 | ans = min( O + (I/2)*2 + (J/2)*2 + (L/2)*2 + 3); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 16 | ans = min( O + (I/2)*2 + (J/2)*2 + (L/2)*2 + 3); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate expects 2 arguments, 1 provided
s254884435
p03840
C
#include <bits/stdc++.h> using namespace std; int ai, ao, at, al, aj, as, az, k; int main() { cin >> ai >> ao >> at >> al >> aj >> as >> az; k += ao; k += ai - ai % 2; ai = ai % 2; k += min(min(al, aj), ai) * 3; int minn = min(min(al, aj), ai); al -= minn; aj -= minn; ai -= minn; k += aj / 2 * 2; k += al / 2 * 2; cout << k; return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s965451151
p03840
C
#include <iostream> using namespace std; int ai, ao, at, al, aj, as, az, k; int main() { cin >> ai >> ao >> at >> al >> aj >> as >> az; k += ao; k += ai - ai % 2; ai = ai % 2; k += min(min(al, aj), ai) * 3; int minn = min(min(al, aj), ai); al -= minn; aj -= minn; ai -= minn; k += aj / 2 * 2; k += al / 2 * 2; cout << k; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s423381491
p03840
Java
import java.util.*; import java.io.*; import java.math.*; public class Main{ //Don't have to see. start------------------------------------------ static class InputIterator{ ArrayList<String> inputLine = new ArrayList<String>(1024); int index = 0; int max; String read; InputIterator(){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ while((read = br.readLine()) != null){ inputLine.add(read); } }catch(IOException e){} max = inputLine.size(); } boolean hasNext(){return (index < max);} String next(){ if(hasNext()){ return inputLine.get(index++); }else{ throw new IndexOutOfBoundsException("There is no more input"); } } } static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>(); static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem. static PrintWriter out = new PrintWriter(System.out); static void flush(){out.flush();} static void myout(Object t){out.println(t);} static void myerr(Object t){System.err.print("debug:");System.err.println(t);} static String next(){return ii.next();} static boolean hasNext(){return ii.hasNext();} static int nextInt(){return Integer.parseInt(next());} static long nextLong(){return Long.parseLong(next());} static double nextDouble(){return Double.parseDouble(next());} static ArrayList<String> nextStrArray(){return myconv(next(), 8);} static ArrayList<String> nextCharArray(){return myconv(next(), 0);} static ArrayList<Integer> nextIntArray(){ ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size()); for(int i = 0; i < input.size(); i++){ ret.add(Integer.parseInt(input.get(i))); } return ret; } static ArrayList<Long> nextLongArray(){ ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size()); for(int i = 0; i < input.size(); i++){ ret.add(Long.parseLong(input.get(i))); } return ret; } static String myconv(Object list, int no){//only join String joinString = CONVSTR.get(no); if(list instanceof String[]){ return String.join(joinString, (String[])list); }else if(list instanceof ArrayList){ return String.join(joinString, (ArrayList)list); }else{ throw new ClassCastException("Don't join"); } } static ArrayList<String> myconv(String str, int no){//only split String splitString = CONVSTR.get(no); return new ArrayList<String>(Arrays.asList(str.split(splitString))); } public static void main(String[] args){ CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, ""); solve();flush(); } //Don't have to see. end------------------------------------------ static void solve(){//Here is the main function ArrayList<Integer> one = nextIntArray(); int ai = one[0]; int ao = one[1]; int at = one[2]; int aj = one[3]; int al = one[4]; int as = one[5]; int az = one[6]; int output1 = Math.floor(ai / 2) * 2 + Math.floor(aj / 2) * 2 + Math.floor(al / 2) * 2; int output2; if(ai >= 1 && aj >= 1 && al >= 1){ output2= Math.floor((ai - 1) / 2) * 2 + Math.floor((aj - 1) / 2) * 2 + Math.floor((al - 1) / 2) * 2 + 3; }else{ output2 = 0; } myout(Math.max(output1, output2) + ao); } //Method addition frame start //Method addition frame end }
Main.java:73: error: array required, but ArrayList<Integer> found int ai = one[0]; ^ Main.java:74: error: array required, but ArrayList<Integer> found int ao = one[1]; ^ Main.java:75: error: array required, but ArrayList<Integer> found int at = one[2]; ^ Main.java:76: error: array required, but ArrayList<Integer> found int aj = one[3]; ^ Main.java:77: error: array required, but ArrayList<Integer> found int al = one[4]; ^ Main.java:78: error: array required, but ArrayList<Integer> found int as = one[5]; ^ Main.java:79: error: array required, but ArrayList<Integer> found int az = one[6]; ^ Main.java:80: error: incompatible types: possible lossy conversion from double to int int output1 = Math.floor(ai / 2) * 2 + Math.floor(aj / 2) * 2 + Math.floor(al / 2) * 2; ^ Main.java:83: error: incompatible types: possible lossy conversion from double to int output2= Math.floor((ai - 1) / 2) * 2 + Math.floor((aj - 1) / 2) * 2 + Math.floor((al - 1) / 2) * 2 + 3; ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 9 errors
s527968674
p03840
C++
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pi; #define debug(x) cerr << #x << ": " << x << endl #define debug2(x, y) debug(x), debug(y) #define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++) #define rep(i, a) for(int i = 0; i < (int)(a); i++) #define all(v) v.begin(), v.end() #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sq(x) ((x) * (x)) template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); ll lon, squ, tri, lle, lri, zri, zle; cin >> lon >> squ >> tri >> lle >> lri >> zri >> zle; ll tot1 = squ * 2; tot1 += 4 * (lle / 2); tot1 += 4 * (lri / 2); if(lon && (lle & 1) && (lri & 1)) tot1 += 6, lon--; tot1 += (lon / 2) * 4; ll tot = squ * 2; ll mn = min({lon, lle, lri}); tot += mn * 6; lon -= mn; lri -= mn; lle -= mn; tot += (lon / 2) * 4; tot += (lle / 2) * 4; tot += (lri / 2) * 4; cout << max({tot1 / 2, tot / 2, tot2 / 2}) << endl; return 0; } /* Things to look out for: - Integer overflows - Array bounds - Special cases Be careful! */
a.cc: In function 'int main()': a.cc:45:41: error: 'tot2' was not declared in this scope; did you mean 'tot'? 45 | cout << max({tot1 / 2, tot / 2, tot2 / 2}) << endl; | ^~~~ | tot a.cc:45:20: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 45 | cout << max({tot1 / 2, tot / 2, tot2 / 2}) << endl; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:3: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided
s010015627
p03840
C++
#include<bits/stdc++.h> using namespace std; #define int ll #define ll long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 // #define MOD 998244353 #define MEM_SIZE 101010 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";} template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;} template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } } template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);} template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}} template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } void solve(void) { int n = 7; vector<int> vec (n,0); for (int i = 0; i < n; i++) { cin>>vec[i]; } int res1 = 0; res1 += vec[0]/2*2; res1 += vec[1]; res1 += vec[3]/2*2; res1 += vec[4]/2*2; int res = 0; if(vec[0] >= 1 and vec[3] >= 1 and vec[4] >= 1) { res += 3; vec[0] --; vec[3] --; vec[4] --; } res += vec[0]/2*2: res += vec[1]; res += vec[3]/2*2; res += vec[4]/2*2; // res += min(vec[2],min(vec[5],vec[6]))* cout<<max(res1,res)<<endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(11); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:46:20: error: expected ';' before ':' token 46 | res += vec[0]/2*2: | ^ | ;
s754912281
p03840
C++
v#include <bits/stdc++.h> using namespace std; int main(){ long long I, O, T, J, L, S, Z; cin >> I >> O >> T >> J >> L >> S >> Z; long long ans = I / 2 * 2 + O + J / 2 * 2 + L / 2 * 2; if (I % 2 == 1 (J >= 2 || L >= 2)){ ans++; } cout << ans << endl; }
a.cc:1:2: error: stray '#' in program 1 | v#include <bits/stdc++.h> | ^ a.cc:1:1: error: 'v' does not name a type 1 | v#include <bits/stdc++.h> | ^ a.cc: In function 'int main()': a.cc:5:3: error: 'cin' was not declared in this scope 5 | cin >> I >> O >> T >> J >> L >> S >> Z; | ^~~ a.cc:7:18: error: expression cannot be used as a function 7 | if (I % 2 == 1 (J >= 2 || L >= 2)){ | ~~^~~~~~~~~~~~~~~~~~ a.cc:10:3: error: 'cout' was not declared in this scope 10 | cout << ans << endl; | ^~~~ a.cc:10:18: error: 'endl' was not declared in this scope 10 | cout << ans << endl; | ^~~~
s579313419
p03840
C++
#include<cmath> #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<utility> #include<map> #include<set> #include<queue> #include<functional> #define INF 1e16 #define N (1000000007) using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<ll,P> Q; ll a[7]; int main(void){ for(int i=0;i<7;i++)cin>>a[i]; ll ans=0 ll k = min(a[0],min(a[3],a[4])); ll cnt=0; if(a[0]%2==1)cnt++; if(a[3]%2==1)cnt++; if(a[4]%2==1)cnt++; if(k%2==0){ ans+=3*k; ans+=((a[0]-k)/2)*2; ans+=a[1]; ans+=((a[3]-k)/2)*2; ans+=((a[4]-k)/2)*2; cout<<ans<<endl; } else{ if(cnt==3)ans+=a[0]+a[3]+a[4]; if(cnt==2)ans+=a[0]+a[3]+a[4]-1; if(cnt==1)ans+=a[0]+a[3]+a[4]-1; cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:5: error: expected ',' or ';' before 'll' 23 | ll k = min(a[0],min(a[3],a[4])); | ^~ a.cc:28:8: error: 'k' was not declared in this scope 28 | if(k%2==0){ | ^
s736345100
p03840
C++
#include<cmath> #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<utility> #include<map> #include<set> #include<queue> #include<functional> #define INF 1e16 #define N (1000000007) using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<ll,P> Q; ll a[7]; int main(void){ for(int i=0;i<7;i++)cin>>a[i]; ll ans=0 ll k = min(a[0],min(a[3],a[4])); ll cnt=0; if(a[0]%2==1)cnt++; if(a[1]%2==1)cnt++; if(a[2]%2==1)cnt++; if(k%2==0){ ans+=3*k; ans+=((a[0]-k)/2)*2; ans+=a[1]; ans+=((a[3]-k)/2)*2; ans+=((a[4]-k)/2)*2; cout<<ans<<endl; } else{ if(cnt==3)ans+=a[0]+a[3]+a[4]; if(cnt==2)ans+=a[0]+a[3]+a[4]-1; if(cnt==1)ans+=a[0]+a[3]+a[4]-1; cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:5: error: expected ',' or ';' before 'll' 23 | ll k = min(a[0],min(a[3],a[4])); | ^~ a.cc:28:8: error: 'k' was not declared in this scope 28 | if(k%2==0){ | ^
s851660174
p03840
C++
#include<cmath> #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<utility> #include<map> #include<set> #include<queue> #include<functional> #define INF 1e16 #define N (1000000007) using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<ll,P> Q; ll a[7]; int main(void){ for(int i=0;i<7;i++)cin>>a[i]; ll ans=0 ll k = min(a[0],min(a[3],a[4])); ans+=3*k; ans+=((a[0]-k)/2)*2; ans+=a[1]; ans+=((a[3]-k)/2)*2; ans+=((a[4]-k)/2)*2; cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:23:5: error: expected ',' or ';' before 'll' 23 | ll k = min(a[0],min(a[3],a[4])); | ^~ a.cc:24:12: error: 'k' was not declared in this scope 24 | ans+=3*k; | ^
s472225600
p03840
C++
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, e, f, g; int main() { cin >> a >> b >> c >> d >> e >> f; long long res = b; for (int i = 0; i <= min({a, d, e, 4}); ++i) res = max(res, 3 * i + 2 * ((a - i) / 2 + (d - i) / 2 + (e - i) / 2) + b); cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:27: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 9 | for (int i = 0; i <= min({a, d, e, 4}); ++i) | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: template argument deduction/substitution failed: a.cc:9:27: note: deduced conflicting types for parameter '_Tp' ('long long int' and 'int') 9 | for (int i = 0; i <= min({a, d, e, 4}); ++i) | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate expects 2 arguments, 1 provided
s482726596
p03840
C++
#include <bits/stdc++.h> using namespace std; #define int long long //0oooo0 //000000 signed main() { int I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z; int ans = I/2*4+O*2+J/2*4+L/2*4)/2; int cnt = I%2+J%2+L%2; if(cnt == 3) { ans+=6; } if(cnt == 2) { ans+=2; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:9:36: error: expected ',' or ';' before ')' token 9 | int ans = I/2*4+O*2+J/2*4+L/2*4)/2; | ^
s921354211
p03840
C++
#include <bits/stdc++.h> using namespace std; int i, o, t, j, l, s, z; long long ans; int main() { cin >> i >> o >> t >> j >> l >> s >> z; ans = o; ans += i / 2 * 2; ans += j / 2 * 2; ans += l / 2 * 2; ans += max(((i & 1) + (j & 1) + (l & 1)) * 2 - 3, 0) cout << ans << endl; }
a.cc: In function 'int main()': a.cc:13:61: error: expected ';' before 'cout' 13 | ans += max(((i & 1) + (j & 1) + (l & 1)) * 2 - 3, 0) | ^ | ; 14 | cout << ans << endl; | ~~~~
s352104079
p03840
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <iomanip> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cassert> #include <complex> #include <time.h> #define ll long long #define double long double #define itn int #define endl '\n' #define co(ans) cout<<ans<<endl #define COYE cout<<"YES"<<endl #define COYe cout<<"Yes"<<endl #define COye cout<<"yes"<<endl #define CONO cout<<"NO"<<endl #define CONo cout<<"No"<<endl #define COno cout<<"no"<<endl #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FFOR(i,a,b) for(int i=(a);i<=(b);++i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) FFOR(i,1,n) #define ALL(V) (V).begin(),(V).end() #define SORT(V) sort((V).begin(),(V).end()) #define REVERSE(V) reverse((V).begin(),(V).end()) #define INF ((1LL<<62)-(1LL<<31)) #define EPS 1e-10 #define PI 3.141592653589793238 #define MOD 1000000007 #define MAX 5100000 template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;} const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} bool CAN=true; using namespace std; int main(){ ll A[7],ans=0LL,cnt=0LL; REP(i,7) cin>>A[i]; ans+=A[1]; ans+=A[0]-A[0]%2; ans+=A[3]-B[3]%2; ans+=A[4]-B[4]%2; if(A[0]*A[3]*A[4]>0){ cnt+=A[1]; cnt+=(A[0]-1)-(A[0]-1)%2; cnt+=(A[3]-1)-(A[3]-1)%2; cnt+=(A[4]-1)-(A[4]-1)%2; cnt+=3LL; } cout<<chmax(ans,cnt)<<endl; }
a.cc: In function 'int main()': a.cc:55:13: error: 'B' was not declared in this scope 55 | ans+=A[3]-B[3]%2; | ^
s174222916
p03840
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <fstream> #include <set> #include <cmath> #include <array> #include <iomanip> #include <cassert> using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); int64_t answer = 0; int64_t a_i; cin >> a_i; int64_t a_o; cin >> a_o; int x; cin >> x; int64_t y_1, y_2; cin >> y_1; cin >> y_2; answer += a_o * 2; auto try_this = [=](int sub) { int64_t mag = min({a_i, y_1, y_2}) - sub; if (mag < 0) { return 0LL; } return 6 * mag + ((a_i - mag) / 2) * 4 + ((y_1 - mag) / 2) * 4 + ((y_2 - mag) / 2) * 4; }; cout << (answer + std::max(try_this(0), try_this(1))) / 2; }
a.cc: In lambda function: a.cc:45:72: error: inconsistent types 'long long int' and 'long int' deduced for lambda return type 45 | return 6 * mag + ((a_i - mag) / 2) * 4 + ((y_1 - mag) / 2) * 4 + ((y_2 - mag) / 2) * 4; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
s432383013
p03840
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=x;i<y;i++) #define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl; #define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);} const long mod=1e9+7; const int size=1e5; const int inf=1e9; int main(){ long A[7]; rep(i,0,7) cin>>A[i]; long a = A[0]/2*2 + A[1] + A[3]/2*2 + A[4]/2*2 long b = (A[0]-1)/2*2 + A[1] + (A[3]-1)/2*2 + (A[4]-1)/2*2 + 4 if(A[0] == 0 || A[3] == 0 || A[4] == 0) b = A[1]; cout<<max(a, b)<<endl; }
a.cc: In function 'int main()': a.cc:13:9: error: expected ',' or ';' before 'long' 13 | long b = (A[0]-1)/2*2 + A[1] + (A[3]-1)/2*2 + (A[4]-1)/2*2 + 4 | ^~~~ a.cc:15:22: error: 'b' was not declared in this scope 15 | cout<<max(a, b)<<endl; | ^
s303781603
p03840
C++
#include<bits/stdc++.h> using namespace std; long long ai, ao, at, aj, al, as, az; int main(int argc, char const *argv[]) { cin >> ai >> ao >> at >> aj >> al >> as >> az; long long ans = ao; if(!ai||!aj||!al){ long long ans += ai/2*2+aj/2*2+al/2*2; } else{ ans += ai + aj + al; if(ai%2==aj%2&&aj%2==al%2);else ans--; } cout << ans; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:8:23: error: expected initializer before '+=' token 8 | long long ans += ai/2*2+aj/2*2+al/2*2; | ^~
s891871525
p03840
C++
#include <bits/stdc++.h> using namespace std; int main(){ int ans; int I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z; if(!((T!=0)||(S!=0)||(Z!=0)||(I%2==1)||(J%2==1)||(L%2==1))) ans += O + I + J + L; } cout << ans << endl; }
a.cc:10:3: error: 'cout' does not name a type 10 | cout << ans << endl; | ^~~~ a.cc:12:1: error: expected declaration before '}' token 12 | } | ^
s506616559
p03840
C++
#include <bits/stdc++.h> using namespace std; int main(){ int I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z; if((T!=0)||(S!=0)||(Z!=0)||(I%2==1)||(J%2==1)||(L%2==1)) const int ans = 0; else{ int ans = 0; ans += O + I + J + L; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:12:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 12 | cout << ans << endl; | ^~~ | abs
s509530898
p03840
C++
#include <bits/stdc++.h> using namespace std; int main(){ int I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z; if((T!=0)||(S!=0)||(Z!=0)||(I%2==1)||(J%2==1)||(L%2==1)) const int ans = 0; else{ int ans = 0; ans += O + I + J + L; } cout << and << endl; }
a.cc: In function 'int main()': a.cc:12:15: error: expected identifier before '<<' token 12 | cout << and << endl; | ^~
s800595265
p03840
C
#include <bits/stdc++.h> using namespace std; int main(){ int I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z; if((T!=0)||(S!=0)||(Z!=0)||(I%2==1)||(J%2==1)||(L%2==1)) const int ans = 0; else{ int ans = 0; ans += O + I + J + L; } cout << and << endl; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s135061298
p03840
C++
#include<iostream> #include<vector> using namespace std; typedef long long li; #define rep(i,n) for(int i=0;i<(n);i++) #define df 0 template<class T> void print(const T& t){ cout << t << "\n"; } template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); } int main(){ li v[7]; rep(i,7) cin >> v[i]; if(df)print(v[0]+v[1]+v[3]+v[4]); li s=v[1]; if(v[0] && v[3] && v[4]){ int f=(v[0]&1)+(v[3]&1)+(v[4]&1); if(f>=2){ s+=3; v[0]--; v[3]--; v[4]--; } } s+=v[0]/2*2; s+=v[3]/2*2; s+=v[4]/2*2; print(s); } #define df 0 #include<iostream> #include<vector> using namespace std; typedef long long li; #define rep(i,n) for(int i=0;i<(n);i++) #define df 0 template<class T> void print(const T& t){ cout << t << "\n"; } template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); } int main(){ li v[7]; rep(i,7) cin >> v[i]; if(df)print(v[0]+v[1]+v[3]+v[4]); li s=v[1]; if(v[0] && v[3] && v[4]){ int f=(v[0]&1)+(v[3]&1)+(v[4]&1); if(f>=2){ s+=3; v[0]--; v[3]--; v[4]--; } } s+=v[0]/2*2; s+=v[3]/2*2; s+=v[4]/2*2; print(s); }
a.cc:33:24: error: redefinition of 'template<class T> void print(const T&)' 33 | template<class T> void print(const T& t){ cout << t << "\n"; } | ^~~~~ a.cc:7:24: note: 'template<class T> void print(const T&)' previously declared here 7 | template<class T> void print(const T& t){ cout << t << "\n"; } | ^~~~~ a.cc:34:37: error: redefinition of 'template<class T, class ... Ts> void print(const T&, const Ts& ...)' 34 | template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); } | ^~~~~ a.cc:8:37: note: 'template<class T, class ... Ts> void print(const T&, const Ts& ...)' previously declared here 8 | template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); } | ^~~~~ a.cc:36:5: error: redefinition of 'int main()' 36 | int main(){ | ^~~~ a.cc:10:5: note: 'int main()' previously defined here 10 | int main(){ | ^~~~
s578292929
p03840
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); i++) #define ALL(v) (v).begin(),(v).end() using ll = long long; using P = pair<int, int>; const int INF = 1e9; const long long LINF = 1e18; const long long MOD = 1e9 + 7; signed main(){ ll i, o, t, j, l, s, z; cin >> i >> o >> t >> j >> l >> s >> z; int cnt = 0; if (i % 2 == 1) cnt++; if (j % 2 == 1) cnt++; if (l % 2 == 1) cnt++; if(cnt <= 1){ cout << o + 2 * (i / 2) + 2 * (j / 2) + 2 * (l / 2) << endl; }else{ ll t = min(i, j, l); i -= t; j -= t; l -= t; cout << o + t * 3 + 2 * (i / 2) + 2 * (j / 2) + 2 * (l / 2) << endl; } return 0; }
In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:21:19: required from here 21 | ll t = min(i, j, l); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s553168308
p03840
C++
//Zory-2020 #include<bits/stdc++.h> using namespace std; typedef long long ll; // typedef __int128 ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define FR first #define SE second #define MP make_pair #define PB push_back #define vc vector #define db double #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define bin(x) (1ll<<(x)) #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++) #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--) #define mem(x,val) memset(x,val,sizeof x) #define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I]) #define PC __builtin_popcountll #ifdef DEBUG #define DD 1 #else #define DD 0 #endif #define Debug if(DD) printf("line %d\n",__LINE__) #define deb(x) if(DD) cerr<<#x<<'='<<x<<endl #define debug if(DD) printf namespace mine { ll qread() { ll ans=0,f=1;char c=getchar(); while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();} while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar(); return ans*f; } void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);} void write1(ll num){write(num);putchar(' ');} void write2(ll num){write(num);putchar('\n');} template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;} template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;} ll gcd(ll x,ll y){return y?gcd(y,x%y):x;} bool IN(ll x,ll l,ll r){return l<=x and x<=r;} void gg1(){write2(-1);exit(0);} void gg2(){puts("NO");exit(0);} const db eps=1e-8; const int INF=0x3f3f3f3f; const int MOD=1e9+7; int mm(const int x){return x>=MOD?x-MOD:x;} template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);} ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;} ll invm(ll x){return qpower(x,MOD-2);} const int M=5e6+10; ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;} void PRE() { fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD; facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD; Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD; } const int N=3e3+10; //------------------FIXED------------------ void main() { ll I=qread(),O=qread(),T=qread(),J=qread(),L=qread(); write((I/2)*2+O+(J/2)*2+(L/2)*2+(I&1 and J&1 and L&1)+(I%2==0 and I>0 and j&1 and L&1)+(I&1 and J%2==0 and J>0 and L&1)+(I&1 and J&1 and L%2==0 and L>0)); } };//变量重名! signed main() { #ifdef DEBUG //freopen("a.in","r",stdin); freopen("z.txt","r",stdin); //freopen("a.out","w",stdout); #endif srand(time(0)); mine::PRE();//线性预处理模意义 mine::main(); if(DD) cerr<<"\n---------------------Zory---------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s"; }
a.cc: In function 'void mine::main()': a.cc:70:91: error: 'j' was not declared in this scope 70 | write((I/2)*2+O+(J/2)*2+(L/2)*2+(I&1 and J&1 and L&1)+(I%2==0 and I>0 and j&1 and L&1)+(I&1 and J%2==0 and J>0 and L&1)+(I&1 and J&1 and L%2==0 and L>0)); | ^
s623168457
p03840
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++) #define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--) #define rep(i,n) FOR(i,0,n) #define rrep(i,n) RFOR(i,0,n) #define ALL(v) v.begin(), v.end() #define bra(first,second) '(' << first << ',' << second << ')' #define P(a,b) make_pair(a,b); ll MOD = 1000000007; //ll INF = 21474836470000000; ll INF = 1001001001001001001; long double EPS = 1e-11; long double PI = 3.141592653589793238; template<typename T> void remove(std::vector<T>& vector, unsigned int index){ vector.erase(vector.begin() + index); } using Graph = vector<vector<pair<ll,ll>>>; ll A[10]; int main(){ rep(i,7) cin >> A[i]; ll I = A[0],L = A[3],J = A[4],ans = I + L + J; if(J > L) swap(J,L); if(I % 2 == 1){ if(L % 2 == 1 && J % 2 == 1) ans = I + L + J; if(L % 2 == 0 && J % 2 == 0) ans--; if((L % 2) ^ (J % 2) == 1){ if(L == 0 || J == 0) ans -= 2; else ans--; }else{ if(I == 0){ if(L % 2 == 1 && J % 2 == 1) ans -= 2; if(L % 2 == 0 && J % 2 == 0) ans = I + L + J; if((L % 2) ^ (J % 2) == 1) ans--; }else{ if(L % 2 == 1 && J % 2 == 1) ans--; if(L % 2 == 0 && J % 2 == 0) ans = I + L + J; if((L % 2) ^ (J % 2) == 1) ans--; } } cout << ans + A[1] << endl; }
a.cc: In function 'int main()': a.cc:47:2: error: expected '}' at end of input 47 | } | ^ a.cc:25:11: note: to match this '{' 25 | int main(){ | ^
s002171528
p03840
C++
/** * author: otera **/ #include<iostream> #include<string> #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<deque> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60 ; const ll mod=1e9+7 ; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cerr << #x << " = " << (x) << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } void solve() { vector<int> a(7); rep(i, 7) { cin >> a[i]; } if(a[0] == 0) { cout << a[1] + 2 * aj << endl; return; } if(aj == 0) { cout << a[1] + 2 * (a[0] / 2) << endl; return; } cout << a[1] + max(2 * (a[0] / 2) + 2 * (a[3] / 2) + 2 * (a[4] / 2), 3 + 2 * ((a[0] - 1) / 2)+ 2 * ((a[3] - 1) / 2) + 2 * ((a[4] - 1) / 2)) << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //int t; cin >> t; rep(i, t)solve(); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:61:28: error: 'aj' was not declared in this scope; did you mean 'a'? 61 | cout << a[1] + 2 * aj << endl; | ^~ | a a.cc:64:8: error: 'aj' was not declared in this scope; did you mean 'a'? 64 | if(aj == 0) { | ^~ | a
s123193913
p03840
C++
#include<bits/stdc++.h> using namespace std; int f(int x) { if (x % 2) return x - 1; return x; } int main() { int I, O, J, L; { int x; cin >> I >> O >> x >> J >> L; } long r = 0; if (I && J && L) { r = 3ll + f(I-1) + f(J-1) + f(L-1); } r = max(r, f(I) + f(J) + f(L)); cout << r + O << endl; }
a.cc: In function 'int main()': a.cc:18:10: error: no matching function for call to 'max(long int&, int)' 18 | r = max(r, f(I) + f(J) + f(L)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:18:10: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 18 | r = max(r, f(I) + f(J) + f(L)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:18:10: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 18 | r = max(r, f(I) + f(J) + f(L)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~
s429979843
p03840
C++
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" #define rep(i, n) for(int i=0; i<(n); ++i) #define FOR(i, m, n) for(int i=(m); i<(n); ++i) #define rrep(i, n) for(int i=(n)-1; i>=0; --i) #define rfor(i, m, n) for(int i=(m); i>=(n); --i) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define mp make_pair #define pb push_back #define eb emplace_back using namespace std; using LL = long long; using VB = vector<bool>; using VVB = vector<VB>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<LL>; using VVL = vector<VL>; using VS = vector<string>; using VD = vector<double>; using PII = pair<int, int>; using VP = vector<PII>; using PLL = pair<LL, LL>; using VPL = vector<PLL>; template<class T>using pq = priority_queue<T>; template<class T>using pqs = priority_queue<T, vector<T>, greater<T>>; const int inf = (int)1e9; const LL inf_ll = (LL)1e18, MOD = 1000000007; const double PI = acos(-1.0), EPS = 1e-12; template<class T>inline void Sort(T& a)noexcept { sort(all(a)); } template<class T>inline void RSort(T& a)noexcept { sort(rall(a)); } template<class T>inline void Reverse(T& a)noexcept { reverse(all(a)); } template<class T>inline void Unique(T& a)noexcept { a.erase(unique(all(a)), a.end()); } template<class T>inline T Sorted(T a)noexcept { Sort(a); return a; } template<class T>inline T RSorted(T a)noexcept { RSort(a); return a; } template<class T>inline T Reversed(T a)noexcept { Reverse(a); return a; } template<class T>inline T Uniqued(T a)noexcept { Unique(a); return a; } template<class T>inline auto Max(const T& a)noexcept { return *max_element(all(a)); } template<class T>inline auto Min(const T& a)noexcept { return *min_element(all(a)); } template<class T>inline int MaxPos(const T& a)noexcept { return max_element(all(a)) - a.begin(); } template<class T>inline int MinPos(const T& a)noexcept { return min_element(all(a)) - a.begin(); } template<class T, class U>inline int Count(const T& a, const U& v)noexcept { return count(all(a), v); } template<class T, class U>inline int Find(const T& a, const U& v)noexcept { auto pos = find(all(a), v); return pos == a.end() ? -1 : pos - a.begin(); } template<class T, class U>inline U Sum(const T& a, const U& v)noexcept { return accumulate(all(a), v); } template<class T, class U>inline int Lower(const T& a, const U& v)noexcept { return lower_bound(all(a), v) - a.begin(); } template<class T, class U>inline int Upper(const T& a, const U& v)noexcept { return upper_bound(all(a), v) - a.begin(); } template<class T, class P>inline void RemoveIf(T& a, P f)noexcept { a.erase(remove_if(all(a), f), a.end()); } template<class T>inline T Age(T n, T m)noexcept { return (n + m - 1) / m; } template<class T>inline T Age2(T n, T m)noexcept { return Age(n, m) * m; } template<class T>inline T Tri(T n)noexcept { return (n & 1) ? (n + 1) / 2 * n : n / 2 * (n + 1); } template<class T = long long>inline T BIT(int b)noexcept { return T{ 1 } << b; } template<class T>inline T Gcd(T n, T m)noexcept { return m ? Gcd(m, n % m) : n; } template<class T>inline T Lcm(T n, T m)noexcept { return n / Gcd(n, m) * m; } template<class T>inline T Pow(T a, T n)noexcept { T r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; } template<class T>inline T Powmod(T a, T n, T m = MOD)noexcept { T r = 1; while (n > 0) { if (n & 1)r = r * a % m, n--; else a = a * a % m, n /= 2; }return r; } template<class T>inline bool chmax(T& a, const T& b)noexcept { if (a < b) { a = b; return true; } return false; } template<class T>inline bool chmin(T& a, const T& b)noexcept { if (a > b) { a = b; return true; } return false; } inline string operator*(string s, int n)noexcept { string ret; rep(i, n)ret += s; return ret; } // --- input --- // #if defined(_MSC_VER) || defined(ONLINE_JUDGE) #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #endif inline int gc()noexcept { return getchar_unlocked(); } template<class T>inline void InputF(T& v)noexcept { cin >> v; } inline void InputF(char& v)noexcept { while (isspace(v = gc())); } inline void InputF(string& v)noexcept { char c; for (InputF(c); !isspace(c); c = gc())v += c; } inline void InputF(int& v)noexcept { bool neg = false; v = 0; char c; InputF(c); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c); c = gc())v = v * 10 + (c - '0'); if (neg)v = -v; } inline void InputF(long long& v)noexcept { bool neg = false; v = 0; char c; InputF(c); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c); c = gc())v = v * 10 + (c - '0'); if (neg)v = -v; } inline void InputF(double& v)noexcept { double dp = 1; bool neg = false, adp = false; v = 0; char c; InputF(c); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c) || c == '.'; c = gc()) { if (c == '.')adp = true; else if (adp)v += (c - '0') * (dp *= 0.1); else v = v * 10 + (c - '0'); } if (neg)v = -v; } template<class T, class U>inline void InputF(pair<T, U>& v)noexcept { InputF(v.first); InputF(v.second); } template<class T>inline void InputF(vector<T>& v)noexcept { for (auto& e : v)InputF(e); } struct InputV { int n, m; InputV(int N) :n(N), m(0) {} InputV(pair<int, int> N) :n(N.first), m(N.second) {} template<class T>operator vector<T>()noexcept { vector<T> v(n); InputF(v); return v; } template<class T>operator vector<vector<T>>()noexcept { vector<vector<T>> v(n, vector<T>(m)); InputF(v); return v; } }; struct Input { template<class T>operator T()noexcept { T v; InputF(v); return v; } int operator--(int) { int v; InputF(v); v--; return v; } InputV operator[](int n)noexcept { return InputV(n); } InputV operator[](pair<int, int> n)noexcept { return InputV(n); } template<class T, size_t W>array<vector<T>, W> get(int H) { array<vector<T>, W> ret; rep(i, H)rep(j, W) { T x = *this; ret[j].push_back(x); } return ret; } }in; // --- output --- // struct BoolStr { const char* t, * f; BoolStr(const char* _t, const char* _f) :t(_t), f(_f) {} }Yes("Yes", "No"), yes("yes", "no"), YES("YES", "NO"), Int("1", "0"); struct DivStr { const char* d, * l; DivStr(const char* _d, const char* _l) :d(_d), l(_l) {} }spc(" ", "\n"), no_spc("", "\n"), end_line("\n", "\n"), comma(",", "\n"), no_endl(" ", ""); class Output { BoolStr B{ Yes }; DivStr D{ spc }; bool isPrint = true; void p(double v) { printf("%.20f", v); } void p(long double v) { printf("%.20Lf", v); } void p(int v) { printf("%d", v); } void p(LL v) { printf("%lld", v); } void p(char v) { putchar(v); } void p(bool v) { printf(v ? B.t : B.f); } template<class T>void p(const T& v) { cout << v; } template<class T, class U>void p(const pair<T, U>& v) { p(v.first); printf(D.d); p(v.second); } template<class T>void p(const vector<T>& v) { rep(i, sz(v)) { if (i)printf(D.d); p(v[i]); } } template<class T>void p(const vector<vector<T>>& v) { rep(i, sz(v)) { if (i)printf(D.l); p(v[i]); } } void p(const BoolStr& v) { B = v; isPrint = false; } void p(const DivStr& v) { D = v; isPrint = false; } public: void operator()() { printf(D.l); } template<class H>void operator()(H&& h) { p(h); if (isPrint)printf(D.l); isPrint = true; B = Yes; D = spc; } template<class H, class...T>void operator()(H&& h, T&& ...t) { p(h); if (isPrint)printf(D.d); isPrint = true; operator()(forward<T>(t)...); } template<class...T>void exit(T&& ...t) { operator()(forward<T>(t)...); std::exit(EXIT_SUCCESS); } }out; // --- dump --- // #if __has_include("dump.hpp") #include "dump.hpp" #else #define dump(...) (void(0)) #endif // ---------------------------------------------------------------- // // O -> 1 // I,I -> 2 // J,J -> 2 // L,L -> 2 // J,I,L -> 3 int main() { LL I = in, O = in, T = in, J = in, L = in, S = in, Z = in; VL ans{ I / 2 * 2 + J / 2 * 2 + L / 2 * 2 }; if (I && J && L)ans.pb((I - 1) / 2 * 2 + (J - 1) / 2 * 2 + (K - 1) / 2 * 2 + 3); out(Max(ans) + O); }
a.cc: In function 'int main()': a.cc:167:69: error: 'K' was not declared in this scope 167 | if (I && J && L)ans.pb((I - 1) / 2 * 2 + (J - 1) / 2 * 2 + (K - 1) / 2 * 2 + 3); | ^
s295879646
p03840
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef set<int> si; typedef pair<int,int> pii; #define rep(i,a,b) for(int i=(a); i<(b); ++i) #define per(i,a,b) for(int i=(b)-1; i>=(a); --i) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define S second const int N = 7; int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); //freopen("in.txt", "r", stdin); vl a(N); rep(i,0,sz(a)) { cin >> a[i]; } ll ret = a[1]; ll x = min(a[0], min(a[3],a[4])); ll y = a[0]%2 + a[3]%2 + a[4]%2; if(y >= 2) { x = min(1, x); } else { x = 0; } rep(i,0,x+1) { ll loc = a[1] + 3 * i; loc += ((a[0]-i)/2)*2; loc += ((a[3]-i)/2)*2; loc += ((a[4]-i)/2)*2; ret = max(ret, loc); } cout << ret << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:30:24: error: no matching function for call to 'min(int, ll&)' 30 | x = min(1, x); | ~~~^~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:30:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 30 | x = min(1, x); | ~~~^~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:30:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 30 | x = min(1, x); | ~~~^~~~~~
s921158126
p03840
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<ll, ll>; using edge = pair<int, ll>; using graph = vector<vector<int>>; using WeightedGraph = vector<vector<edge>>; const ll INF = 1LL << 60; const int INF32 = 1 << 29; const ll MOD = 1000000007; int main() { ll i,o,t,j,l,s,z; cin >>i>> o>> t>> j>> l>> s>> z; ll ans =o; if(i%2+j%2+l%2>1){} ll tmp = min(1, min(i, min(j, l))); ans+=3*tmp; i-=tmp;j-=tmp;l-=tmp; } ans+=(i/2)* 2; ans+=(j/2)* 2; ans+=(l/2)* 2; cout << ans << endl; }
a.cc: In function 'int main()': a.cc:19:17: error: no matching function for call to 'min(int, const long long int&)' 19 | ll tmp = min(1, min(i, min(j, l))); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:19:17: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 19 | ll tmp = min(1, min(i, min(j, l))); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:19:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 19 | ll tmp = min(1, min(i, min(j, l))); | ~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc: At global scope: a.cc:23:3: error: 'ans' does not name a type 23 | ans+=(i/2)* 2; | ^~~ a.cc:24:3: error: 'ans' does not name a type 24 | ans+=(j/2)* 2; | ^~~ a.cc:25:3: error: 'ans' does not name a type 25 | ans+=(l/2)* 2; | ^~~ a.cc:26:3: error: 'cout' does not name a type 26 | cout << ans << endl; | ^~~~ a.cc:27:1: error: expected declaration before '}' token 27 | } | ^
s812350992
p03840
C++
#include <bits/stdc++.h> using namespace std; #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) typedef long long ll; typedef long double lb; typedef pair<int,int> P; const int MOD = 1000000007; const ll INF = 1e10; const double EPS = 1e-10; const double PI = 3.141592653589793; template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;} template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;} const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; #define int long long #define double long double //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////i int a[10], ans; signed main(){ rep(i,7)cin>>a[i]; ans += (a[0]/2)*2;a[0] %= 2; ans += a[1];a[1] = 0; if(a[0]){ if(a[3] % 2 == 0 && a[4] % 2 == 0){ ans += (a[3]/2)*2;a[3] %= 2; ans += (a[4]/2)*2;a[4] %= 2; }else if(a[3] % 2 && a[4] % 2){ ans += (a[3]/2)*2;a[3] %= 2; ans += (a[4]/2)*2;a[4] %= 2; ans += 3; }else{ ans += 3;a--;b--; ans += (a[3]/2)*2;a[3] %= 2; ans += (a[4]/2)*2;a[4] %= 2; } }else{ ans += (a[3]/2)*2;a[3] %= 2; ans += (a[4]/2)*2;a[4] %= 2; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:39:16: error: lvalue required as decrement operand 39 | ans += 3;a--;b--; | ^ a.cc:39:20: error: 'b' was not declared in this scope; did you mean 'lb'? 39 | ans += 3;a--;b--; | ^ | lb
s732939465
p03840
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll aI, aO, aT, aJ, aL, aS, aZ; cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; if(aI%2 == aJ%2 && aJ%2 == aL%2){ cout << aI + aJ + aL + aO << endl; } else{ if((aI + aJ + aL) % 2 == 0 && min(min(aI, aJ), aL) == 0){ cout << aI + aJ + aL + aO - 2 << endl; }else{ cout << max(0, aI + aJ + aL + aO - 1) << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:12:35: error: no matching function for call to 'max(int, ll)' 12 | }else{ cout << max(0, aI + aJ + aL + aO - 1) << endl; } | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 12 | }else{ cout << max(0, aI + aJ + aL + aO - 1) << endl; } | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:12:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 12 | }else{ cout << max(0, aI + aJ + aL + aO - 1) << endl; } | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
s198824101
p03840
C++
#include<bits/stdc++.h> using namespace std; int main(){ ll aI, aO, aT, aJ, aL, aS, aZ; cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; if(aI%2 == aJ%2 && aJ%2 == aL%2){ cout << aI + aJ + aL + aO << endl; } else{ if((aI + aJ + aL) % 2 == 0 && min(min(aI, aJ), aL) == 0){ cout << aI + aJ + aL + aO - 2 << endl; }else{ cout << max(0, aI + aJ + aL + aO - 1) << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: 'll' was not declared in this scope 5 | ll aI, aO, aT, aJ, aL, aS, aZ; | ^~ a.cc:6:16: error: 'aI' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~ a.cc:6:22: error: 'aO' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~ a.cc:6:28: error: 'aT' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~ a.cc:6:34: error: 'aJ' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~ a.cc:6:40: error: 'aL' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~ a.cc:6:46: error: 'aS' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~ a.cc:6:52: error: 'aZ' was not declared in this scope 6 | cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; | ^~
s037258832
p03840
C++
#include<bits/stdc++.h> using namespace std; int main(){ int aI, aO, aT, aJ, aL, aS, aZ; cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ; if(aI%2 == aJ%2 && aJ%2 == aL%2) cout << aI + aJ + aL + aO << endl; else{ if((aI + aJ + aL) % 2 == 0 && min(min(aI, aJ), aL) == 0) cout << aI + aJ + aL + aO - 2 << endl; }else cout << max(0, aI + aJ + aL + aO - 1) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:18: error: 'else' without a previous 'if' 11 | }else cout << max(0, aI + aJ + aL + aO - 1) << endl; | ^~~~ a.cc: At global scope: a.cc:13:9: error: expected unqualified-id before 'return' 13 | return 0; | ^~~~~~ a.cc:14:1: error: expected declaration before '}' token 14 | } | ^