submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s775825830 | p03838 | C++ | #include <iostream>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long i64;
i64 x,y;
i64 dif;
int main()
{
cin >> x >> y;
dif = abs(x - y);
typedef pair<i64,i64> P;
priority_queue<P> que;
que.push({0,x});
while(!que.empty())
{
i64 v= que.front().first;
i64 d = que.front().second;
que.pop();
if(v == y)
{
cout << d << endl;
return 0;
}
que.push({d + dif , v + dif});
que.push({d + 1,v * -1});
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:28: error: 'class std::priority_queue<std::pair<long long int, long long int> >' has no member named 'front'
26 | i64 v= que.front().first;
| ^~~~~
a.cc:27:29: error: 'class std::priority_queue<std::pair<long long int, long long int> >' has no member named 'front'
27 | i64 d = que.front().second;
| ^~~~~
|
s862234517 | p03838 | C++ | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
using namespace std;
typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
int to,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
#define MAX_N 200002
int dp[26][MAX_N]={};
bool d[MAX_N]={};
int pa[MAX_N];
vector<edge> G[MAX_N];
P1 cost[MAX_N]={};
vector<int> child[MAX_N];
vector<int> ra[MAX_N];
int x[MAX_N]={};
priority_queue<P2,vector<P2>,greater<P2>> que;
ll x[200001]={};
ll y[200001]={};
int main() {
ll x,y;
int t=0;
cin>>x>>y;
if(abs(x)>abs(y)){
if(x>0)t++;
t+=abs(x)-abs(y);
if(y>0)t++;
}else{
if(x<0)t++;
t+=abs(y)-abs(x);
if(y<0)t++;
}
cout<<t<<endl;
return 0;
}
| a.cc:29:4: error: conflicting declaration 'll x [200001]'
29 | ll x[200001]={};
| ^
a.cc:27:5: note: previous declaration as 'int x [200002]'
27 | int x[MAX_N]={};
| ^
|
s207949851 | p03838 | Java | x,y = gets.split.map &:to_i
add = 0
if y<0
add = 1
y = -y
end
p [y-x, y+x+1].min + add | Main.java:1: error: class, interface, enum, or record expected
x,y = gets.split.map &:to_i
^
1 error
|
s962910846 | p03838 | C++ | #include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;
int main(){
int x, y;
cin >> x >> y;
if(x > 0){
if(y <= ((-1) * x)) cout << 1 - x - y << endl;
else if(y < x) cout << 1 + x + y << endl;
else cout << y - x << endl;
}
else if(x < 0){
if(y < x) cout << 2 - y + x << endl;
else if(y < ((-1) * x)) cout << y - x << endl;
else cout << 1 + x + y << endl;
}
else{
if(y > 0) cout << y << endl;
else cout << 1 - y << endl;
}
}
return 0;
}
| a.cc:29:9: error: expected unqualified-id before 'return'
29 | return 0;
| ^~~~~~
a.cc:30:1: error: expected declaration before '}' token
30 | }
| ^
|
s716246247 | p03838 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT_MAX - 10;
const int MOD = 1e9 + 7;
// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int f(int x, int y) {
if (x <= y) {
return y - x;
} else {
return INF;
}
}
int main() {
// 入力
int x, y;
cin >> x >> y;
int ans = f(x, y);
ans = min(ans, f(-x, y) + 1);
ans = min(ans, f(-x, -y) + 2);
ans = min(ans, f(x, -y) + 1);
// 解答
cout << ans << endl;
return 0;
}
| a.cc:18:17: error: 'INT_MAX' was not declared in this scope
18 | const int INF = INT_MAX - 10;
| ^~~~~~~
a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
12 | #include <cmath>
+++ |+#include <climits>
13 | using namespace std;
|
s295070120 | p03838 | C++ |
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
int main() {
int I, O, T, J, L, S, Z;
cin >> I >> O >> T >> J >> L >> S >> Z;
int ans = 0;
if(I && J && L) {
int ni = I-1, nj = J-1, nl = L-1;
int temp = 0;
temp += ni / 2;
temp += nj / 2;
temp += nl / 2;
chmax(ans, temp * 2 + 3);
}
int temp = 0;
temp += I / 2;
temp += L / 2;
temp += J / 2;
chmax(ans, temp * 2);
cout << ans + O << endl;
return 0;
}
| a.cc:31:23: error: '::main' must return 'int'
31 | #define int long long int
| ^~~
a.cc:36:1: note: in expansion of macro 'int'
36 | int main() {
| ^~~
|
s247193372 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int x , y;
int main()
{
cin >> x >> y;
if(x >= 0 && x <= y)
{
cout << y - x;
return 0;
}
int diff = abs(abs(x) - abs(y));
int ans = diff;
if(x >= 0 && y >= 0 && y < x)
{
cout << ans + 1 + (y > 0);
return 0;
}
if(x < 0 && y < 0 && y < x)
{
cout << ans + 2;
return 0;
}
if(x < 0 && y < 0 && y >= x)
{
cout << ans;
return 0;
}
if((x >= 0 && y < 0))
{
cout << ans + 1;
return 0;
}
if(y >= 0 && x < 0)
{
cout << ans + (y > 0);
return 0;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int x , y;
int main()
{
cin >> x >> y;
if(x >= 0 && x <= y)
{
cout << y - x;
return 0;
}
int diff = abs(abs(x) - abs(y));
int ans = diff;
if(x >= 0 && y >= 0 && y < x)
{
cout << ans + 1 + (y > 0);
return 0;
}
if(x < 0 && y < 0 && y < x)
{
cout << ans + 2;
return 0;
}
if(x < 0 && y < 0 && y >= x)
{
cout << ans;
return 0;
}
if((x >= 0 && y < 0))
{
cout << ans + 1;
return 0;
}
if(y >= 0 && x < 0)
{
cout << ans + (y > 0);
return 0;
}
return 0;
}
| a.cc:45:5: error: redefinition of 'int x'
45 | int x , y;
| ^
a.cc:4:5: note: 'int x' previously declared here
4 | int x , y;
| ^
a.cc:45:9: error: redefinition of 'int y'
45 | int x , y;
| ^
a.cc:4:9: note: 'int y' previously declared here
4 | int x , y;
| ^
a.cc:46:5: error: redefinition of 'int main()'
46 | int main()
| ^~~~
a.cc:5:5: note: 'int main()' previously defined here
5 | int main()
| ^~~~
|
s134326497 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
int x, y;
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(false);
cin >> x >> y;
if (abs(x) == abs(y)) cout << 1 << endl;
// else if (x == 0 && y > 0) cout << y << endl;
// else if (x == 0 && y < 0) cout << -y+1 << endl;
// else if (y == 0 && x > 0) cout << x+1 << endl;
// else if (y == 0 && x < 0) cout << -x << endl;
else if (abs(x) < abs(y)) {
if (y < 0) cout << min(-y-x+1, -y+x+2) << endl;
else cout << min(y-x, y+x+1) << endl;
}
else {
if (x < 0) {
if (y <= 0) cout << y-x << endl;
else cout << -y-x+1 << endl;
}
else {
if (y <= 0) cout << y+x+1 << endl;
else cout << -y+x+2 < endl;
}
}
return 0;
} | a.cc: In function 'int main(int, const char**)':
a.cc:30:45: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
30 | else cout << -y+x+2 < endl;
| ~~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: couldn't deduce template parameter '_Bi_iter'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: couldn't deduce template parameter '_Bi_iter'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
30 | else cout << -y+x+2 < endl;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>'
30 | else cout << -y+x+2 < endl;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
30 | else cout << -y+x+2 < endl;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:30:47: note: couldn't deduce template parameter '_CharT'
30 | else cout << -y+x+2 < endl;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _T |
s631840989 | p03838 | C++ | #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
ll abs(ll a){
if(a>=0)return a;
else return -1*a;
}
int main(){
ll x,y;
ll ans=0;
cin>>x>>y;
if(x>=0 && y>=0){
if(x>y){
ans+=2;
ans+=x-y;
}else{
ans+=y-x;
}
}else if(x<0 && y<0){
if(abs(x)>abs(y)){
ans+=y-x;
}else{
ans+=2;
ans+=abs(y)-abs(x);
}
}else if(x>=0 && y<0){
if(abs(x)>abs(y)){
ans++;
ans+=abs(x)-abs(y);
}else{
ans++;
ans+=abs(y)-x;
}
}else{
if(abs(x)>abs(y)){
ans++;
ans+=abs(x)-abs(y);
}else{
ans++;
ans+=abs(y)-abs(x);
}
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:24:23: error: call of overloaded 'abs(ll&)' is ambiguous
24 | if(abs(x)>abs(y)){
| ~~~^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:24:30: error: call of overloaded 'abs(ll&)' is ambiguous
24 | if(abs(x)>abs(y)){
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:33: error: call of overloaded 'abs(ll&)' is ambiguous
28 | ans+=abs(y)-abs(x);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:40: error: call of overloaded 'abs(ll&)' is ambiguous
28 | ans+=abs(y)-abs(x);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:31:23: error: call of overloaded 'abs(ll&)' is ambiguous
31 | if(abs(x)>abs(y)){
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:31:30: error: call of overloaded 'abs(ll&)' is ambiguous
31 | if(abs(x)>abs(y)){
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:33:33: error: call of overloaded 'abs(ll&)' is ambiguous
33 | ans+=abs(x)-abs(y);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:7:4: note: candidate: 'll abs(ll)'
7 | ll abs(ll a){
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: |
s657349076 | p03838 | Java | public class Example05 {
public static void main(String[] args) {
// 画面の初期値
int x = Integer.parseInt(args[0]);
// 目標の画面の値
int y = Integer.parseInt(args[1]);
// ボタン最小押下回数
long count = 1;
// [x]と[y]の絶対値が同一の場合は何もしない
if (Math.abs(x) != Math.abs(y)) {
// 変数x,yがどちらも0以上
if (x >= 0 && y >= 0) {
if (x < y) {
count = y - x;
} else {
count = x + y + 1;
}
} else if (x < 0 && y >= 0) {
// 変数xが負数で変数yが0以上
if (Math.abs(x) < y) {
count = y - Math.abs(x) + 1;
} else {
count = Math.abs(x) - y + 1;
}
} else if (x >= 0 && y < 0) {
// 変数xが0以上で変数yが負数
if (x < Math.abs(y)) {
count = Math.abs(y) - x + 1;
} else {
count = x - Math.abs(y) + 1;
}
} else {
// 変数x,yがどちらも負数
if (Math.abs(x) < Math.abs(y)) {
count = Math.abs(y) - Math.abs(x) + 2;
} else {
count = Math.abs(x) - Math.abs(y);
}
}
} else {
;// do nothing
}
// ボタン最小押下回数出力
System.out.println(count);
}
} | Main.java:1: error: class Example05 is public, should be declared in a file named Example05.java
public class Example05 {
^
1 error
|
s014014486 | p03838 | Java | public static void main(String[] args) throws Exception {
// Here your code !
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
String[] lineArray = br.readLine().split(" ", 0);
long x = Integer.parseInt(lineArray[0]);
long y = Integer.parseInt(lineArray[1]);
int cnt =0;
if (y<x){
x=x*(-1);
cnt++;
}
while(x<y){
x++;
cnt++;
if(x*(-1)==y){
cnt++;
break;
}
}
System.out.println(cnt);
} | Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) throws Exception {
^
(use --enable-preview to enable unnamed classes)
1 error
|
s738638396 | p03838 | C | #include<iostream>
#include<string>
using namespace std;
int main()
{
long x, y, kaisu;
cin >> x;
cin >> y;
kaisu = 0;
if ((x >= 0 && y >= 0 ) || ((x < 0) && (y < 0))){
if(y > x){
kaisu = y - x;
} else {
if (y == 0){
kaisu = x - y + 1;
} else {
kaisu = x - y + 2;
}
}
} else {
x = x * -1;
if(y > x){
kaisu = y - x + 1;
} else {
if (y == 0){
kaisu = x - y;
} else {
kaisu = x - y + 1;
}
}
}
cout << kaisu;
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s649027572 | p03838 | Java | import java.util.*;
import java.io.*;
public class gg {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stk = new StringTokenizer(br.readLine());
long x = Long.parseLong(stk.nextToken());
long y = Long.parseLong(stk.nextToken());
long rta = 0;
if(x < 0){
if(y<0){
if(x<y){
System.out.println(Math.abs((y*-1) -(x*-1)));
}else{
System.out.println(Math.abs((y*-1) -(x*-1))+2);
}
}else{
if(x*-1<y){
System.out.println(Math.abs((y) -(x*-1))+1);
}else if(x*-1==y){
System.out.println(1);
}else{
System.out.println(Math.abs((x*-1) -(y))+1);
}
}
}else{
if(y<0){
if(x<y*-1){
System.out.println(Math.abs((y*-1) -(x))+1);
}else if(x==y*-1){
System.out.println(1);
}else{
System.out.println(Math.abs(x-(y*-1))+1);
}
}else{
if(x>y){
if(y==0) System.out.println(x+1);
else System.out.println(Math.abs((y)-(x))+2);
}else{
System.out.println(Math.abs((y)-(x)));
}
}
}
/*if(x > y){
if(x < 0 && y < 0)
rta+=1;
rta += Math.abs(Math.abs(x) - Math.abs(y));
rta+=1;
}
else if(x < y){
if(x < 0 && y > 0)
rta+=1;
if(x <0 && Math.abs(x) > Math.abs(y))
rta+=1;
rta += Math.abs(Math.abs(x) - Math.abs(y));
}
if(x == 0 || y == 0)
rta = Math.abs(Math.abs(x) - Math.abs(y));
System.out.println(rta);*/
}
}
| Main.java:3: error: class gg is public, should be declared in a file named gg.java
public class gg {
^
1 error
|
s140402977 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second
typedef long long ll;
const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;
#define int ll
int a, b, ans;
main()
{
cin >> a >> b;
ans = abs(abs(a) - abs(b));
if (a == 0)
{
cout << (b > 0 ? ans : ans + 1);
return 0;
}
else if (b == 0)
{
cout << (a > 0 ? ans + 1 : ans)
}
else if (a > 0 && b > 0 && a > b)
cout << ans + 2;
else if (a < 0 && b < 0 && a > b)
cout << ans + 2;
else if (a > 0 && b > 0 && a < b)
cout << ans;
else if (a < 0 && b < 0 && a < b)
cout << ans;
else if (a > 0 && b < 0)
cout << ans + 1;
else if (a < 0 && b > 0)
cout << ans + 1;
}
| a.cc:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
29 | main()
| ^~~~
a.cc: In function 'int main()':
a.cc:41:40: error: expected ';' before '}' token
41 | cout << (a > 0 ? ans + 1 : ans)
| ^
| ;
42 | }
| ~
|
s840358476 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second
typedef long long ll;
const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;
#define int ll
int a, b, ans;
main()
{
cin >> a >> b;
ans = abs(abs(a) - abs(b));
// if (a > 0 && b > 0 && a > b)
// cout << ans + 2;
else if (a > 0 && b > 0 && a < b)
cout << ans;
// else if (a < 0 && b < 0 && a > b)
// cout << ans + 2;
// else if (a < 0 && b < 0 && a < b)
// cout << ans;
// else if (a > 0 && b < 0)
// cout << ans + 1;
// else if (a < 0 && b > 0)
// cout << ans + 1;
}
| a.cc:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
29 | main()
| ^~~~
a.cc: In function 'int main()':
a.cc:36:5: error: 'else' without a previous 'if'
36 | else if (a > 0 && b > 0 && a < b)
| ^~~~
|
s989664495 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second
typedef long long ll;
const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;
#define int ll
int a, b;
main()
{
cin >> a >> b;
if (a * -1 == b)
{
cout << 1;
return 0;
}
ans = abs(abs(a) - abs(b));
if (a > 0 && b > 0 && a > b)
cout << ans + 2;
if (a > 0 && b > 0 && a < b)
cout << ans;
if (a < 0 && b < 0 && a > b)
cout << ans + 2;
if (a < 0 && b < 0 && a < b)
cout << ans;
if (a > 0 && b < 0)
cout << ans + 1;
if (a < 0 && b > 0)
cout << ans + 1;
}
| a.cc:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
29 | main()
| ^~~~
a.cc: In function 'int main()':
a.cc:37:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
37 | ans = abs(abs(a) - abs(b));
| ^~~
| abs
|
s107606518 | p03838 | C | long long x,y;
scanf("%lld %lld",&x,&y);
int kaisu;
if(x<y){
if(x*y>=0)kaisu=y-x;
if(x*y<0){
if(x*-1<y)kaisu=y-x*-1+1
if(x*-1==y)kaisu=1;
if(x*-1>y)kaisu=x*-1-y+1;
}
}
if(x>y){
if(x*y>0){
if(y>0)kaisu=x-y+2;
if(y<0)kaisu=y*-1+x+2;
}
if(x*y<0){
if(x<y*-1)kaisu=y*-1-x+1;
if(x==y*-1)kaisu=1;
if(x>y*-1)kaisu=x-y*-1+1;
}
if(x==0){
kaisu=y*-1+1;
}
if(y==0){
kaisu=x+1;
}
}
printf("%d",kaisu);
} | main.c:2:15: error: expected declaration specifiers or '...' before string constant
2 | scanf("%lld %lld",&x,&y);
| ^~~~~~~~~~~
main.c:2:27: error: expected declaration specifiers or '...' before '&' token
2 | scanf("%lld %lld",&x,&y);
| ^
main.c:2:30: error: expected declaration specifiers or '...' before '&' token
2 | scanf("%lld %lld",&x,&y);
| ^
main.c:5:9: error: expected identifier or '(' before 'if'
5 | if(x<y){
| ^~
main.c:13:9: error: expected identifier or '(' before 'if'
13 | if(x>y){
| ^~
main.c:31:16: error: expected declaration specifiers or '...' before string constant
31 | printf("%d",kaisu);
| ^~~~
main.c:31:21: error: expected declaration specifiers or '...' before 'kaisu'
31 | printf("%d",kaisu);
| ^~~~~
main.c:33:1: error: expected identifier or '(' before '}' token
33 | }
| ^
|
s858075177 | p03838 | C++ | x, y = map(int, raw_input().split())
if x == y:
print 0
elif x == -y:
print 1
else:
if abs(y) > abs(x):
print (x < 0) + (y < 0) + abs(y) - abs(x)
else:
print (x > 0) + (y > 0) + abs(x) - abs(y)
| a.cc:1:1: error: 'x' does not name a type
1 | x, y = map(int, raw_input().split())
| ^
|
s145984826 | p03838 | C++ | #include <stdio.h>
#include <iostream>
#include <cmath>
#define int long long
using namespace std;
const int N=123456;
int abs(int a) {
return a>=0?a:-a;
}
signed main() {
int x,y;
scanf("%lld %lld",&x,&y);
if(x>=0 && y>=0) {
if(x<=y) {
printf("%lld\n",y-x);
} else {
printf("%lld\n",min(y-x+2,y+x+1));
}
} else if(x>=0 && y<=0) {
if(abs(x)<=abs(y)) {
printf("%lld\n",abs(y)-abs(x)+1);
} else {
printf("%lld\n",abs(x)-abs(y)+1);
}
} else if(x<=0 && y>=0) {
if(abs(x)>=abs(y)) {
printf("%lld\n",min(abs(x)-abs(y)+1,abs(x)+abs(y)));
} else {
printf("%lld\n",min(abs(y)+abs(x),abs(y)-abs(x)+2));
}
} else {
if(abs(x)>=abs(y)) {
printf("%lld\n",abs(x)-abs(y));
} else {
printf("%lld\n",abs(y)-abs(x)+2);
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:23: error: call of overloaded 'abs(long long int&)' is ambiguous
25 | if(abs(x)<=abs(y)) {
| ~~~^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:25:31: error: call of overloaded 'abs(long long int&)' is ambiguous
25 | if(abs(x)<=abs(y)) {
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:26:44: error: call of overloaded 'abs(long long int&)' is ambiguous
26 | printf("%lld\n",abs(y)-abs(x)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:26:51: error: call of overloaded 'abs(long long int&)' is ambiguous
26 | printf("%lld\n",abs(y)-abs(x)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:44: error: call of overloaded 'abs(long long int&)' is ambiguous
28 | printf("%lld\n",abs(x)-abs(y)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:51: error: call of overloaded 'abs(long long int&)' is ambiguous
28 | printf("%lld\n",abs(x)-abs(y)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:31:23: error: call of overloaded 'abs(long long int&)' is ambiguous
31 | if(abs(x)>=abs(y)) {
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
|
s838613650 | p03838 | C++ | #include <stdio.h>
#include <iostream>
#include <cmath>
#define int long long
using namespace std;
const int N=123456;
int abs(int a) {
return a>=0?a:-a;
}
signed main() {
int x,y;
scanf("%lld %lld",&x,&y);
if(x>=0 && y>=0) {
if(x<=y) {
printf("%lld\n",y-x);
} else {
printf("%lld\n",min(y-x+2,y+x+1));
}
} else if(x>=0 && y<=0) {
if(abs(x)<=abs(y)) {
printf("%lld\n",abs(y)-abs(x)+1);
} else {
printf("%lld\n",abs(x)-abs(y)+1);
}
} else if(x<=0 && y>=0) {
if(abs(x)>=abs(y)) {
printf("%lld\n",min(abs(x)-abs(y)+1,abs(x)+abs(y)));
} else {
printf("%lld\n",min(abs(y)+abs(x),abs(y)-abs(x)+2));
}
} else {
if(abs(x)>=abs(y)) {
printf("%lld\n",abs(x)-abs(y));
} else {
printf("%lld\n",abs(y)-abs(x)+2);
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:23: error: call of overloaded 'abs(long long int&)' is ambiguous
25 | if(abs(x)<=abs(y)) {
| ~~~^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:25:31: error: call of overloaded 'abs(long long int&)' is ambiguous
25 | if(abs(x)<=abs(y)) {
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:26:44: error: call of overloaded 'abs(long long int&)' is ambiguous
26 | printf("%lld\n",abs(y)-abs(x)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:26:51: error: call of overloaded 'abs(long long int&)' is ambiguous
26 | printf("%lld\n",abs(y)-abs(x)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:44: error: call of overloaded 'abs(long long int&)' is ambiguous
28 | printf("%lld\n",abs(x)-abs(y)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:51: error: call of overloaded 'abs(long long int&)' is ambiguous
28 | printf("%lld\n",abs(x)-abs(y)+1);
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:31:23: error: call of overloaded 'abs(long long int&)' is ambiguous
31 | if(abs(x)>=abs(y)) {
| ~~~^~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:11:5: note: candidate: 'long long int abs(long long int)'
11 | int abs(int a) {
|
s894969149 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9
int main(){
int x,y,n;
cin>>x>>y>>n;
if (y >= x) {
if (x >= 0) { //1,2
n = y-x; //B*0
} else {
if (y >= 0) {
if (y >= -x) { //-1,5
n = y+x+1; //B+A...
} else { //-6, 5
n = x-y+1;
}
} else {
n = y-x; //B*0
}
}
} else {
if (y >= 0) { //2,1
n = x-y+2; //B+A+...+A+B
} else {
if (x >= 0) {
if (x >= -y) { //5,-1
n = y+x+1; //B+A...
} else { //6, -5
n = x+y+1;
}
} else {
n = y-x; //B*0
}
}
cout<<n;
return 0;
}
| a.cc: In function 'int main()':
a.cc:44:2: error: expected '}' at end of input
44 | }
| ^
a.cc:7:11: note: to match this '{'
7 | int main(){
| ^
|
s411988712 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9
int main(){
int x,y,n;
cin>>x>>y>>n;
if (y >= x) {
if (x >= 0) { //1,2
n = y-x; //B*0
} else {
if (y >= 0) {
if (y >= -x) { //-1,5
n = y+x+1; //B+A...
} else { //-6, 5
n = x-y+1;
}
} else {
n = y-x; //B*0
}
}
} else {
if (y >= 0) { //2,1
n = x-y+2; //B+A+...+A+B
} else {
if (x >= -y) { //2,-1
n = x+y+1; //B+A+...
} else { //2,-3
n = -x-y+1; //A...B
}
}
}
cout<<n;
return 0;
}
| a.cc:21:9: error: extended character is not valid in an identifier
21 | } else {
| ^
a.cc: In function 'int main()':
a.cc:21:9: error: 'else\U00003000' was not declared in this scope
21 | } else {
| ^~~~~~
|
s924496933 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9
int main(){
int x,y,n;
cin>>x>>y>>n;
if (y >= x) {
if (x >= 0) { //1,2
n = y-x; //B*0
} else {
if (y >= 0) {
if (y >= -x) { //-1,5
n = y+x+1 //B+A...
} else { //-6, 5
n = x-y+1
}
} else {
n = y-x; //B*0
}
}
} else {
if (y >= 0) { //2,1
n = x-y+2; //B+A+...+A+B
} else {
if (x >= -y) { //2,-1
n = x+y+1; //B+A+...
} else { //2,-3
n = -x-y+1; //A...B
}
}
}
cout<<n;
return 0;
}
| a.cc:21:9: error: extended character is not valid in an identifier
21 | } else {
| ^
a.cc: In function 'int main()':
a.cc:17:20: error: expected ';' before '}' token
17 | n = y+x+1 //B+A...
| ^
| ;
18 | } else { //-6, 5
| ~
a.cc:19:20: error: expected ';' before '}' token
19 | n = x-y+1
| ^
| ;
20 | }
| ~
a.cc:21:9: error: 'else\U00003000' was not declared in this scope
21 | } else {
| ^~~~~~
|
s652312246 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9
int main(){
int x,y,n;
cin>>x>>y>>n;
if (y >= x) {
if (x >= 0) {
n = y-x; //B*0
} else {
if (y >= -x) {
n = y+x+1; //B*1
} else {
n = y-x; //B*0
}
}
} else {
if (y >= 0) {
n = x-y+2 //B+A+...+A+B
} else {
if (x >= -y) {
n = x+y+1; //B+A+...
} else {
n = x+y;
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:16: error: expected ';' before '}' token
23 | n = x-y+2 //B+A+...+A+B
| ^
| ;
24 | } else {
| ~
|
s735209609 | p03838 | C++ | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <fstream>
#include <cassert>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define sz(a) int((a).size())
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
#define rev(i, n, s) for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;
int main() {
#ifdef loc
if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
assert(0);
}
freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
boost;
int a, b;
cin >> a >> b;
ll a, b;
cin >> a >> b;
ll ans = abs(abs(b) - abs(a));
if (a*b < 0) ans++;
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:51:6: error: conflicting declaration 'll a'
51 | ll a, b;
| ^
a.cc:49:7: note: previous declaration as 'int a'
49 | int a, b;
| ^
a.cc:51:9: error: conflicting declaration 'll b'
51 | ll a, b;
| ^
a.cc:49:10: note: previous declaration as 'int b'
49 | int a, b;
| ^
|
s727891076 | p03838 | C | #include <stdio.h>
#include <math.h>
int main(void)
{
int x,y,i=0;
scanf("%d",&x);
scanf("%d",&y);
if((x=>0&&y<0)||(x<0&&y=>0)){
i=1;
}else if(x<0&&y<0){
i=2;
}
int value;
x=abs(x);
y=abs(y);
if(x==y){
printf("%d\n",i);
}else if(x>y){
value=x-y;
printf("%d\n",value+i);
}else{
value=y-x;
printf("%d\n",value+i);
}
return 0;
}
| main.c: In function 'main':
main.c:8:9: error: expected expression before '>' token
8 | if((x=>0&&y<0)||(x<0&&y=>0)){
| ^
main.c:8:27: error: expected expression before '>' token
8 | if((x=>0&&y<0)||(x<0&&y=>0)){
| ^
main.c:14:5: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
14 | x=abs(x);
| ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
2 | #include <math.h>
+++ |+#include <stdlib.h>
3 | int main(void)
|
s545890796 | p03838 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int X,Y;
cin>>X>>Y;
if(X==Y)
{
cout<<"0";
return 0;
}
if(X==0)
{
if(Y<0)
cout<<-Y+1;
else cout<<Y;
return 0;
}
if(Y==0)
{
if(x<0)
cout<<abs(x);
else cout<<x+1;
return 0;
}
if((X<0 && Y<0) || (X>0 && Y>0) )
{
if(X>Y)
cout<<abs(abs(X)-abs(Y))+2<<endl;
else
cout<<abs(Y-X)<<endl;
}
else
{
cout<<abs(abs(X)-abs(Y))+1<<endl;
}
} | a.cc: In function 'int main()':
a.cc:25:20: error: 'x' was not declared in this scope
25 | if(x<0)
| ^
|
s753802957 | p03838 | C++ | asd | a.cc:1:2: error: 'asd' does not name a type
1 | asd
| ^~~
|
s438322517 | p03838 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s203101400 | p03838 | C++ | #include <iostream>
using namespace std;
long long solve(long long x, long long y){
if(a <= b) return b - a;
return 1e15;
}
int main(){
long long x, y;
cin >> x >> y;
long long ans = 1e15;
ans = min(ans, solve(x, y));
ans = min(ans, solve(-x, y) + 1);
ans = min(ans, solve(x, -y) + 1);
ans = min(ans, solve(-x, -y) + 2);
cout << ans << endl;
} | a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:5:12: error: 'a' was not declared in this scope
5 | if(a <= b) return b - a;
| ^
a.cc:5:17: error: 'b' was not declared in this scope
5 | if(a <= b) return b - a;
| ^
|
s065416219 | p03838 | Java | import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class A {
public static void main(String[] args) {
FS r = new FS();
long x = r.nextLong();
long y = r.nextLong();
long tmpx = x;
long tmpy = y;
long minCount = 1000000500;
long c = 0;
// case 1 : + -> +
if(tmpx < 0){
tmpx = -tmpx;
c++;
}
if(tmpy < 0){
tmpy = -tmpy;
c++;
}
if(tmpy < tmpx) c = minCount+1;
else c += tmpy - tmpx;
minCount = Math.min(minCount, c);
// case 2 : + -> -
c = 0;
tmpx = x;
tmpy = y;
if(tmpx < 0){
tmpx = -tmpx;
c++;
}
if(tmpy > 0){
tmpy = -tmpy;
c++;
}
if(tmpy < tmpx) c = minCount+1;
else c+= tmpy - tmpx;
minCount = Math.min(minCount, c);
// case 3 : - -> +
c = 0;
tmpx = x;
tmpy = y;
if(tmpx > 0){
tmpx = -tmpx;
c++;
}
if(tmpy < 0){
tmpy = -tmpy;
c++;
}
if(tmpy < tmpx) c = minCount+1;
else c+= tmpy - tmpx;
minCount = Math.min(minCount, c);
// case 4 : - -> -
c = 0;
tmpx = x;
tmpy = y;
if(tmpx > 0){
tmpx = -tmpx;
c++;
}
if(tmpy > 0){
tmpy = -tmpy;
c++;
}
if(tmpy < tmpx) c = minCount+1;
else c+= tmpy - tmpx;
minCount = Math.min(minCount, c);
System.out.println(minCount);
}
// Read Class
static class FS {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
public boolean hasNext() { skipUnprintable(); return hasNextByte();}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public int nextInt() {
return (int)nextLong();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if(b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
}
}
| Main.java:6: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
s724687185 | p03838 | Java | import java.util.Scanner;
class Main{
public static void main(String args[]){
Scanner inp=new Scanner(System.in);
int x=inp.nextInt();
int y=inp.nextInt();
int c=0;
y-x=c;
System.out.println(c);
}
} | Main.java:9: error: unexpected type
y-x=c;
^
required: variable
found: value
1 error
|
s386067320 | p03838 | C++ | #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
int main(){
ll x, y;
cin >> x >> y;
ll ret = 500000000000LL;
if(x>=0 && y>=0){
if(x < y){
ret = min(ret, y-x);
}else{
ret = min(ret, y-x+2);
ret = min(ret, y+x+1)
}
}
else if(x<0 && y>=0){
if(abs(x) < abs(y)){
ret = min(ret, abs(y)-abs(x)+1);
}else{
ret = min(ret, abs(x)-abs(y)+1);
}
}
else if(x>=0 && y<0){
if(abs(x) < abs(y)){
ret = min(ret, abs(y)+abs(x));
ret = min(ret, abs(y)-abs(x)+1);
}else{
ret = min(ret, abs(y)+abs(x));
ret = min(ret, abs(x)-abs(y)+1);
}
}
else{
if(abs(x) < abs(y)){
ret = min(ret, abs(y)-abs(x)+2);
}else{
ret = min(ret, abs(y)-abs(x));
}
}
cout << ret << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:34: error: expected ';' before '}' token
32 | ret = min(ret, y+x+1)
| ^
| ;
33 | }
| ~
|
s935514684 | p03838 | Java | import java.util.Scanner;
public class renshu{
public static void main(String[] args){
Scanner kbs=new Scanner(System.in);
int x=kbs.nextInt();
int y=kbs.nextInt();
int a=0,b=0;
if(y<0&&x>0){
y*=-1;
a++;
}else if(y>0&&x<0){
x*=-1;
a++;
}
else if(y<0&&x<0){
a+=2;
x*=-1;
y*=-1;
}
b=x-y;
if(b<0){b*=-1;}
System.out.println(a+b);
}
} | Main.java:2: error: class renshu is public, should be declared in a file named renshu.java
public class renshu{
^
1 error
|
s113910338 | p03838 | C++ | #include <iostream>
using namespace std;
int main()
{
int32_t x, y;
cin >> x >> y;
int32_t d{ y - x };
if( d < 0) {
cout << 2 - d << end;
}
else {
cout << d << endl;
}
}
| a.cc: In function 'int main()':
a.cc:12:23: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
12 | cout << 2 - d << end;
| ~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::nullptr_t'
306 | operator<<(nullptr_t)
|
s196965830 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>(_b);--i)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned char byte;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
const int MX = 25;
int main(int argc, char *argv[])
{
#ifdef HTRINH_UNIT_TEST
freopen(argv[1],"r",stdin);
ifstream cin(argv[1]);
#endif
#if 0
ofstream cout(argv[2]);
#endif
ios :: sync_with_stdio(false);
cin.tie(NULL);
int x,y;
cin >> x >> y;
if (x == y) {
cout << 0 << endl;
} else if (x < y) {
if (x >= 0 || y <= 0) cout << y-x << endl;
else cout << 1+abs(abs(y)-abs(x)) << endl;
}
} else { // x > y
if (y >= 0) cout << 1+x+y << endl;
else {
if (x == 0) cout << 1+abs(y) << endl;
else if (x > 0) {
if (abs(x) >= abs(y)) cout << 1+abs(x)-abs(y) << endl;
else cout << 1+abs(y)-abs(x) << endl;
} else {
cout << 2+abs(y)-abs(x) << endl;
}
}
}
return 0;
} | a.cc:44:11: error: expected unqualified-id before 'else'
44 | } else { // x > y
| ^~~~
a.cc:56:9: error: expected unqualified-id before 'return'
56 | return 0;
| ^~~~~~
a.cc:57:5: error: expected declaration before '}' token
57 | }
| ^
|
s563554336 | p03838 | C++ | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
long long x,y;
cin>>x>>y;
if(x==y)
{
cout<<0<<endl;
return 0;
}
if(abs(x)==abs(y))
{
cout<<1<<endl;
return 0;
}
if((x==0)||(y==0))
{
if(x>0)
{
cout<<x<<endl;
return 0;
}
if(x<0)
{
cout<<abs(x)+1<endl;
return 0;
}
if(y>0)
{
cout<<y<<endl;
return 0;
}
if(y<0)
{
cout<<abs(y)+1<<endl;
return 0;
}
}
if((x>=0)&&(y>=0)&&(y>x))
{
cout<<y-x<<endl;
return 0;
}
if((x>=0)&&(y>=0)&&(y<x))
{
x=-x;y=-y;
cout<<2+y-x<<endl;
return 0;
}
if((x>=0)&&(y<0)&&(abs(y)<abs(x)))
{
x=-x;
cout<<1+y-x<<endl;
return 0;
}
if((x>=0)&&(y<0)&&(abs(y)>abs(x)))
{
cout<<1+abs(y)-x<<endl;
return 0;
}
if((x>=0)&&(y>=0)&&(y>x))
{
cout<<y-x<<endl;
return 0;
}
if((x<0)&&(y>=0)&&(abs(y)>abs(x)))
{
x=-x;
cout<<1+y-x<<endl;
return 0;
}
if((x<0)&&(y>=0)&&(abs(y)<abs(x)))
{
y=-y;
cout<<1+y-x<<endl;
return 0;
}
if((x<0)&&(y<0)&&(y<x))
{
x=-x;y=-y;
cout<<2+y-x<<endl;
return 0;
}
if((x<0)&&(y<0)&&(y>x))
{
cout<<y-x<<endl;
return 0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:27:21: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
27 | cout<<abs(x)+1<endl;
| ~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/string:48,
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_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
27 | cout<<abs(x)+1<endl;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
27 | cout<<abs(x)+1<endl;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: couldn't deduce template parameter '_CharT'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
27 | cout<<abs(x)+1<endl;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3901 | operator<(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
27 | cout<<abs(x)+1<endl;
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2600 | operator<(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed:
a.cc:27:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
27 | cout<<abs(x)+1<endl;
| ^~~~
In file included from /usr/include/c++/14/bits/ios_base.h:46:
/usr/include/c++/14/system_error:324:3: note: candidate: 'bool std::operator<(const error_code&, const error_code&)'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ^~~~~~~~
/usr/include/c++/14/system_error:324:31: note: no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'const std::error_code&'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/system_error:507:3: note: candidate: 'bool std::operator<(const error_condition&, const error_condition&)'
507 | operator<(const error_condition& __lhs,
| ^~~~~~~~
/usr/include/c++/14/system_error:507:36: note: no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'const std::error_condition&'
507 | operator<(const error_condition& __lhs,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
|
s845704544 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long int64_t;
int main() {
int64_t x, y;
cin >> x >> y;
vector<int64_t> p = { x, y, -x, -y };
int64_t g[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
g[i][j] = 1e15;
if (i == j) {
g[i][j] = 0;
}
if (p[i] == -p[j]) {
g[i][j] = min(g[i][j], 1LL);
}
if (p[i] <= p[j]) {
g[i][j] = min(g[i][j], p[j] - p[i]);
}
}
}
for (int k = 0; k < 4; k++) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
}
}
cout << g[0][1] << endl;
}
| a.cc:4:19: error: conflicting declaration 'typedef long long int int64_t'
4 | typedef long long int64_t;
| ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155,
from /usr/include/stdlib.h:514,
from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration as 'typedef __int64_t int64_t'
27 | typedef __int64_t int64_t;
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:20:46: error: no matching function for call to 'min(int64_t&, long long int)'
20 | g[i][j] = min(g[i][j], 1LL);
| ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/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:20:46: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
20 | g[i][j] = min(g[i][j], 1LL);
| ~~~^~~~~~~~~~~~~~
/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:20:46: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
20 | g[i][j] = min(g[i][j], 1LL);
| ~~~^~~~~~~~~~~~~~
|
s274022707 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, y;
cin >> x >> y;
vector<int64_t> p = { x, y, -x, -y };
int64_t g[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
g[i][j] = 1e9;
if (i == j) {
g[i][j] = 0;
}
if (p[i] == -p[j]) {
g[i][j] = min(g[i][j], 1LL);
}
if (p[i] <= p[j]) {
g[i][j] = min(g[i][j], p[j] - p[i]);
}
}
}
for (int k = 0; k < 4; k++) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
}
}
cout << g[0][1] << endl;
}
| a.cc: In function 'int main()':
a.cc:18:46: error: no matching function for call to 'min(int64_t&, long long int)'
18 | g[i][j] = min(g[i][j], 1LL);
| ~~~^~~~~~~~~~~~~~
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:18:46: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
18 | g[i][j] = min(g[i][j], 1LL);
| ~~~^~~~~~~~~~~~~~
/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:18:46: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
18 | g[i][j] = min(g[i][j], 1LL);
| ~~~^~~~~~~~~~~~~~
|
s740523123 | p03838 | C++ | import java.util.*;
class Main {
public static void main(String args[]) {
try (Scanner sc = new Scanner(System.in)) {
int A = sc.nextInt(), B = sc.nextInt();
if (B > A) {
System.out.println(Math.min(B - A, B + A + 2));
} else {
System.out.println(Math.min(A - B + 2, -A - B + 1));
}
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:15: error: expected ':' before 'static'
4 | public static void main(String args[]) {
| ^~~~~~~
| :
a.cc:4:33: error: 'String' has not been declared
4 | public static void main(String args[]) {
| ^~~~~~
a.cc:15:2: error: expected ';' after class definition
15 | }
| ^
| ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:21: error: expected '{' before '(' token
5 | try (Scanner sc = new Scanner(System.in)) {
| ^
a.cc:5:21: error: expected 'catch' before '(' token
a.cc:5:22: error: 'Scanner' does not name a type
5 | try (Scanner sc = new Scanner(System.in)) {
| ^~~~~~~
a.cc:5:33: error: expected ')' before '=' token
5 | try (Scanner sc = new Scanner(System.in)) {
| ^
a.cc:5:21: note: to match this '('
5 | try (Scanner sc = new Scanner(System.in)) {
| ^
a.cc:5:33: error: expected '{' before '=' token
5 | try (Scanner sc = new Scanner(System.in)) {
| ^
a.cc:5:33: error: expected primary-expression before '=' token
a.cc:5:39: error: expected type-specifier before 'Scanner'
5 | try (Scanner sc = new Scanner(System.in)) {
| ^~~~~~~
|
s772732292 | p03838 | C++ | #include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
ll x,y;
cin >> x >> y;
ll ans = LONG_LONG_MAX;
if(x<=y)ans = min(ans,y-x);
if(-x<=y)ans = min(ans,y+x+1);
if(x<=-y)ans = min(ans,-y-x+1);
if(-x<=-y)ans = min(ans,-y+x+2);
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:23:14: error: 'LONG_LONG_MAX' was not declared in this scope
23 | ll ans = LONG_LONG_MAX;
| ^~~~~~~~~~~~~
|
s053825120 | p03838 | C++ | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
int N,K;
int A[SIZE];
int main(){
REP(i,7){
cin >> A[i];
}
int ans=A[1]+A[0]/2*2+A[3]/2*2+A[4]/2*2;
if((A[0] && A[3] && A[4] )){
ans=max(ans,A[1]+(A[0]-1)/2*2+(A[3]-1)/2*2+(A[4]-1)/2*2+3);
}
cout << ans << endl;
return 0;
} | a.cc:6:7: error: 'SIZE' was not declared in this scope
6 | int A[SIZE];
| ^~~~
a.cc: In function 'int main()':
a.cc:9:24: error: 'A' was not declared in this scope
9 | cin >> A[i];
| ^
a.cc:11:17: error: 'A' was not declared in this scope
11 | int ans=A[1]+A[0]/2*2+A[3]/2*2+A[4]/2*2;
| ^
|
s340996477 | p03838 | C++ | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
LL N,K;
LL A[SIZE];
int main(){
REP(i,7){
cin >> A[i];
}
LL ans=A[1]+A[0]/2*2+A[3]/2*2+A[4]/2*2;
if((A[0] && A[3] && A[4] )){
ans=max(ans,A[1]+(A[0]-1)/2*2+(A[3]-1)/2*2+(A[4]-1)/2*2+3);
}
cout << ans << endl;
return 0;
} | a.cc:5:1: error: 'LL' does not name a type
5 | LL N,K;
| ^~
a.cc:6:1: error: 'LL' does not name a type
6 | LL A[SIZE];
| ^~
a.cc: In function 'int main()':
a.cc:9:24: error: 'A' was not declared in this scope
9 | cin >> A[i];
| ^
a.cc:11:9: error: 'LL' was not declared in this scope
11 | LL ans=A[1]+A[0]/2*2+A[3]/2*2+A[4]/2*2;
| ^~
a.cc:12:13: error: 'A' was not declared in this scope
12 | if((A[0] && A[3] && A[4] )){
| ^
a.cc:13:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
13 | ans=max(ans,A[1]+(A[0]-1)/2*2+(A[3]-1)/2*2+(A[4]-1)/2*2+3);
| ^~~
| abs
a.cc:15:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
15 | cout << ans << endl;
| ^~~
| abs
|
s058597065 | p03838 | C++ | #include <iostream>
#include <cmath>
#include <algorithm>
long long y;
long long dfs(long long n, bool is_prev_reversed) {
int ans = 1e9;
if(n == y) {
return 0;
}
if(y >= n) {
ans = std::min(ans, y - n);
}
if(-y >= n) {
ans = std::min(ans, -y - n + 1);
}
if(!is_prev_reversed) {
ans = std::min(ans, dfs(-n, true) + 1);
}
return ans;
}
int main() {
long long x;
std::cin >> x >> y;
std::cout << dfs(x, false) << std::endl;
} | a.cc: In function 'long long int dfs(long long int, bool)':
a.cc:14:23: error: no matching function for call to 'min(int&, long long int)'
14 | ans = std::min(ans, y - n);
| ~~~~~~~~^~~~~~~~~~~~
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: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:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
14 | ans = std::min(ans, y - n);
| ~~~~~~~~^~~~~~~~~~~~
/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,
from a.cc:3:
/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:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
14 | ans = std::min(ans, y - n);
| ~~~~~~~~^~~~~~~~~~~~
a.cc:17:23: error: no matching function for call to 'min(int&, long long int)'
17 | ans = std::min(ans, -y - n + 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:17:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
17 | ans = std::min(ans, -y - n + 1);
| ~~~~~~~~^~~~~~~~~~~~~~~~~
/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:17:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
17 | ans = std::min(ans, -y - n + 1);
| ~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:20:23: error: no matching function for call to 'min(int&, long long int)'
20 | ans = std::min(ans, dfs(-n, true) + 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:20:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
20 | ans = std::min(ans, dfs(-n, true) + 1);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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:20:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
20 | ans = std::min(ans, dfs(-n, true) + 1);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
|
s608739188 | p03838 | C++ | #include <iosteram>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
if(x<=y)
cout<<y-x<<endl;
else if(x==-y)
cout<<1<<endl;
else
cout<<2+x-y<<endl;
return 0;
} | a.cc:1:10: fatal error: iosteram: No such file or directory
1 | #include <iosteram>
| ^~~~~~~~~~
compilation terminated.
|
s844100209 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int main()
{
ll x,y;
while(cin>>x>>y)
{
ans=(ll)1e18;
//x<=y才能用op:A
if(x<=y)
ans=min(ans,y-x);
if(-x<=y)
ans=min(ans,1+y-(-x));//先变号BA
if(x<=-y)
ans=min(ans,1+(-y-x));//加完后变号AB
if(-x<=-y)
ans=min(ans,1+1+(-y)-(-x));//BAB
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
10 | ans=(ll)1e18;
| ^~~
| abs
|
s584216969 | p03838 | C++ | #include <iostream>
using namespace std;
int main(){
int x, y;
cin >> x >> y;
if(x == y * (-1)){
cout << 1 << endl;
return 0;
}
if(x >= 0 && y >= 0){
if(x < y){
cout << y - x << endl;
} else {
cout << x - y + 2 << endl;
}
}
else if(x < 0 && y < 0){
if(x < y){
cout << y - x << endl;
} else {
cout << x - y + 2 << endl;
}
}
else if(x >= 0 && y < 0){
if(x > (y * (-1))){
cout << x + y + 1 << endl;
} else {
cout << (x + y) * (-1) + 1 << endl;
}
}
else { // x < 0 && y >= 0
if(y > (x * (-1))){
cout << x + y + 1 << endl;
} else {
cout << (x + y) * (-1) + 1 << enld;
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:41:37: error: 'enld' was not declared in this scope
41 | cout << (x + y) * (-1) + 1 << enld;
| ^~~~
|
s352640623 | p03838 | Java | import java.util.Scanner;
public class agc008_a {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long y = sc.nextLong();
sc.close();
long ax = Math.abs(x);
long ay = Math.abs(y);
long clickCnt = 0;
if (x == 0) {
if (0 < y) {
clickCnt = y;
} else {
clickCnt = ay + 1;
}
} else if (y == 0) {
if (0 < x) {
clickCnt = ax;
} else {
clickCnt = ax + 1;
}
} else if (x > 0 && y > 0) {
// 両方正
if (x < y) {
clickCnt = y - x;
} else {
clickCnt = y - x + 2;
}
} else if (x < 0 && y > 0) {
// x:負、y:正
clickCnt = y - x;
} else if (x > 0 && y < 0) {
// x:正、y:負
if (ax < ay) {
clickCnt = ay - ax + 1;
} else {
clickCnt = x + y + 1;
}
} else if (x < 0 && y < 0) {
// x:負、y:負
if (ax < ay) {
clickCnt = 2 + ay - ax;
} else {
clickCnt = ax - ay;
}
}
System.out.println(clickCnt);
}
}
| Main.java:3: error: class agc008_a is public, should be declared in a file named agc008_a.java
public class agc008_a {
^
1 error
|
s545856295 | p03838 | Java | import java.util.Scanner;
public class {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long y = sc.nextLong();
sc.close();
long ax = Math.abs(x);
long ay = Math.abs(y);
long clickCnt;
if (x >= 0 && y >= 0) {
// 両方正
if (x < y) {
clickCnt = y - x;
} else {
clickCnt = y - x + 2;
}
} else if (x < 0 && y >= 0) {
// x:負、y:正
clickCnt = y - x;
} else if (x >= 0 && y < 0) {
// x:正、y:負
if (ax < ay) {
clickCnt = ay - ax + 1;
} else {
clickCnt = x + y + 1;
}
} else {
// x:負、y:負
if (ax < ay) {
clickCnt = 2 + ay - ax;
} else {
clickCnt = ax - ay;
}
}
System.out.println(clickCnt);
}
}
| Main.java:3: error: <identifier> expected
public class {
^
1 error
|
s612486104 | p03838 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
int main(){
int a,b;
cin >>a >> b;
int cnt=0;
if(a < 0){
a *= -1;
b *= -1;
if(a*b > 0) cnt = 2;
}
if(a*b<0) cnt++;
if(abs(a) >= abs(b)){
cout << abs(a+b)+1 <<endl:
}else{
cout << abs(b)-abs(a)+cnt << endl;
}
} | a.cc: In function 'int main()':
a.cc:39:29: error: expected ';' before ':' token
39 | cout << abs(a+b)+1 <<endl:
| ^
| ;
|
s461756067 | p03838 | C++ | #include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ll a,b,c,d;
while(cin>>a>>b)
{
c=0;
if(a<0&&b<0)
{
a=a*(-1);
b=b*(-1);
if(a<b)c=abs(a-b)+2;
else
c=abs(a-b);
}
else if(a<=0&&b>0)
{
if(a==0)c=b;
a=a*(-1);
else if(a<b)
c=abs(a-b)+1;
else c=a+b+1;
}
else if(a>=0&&b<0)
{
b=b*(-1);
if(a==0)c=b;
else
c=abs(a-b)+1;
}
else if(a>0&&b>0)
{
if(a>b)
{
c=(a+b)+1;
}
else c=(abs(a-b));
}
cout<<c<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:12: error: expected '}' before 'else'
23 | else if(a<b)
| ^~~~
a.cc:20:9: note: to match this '{'
20 | {
| ^
a.cc:27:9: error: 'else' without a previous 'if'
27 | else if(a>=0&&b<0)
| ^~~~
a.cc: At global scope:
a.cc:48:5: error: expected unqualified-id before 'return'
48 | return 0;
| ^~~~~~
a.cc:50:1: error: expected declaration before '}' token
50 | }
| ^
|
s680121028 | p03838 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
int main(){
int a,b;
cin >>a >> b;
if(a < 0){
a *= -1;
b *= -1;
}
int cnt=0;
if(a*b<0) cnt++;
else if(a < 0&&b < 0) cnt = 2;
if(abs(a) >= abs(b)){
cout << abs(a+b)+1 <<endl:
}else{
cout << abs(b)-abs(a)+cnt << endl;
}
} | a.cc: In function 'int main()':
a.cc:38:29: error: expected ';' before ':' token
38 | cout << abs(a+b)+1 <<endl:
| ^
| ;
|
s128868024 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int x,y,cnt;
cin>>x>>y;
if(y>x){
if(x*y>=0){
cnt=y-x;
}
else if(x<0&&y>0){
cnt=1+x+y;
}
}
if(x>y){
if(x*y>0){
cnt=2+x-y;
}
else if(x==0){
cnt=-y+1;
}
else if(y==0){
cnt=x+1;
}
else{
cnt=1+x+y
}
}
cout<<cnt
} | a.cc: In function 'int main()':
a.cc:25:16: error: expected ';' before '}' token
25 | cnt=1+x+y
| ^
| ;
26 | }
| ~
a.cc:28:10: error: expected ';' before '}' token
28 | cout<<cnt
| ^
| ;
29 | }
| ~
|
s529510669 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int x,y,cnt;
cin>>x>>y;
if(y>x){
if(x*y>=0){
cnt=y-x;
}
else if(x<0&&y>0){
cnt=1+x+y;
}
}
if(x>y){
if(x*y>0){
cnt=2+x-y;
}
else if(x==0){
cnt=-y+1;
}
else if(y==0){
cnt=x+1;
}
else{
cnt=1+x+y
}
}
} | a.cc: In function 'int main()':
a.cc:25:16: error: expected ';' before '}' token
25 | cnt=1+x+y
| ^
| ;
26 | }
| ~
|
s027956074 | p03838 | C++ |
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
long long x = 1LL << 55;
x *= 2;
long long y = 1LL << 55;
y *= 2;
if(b >= a) x = b - a;
else if(b < a && b < 0 && -b >= a) x = min(x , -b - a + 1);
a *= -1;
if(b >= a) y = b - a + 1;
else if(b < a && b < 0 && -b >= a) y = min(y, -b - a + 2);
printf("%lld\n", min(x, y));
}
| a.cc: In function 'int main()':
a.cc:18:51: error: no matching function for call to 'min(long long int&, int)'
18 | else if(b < a && b < 0 && -b >= a) x = min(x , -b - a + 1);
| ~~~^~~~~~~~~~~~~~~~
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:3:
/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:18:51: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
18 | else if(b < a && b < 0 && -b >= a) x = min(x , -b - a + 1);
| ~~~^~~~~~~~~~~~~~~~
/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,
from a.cc:4:
/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:18:51: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
18 | else if(b < a && b < 0 && -b >= a) x = min(x , -b - a + 1);
| ~~~^~~~~~~~~~~~~~~~
a.cc:21:51: error: no matching function for call to 'min(long long int&, int)'
21 | else if(b < a && b < 0 && -b >= a) y = min(y, -b - a + 2);
| ~~~^~~~~~~~~~~~~~~
/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:21:51: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
21 | else if(b < a && b < 0 && -b >= a) y = min(y, -b - a + 2);
| ~~~^~~~~~~~~~~~~~~
/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:21:51: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
21 | else if(b < a && b < 0 && -b >= a) y = min(y, -b - a + 2);
| ~~~^~~~~~~~~~~~~~~
|
s527637747 | p03838 | C++ | #include<bits/stdc++.h>
using namepsace std;
int main(){
int a,b;
cin>>a>>b;
int ans = 0;
if(a<0&&b>0||a>0&&b<0)
ans++;
if(a>b&&a<0&&b<0)
ans+=2;
a=abs(a);
b=abs(b);
ans+=abs(a-b);
}
| a.cc:2:7: error: expected nested-name-specifier before 'namepsace'
2 | using namepsace std;
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | cin>>a>>b;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
|
s115272180 | p03838 | C++ | #include<bits/stdc++.h>
using namepsace std;
int main(){
int a,b;
cin>>a>>b;
int ans = 0;
if(a<0&&b>0||a>0&&b<0)
ans++;
if(a>b&&a<0&&b<0);
ans+=2;
a=abs(a);
b=abs(b);
ans+=abs(a-b);
}
| a.cc:2:7: error: expected nested-name-specifier before 'namepsace'
2 | using namepsace std;
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | cin>>a>>b;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
|
s710916675 | p03838 | C++ | #include<iostream>
#include<vector>
#include<math.h>
using namespace std;
int main() {
int a, b, ans = 0;
cin >> a >> b;
if((a >= 0 && b < 0) || (a < 0 && b >= 0)) {
if(b != 0)) {
ans++;
}
}else {
if(a > b) ans += 2;
}
if(a < 0) a = -a;
if(b < 0) b = -b;
ans += max(a, b) - min(a, b);
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:10:15: error: expected primary-expression before ')' token
10 | if(b != 0)) {
| ^
|
s074116528 | p03838 | Java | import java.util.Scanner;
2.public class Main {
3.
4. public static void main(String[] args) {
5. // TODO 自動生成されたメソッド・スタブ
6. Scanner stdIn = new Scanner(System.in);
7. int x = stdIn.nextInt();
8. int y = stdIn.nextInt();
9. if (x == y)
10. System.out.println(0);
11. if (x < y) {
12. if (x >= 0 || y <= 0)
13. System.out.println(y - x);
14. if (x < 0 && y > 0) {
15. if ((-x) >= y)
16. System.out.println(y - x);
17. else
18. System.out.println(1 + y +x);
19. }
20. }
21. if (y<x) {
22. if (y >= 0 || x <= 0)
23. System.out.println(2+x-y);
24. if (y < 0 && x > 0) {
25. if ((-y) >= x)
26. System.out.println(1-x - y);
27. else
28. System.out.println(1 + x +y);
29. }
30. }
31.
32. }
33.}
| Main.java:2: error: class, interface, enum, or record expected
2.public class Main {
^
Main.java:3: error: illegal start of type
3.
^
Main.java:5: error: not a statement
5. // TODO ???????????????
^
Main.java:5: error: ';' expected
5. // TODO ???????????????
^
Main.java:7: error: not a statement
7. int x = stdIn.nextInt();
^
Main.java:7: error: ';' expected
7. int x = stdIn.nextInt();
^
Main.java:8: error: not a statement
8. int y = stdIn.nextInt();
^
Main.java:8: error: ';' expected
8. int y = stdIn.nextInt();
^
Main.java:9: error: not a statement
9. if (x == y)
^
Main.java:9: error: ';' expected
9. if (x == y)
^
Main.java:10: error: not a statement
10. System.out.println(0);
^
Main.java:10: error: ';' expected
10. System.out.println(0);
^
Main.java:11: error: not a statement
11. if (x < y) {
^
Main.java:11: error: ';' expected
11. if (x < y) {
^
Main.java:12: error: not a statement
12. if (x >= 0 || y <= 0)
^
Main.java:12: error: ';' expected
12. if (x >= 0 || y <= 0)
^
Main.java:13: error: not a statement
13. System.out.println(y - x);
^
Main.java:13: error: ';' expected
13. System.out.println(y - x);
^
Main.java:14: error: not a statement
14. if (x < 0 && y > 0) {
^
Main.java:14: error: ';' expected
14. if (x < 0 && y > 0) {
^
Main.java:15: error: not a statement
15. if ((-x) >= y)
^
Main.java:15: error: ';' expected
15. if ((-x) >= y)
^
Main.java:16: error: not a statement
16. System.out.println(y - x);
^
Main.java:16: error: ';' expected
16. System.out.println(y - x);
^
Main.java:17: error: not a statement
17. else
^
Main.java:17: error: ';' expected
17. else
^
Main.java:18: error: not a statement
18. System.out.println(1 + y +x);
^
Main.java:18: error: ';' expected
18. System.out.println(1 + y +x);
^
Main.java:17: error: 'else' without 'if'
17. else
^
Main.java:19: error: not a statement
19. }
^
Main.java:19: error: ';' expected
19. }
^
Main.java:20: error: not a statement
20. }
^
Main.java:20: error: ';' expected
20. }
^
Main.java:21: error: not a statement
21. if (y<x) {
^
Main.java:21: error: ';' expected
21. if (y<x) {
^
Main.java:22: error: not a statement
22. if (y >= 0 || x <= 0)
^
Main.java:22: error: ';' expected
22. if (y >= 0 || x <= 0)
^
Main.java:23: error: not a statement
23. System.out.println(2+x-y);
^
Main.java:23: error: ';' expected
23. System.out.println(2+x-y);
^
Main.java:24: error: not a statement
24. if (y < 0 && x > 0) {
^
Main.java:24: error: ';' expected
24. if (y < 0 && x > 0) {
^
Main.java:25: error: not a statement
25. if ((-y) >= x)
^
Main.java:25: error: ';' expected
25. if ((-y) >= x)
^
Main.java:26: error: not a statement
26. System.out.println(1-x - y);
^
Main.java:26: error: ';' expected
26. System.out.println(1-x - y);
^
Main.java:27: error: not a statement
27. else
^
Main.java:27: error: ';' expected
27. else
^
Main.java:28: error: not a statement
28. System.out.println(1 + x +y);
^
Main.java:28: error: ';' expected
28. System.out.println(1 + x +y);
^
Main.java:27: error: 'else' without 'if'
27. else
^
Main.java:29: error: not a statement
29. }
^
Main.java:29: error: ';' expected
29. }
^
Main.java:30: error: not a statement
30. }
^
Main.java:30: error: ';' expected
30. }
^
Main.java:31: error: not a statement
31.
^
Main.java:31: error: ';' expected
31.
^
Main.java:33: error: illegal start of type
33.}
^
57 errors
|
s130442324 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
void test1(){
int x,y;
cin>>x>>y;
if(abs(x)==abs(y)&&a/b==-1){
cout<<-1<<endl;
return;
}
if(x<=y){
if(x<0&&y>=0) cout<<abs(abs(y)-(abs(x)))+1<<endl;
else cout<<y-x<<endl;
return;
}else{
if(abs(x)>abs(y)){ //x<0&&y<0||x>0&&y<0
if(x>0&&y>0){
cout<<abs(abs(y)-(abs(x)))+2<<endl;
}else{ //x>0&&y<0
cout<<abs(abs(y)-(abs(x)))+1<<endl;
}
return;
}
else{
if(x<0&&y<0){
cout<<x-y+2<<endl;
}else{
if(x>0&&y<0){
cout<<abs(abs(x)-abs(y))+1<<endl;
}
else cout<<x-y+1<<endl;
}
return;
}
}
}
int main()
{
test1();
return 0;
}
| a.cc: In function 'void test1()':
a.cc:7:24: error: 'a' was not declared in this scope
7 | if(abs(x)==abs(y)&&a/b==-1){
| ^
a.cc:7:26: error: 'b' was not declared in this scope
7 | if(abs(x)==abs(y)&&a/b==-1){
| ^
|
s167604301 | p03838 | C | #include <stdio.h>
int main(void) {
int x, y;
int button = 0;
scanf("%d %d", &x, &y);
if (y == x*-1) button = 1;
if (x < y){
if (x > 0) button = y - x;
else button = y - x*-1 + 1;
else {
if ((x > 0 && y > 0) || (x < 0 && y < 0)) button = x - y + 2;
else if (x == 0) button = y*-1 + 1;
else if (y == 0) button = x+1;
else button = x + y + 1;
}
printf("%d\n", button);
return 0;
} | main.c: In function 'main':
main.c:14:9: error: expected '}' before 'else'
14 | else {
| ^~~~
|
s933390124 | p03838 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
long long int x, y;
long long int anscnt;
int main(){
scanf("%lld %lld", &x, &y);
if (y < x){
if (y > 0){
anscnt = (x - y) + 2;
}
else if (x < 0){
anscnt = (x - y) + 2;
}
else{
if (x > (y * -1)){
anscnt = (y - x * -1) + 1;
}
else{
anscnt = (y * -1 - x) + 1;
}
}
}
else if (x == y){
anscnt = 0;
}
else if (x < y){
if (x >= 0){
anscnt = y - x;
}
else if (y <= 0){
anscnt = y - x;
}
else{
if (x > (y * -1)){
anscnt = (y - x * -1) + 1;
}
else{
anscnt = (y * -1 - x) + 1;
}
}
}
printf("%lld\n", anscnt);
| a.cc: In function 'int main()':
a.cc:46:34: error: expected '}' at end of input
46 | printf("%lld\n", anscnt);
| ^
a.cc:9:11: note: to match this '{'
9 | int main(){
| ^
|
s584106349 | p03838 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
long long int x, y;
long long int anscnt;
int main(){
scanf("%lld %lld", &x, &y);
if (y < x){
if (y > 0){
anscnt = (x - y) + 2;
}
else if (x < 0){
anscnt = (x - y) + 2;
}
else{
if (x > (y * -1)){
anscnt = (y - x * -1) + 1;
}
else{
anscnt = (y * -1 - x) + 1;
}
}
}
else if (x == y){
anscnt = 0;
}
else if (x < y){
if (x >= 0){
anscnt = y - x;
}
else if (y =< 0){
anscnt = y - x;
}
else{
if (x > (y * -1)){
anscnt = (y - x * -1) + 1;
}
else{
anscnt = (y * -1 - x) + 1;
}
}
}
printf("%lld\n", anscnt);
return 0;
} | a.cc: In function 'int main()':
a.cc:34:29: error: expected primary-expression before '<' token
34 | else if (y =< 0){
| ^
|
s811481198 | p03838 | C++ | #include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
LL x, y;
int main(void) {
cin >> x >> y;
LL ans = INF;
if (-x == y) {
cout << 1 << endl;
return 0;
}
if (x < 0 && y < 0) {
if (x > y) {
ans = llabs(llabs(x) - llabs(y)) + 2;
ans = min(ans, )
} else {
ans = min(ans, y - x);
}
} else if (x < 0) {
if (-x < y) {
ans = y - x;
} else {
ans = y + x + 1;
}
} else if (y < 0) {
if (x < -y) {
ans = llabs(x + y) + 1;
} else {
ans = 1 + y + x;
}
} else {
if (x < y) {
ans = y - x;
} else {
ans = 1 + y + x;
ans = min(ans, -y + x + 2);
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:73:28: error: expected primary-expression before ')' token
73 | ans = min(ans, )
| ^
|
s944786204 | p03838 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int x = scn.nextInt();
int y = scn.nextInt();
int cnt = 0;
if(Math.abs(x) > Math.abs(y) && x > 0 && y >= 0) {
x = -x;
cnt++;
} else if(Math.abs(x) > Math.abs(y) && x > 0 && y <= 0) {
x = -x;
cnt++;
} else if(Math.abs(x) < Math.abs(y) && x <= 0 && y > 0) {
x = -x;
cnt++;
} else if(Math.abs(x) < Math.abs(y) && x < 0 && y <= 0) {
x = -x;
cnt++;
}
while(Math.abs(x) != Math.abs(y)){
x++;
cnt++;
}
if(x == -y && (x > 0 || x < 0) cnt++;
System.out.println(cnt);
}
} | Main.java:29: error: ')' expected
if(x == -y && (x > 0 || x < 0) cnt++;
^
1 error
|
s652897541 | p03838 | C++ | int main(){
int x, y;
cin >> x >> y;
if ((x >= 0) && (y >= x)){
cout << (y-x);
}else if ((x >= 0) && (y < x)){
if (y >= 0){
cout << (y-(-x)+1);
}else if (y >= (-x)){
cout << (y-(-x)+1);
}else{
cout << (-y-x+1);
}
}else if ((x < 0) && (y >= x)){
if (y <= 0){
cout << (y-x);
}else{
cout << min(y-x,y-(-x)+1);
}
}else if ((x < 0) && (y < x)){
cout << (x-y+2);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
3 | cin >> x >> y;
| ^~~
a.cc:5:5: error: 'cout' was not declared in this scope
5 | cout << (y-x);
| ^~~~
a.cc:8:7: error: 'cout' was not declared in this scope
8 | cout << (y-(-x)+1);
| ^~~~
a.cc:10:7: error: 'cout' was not declared in this scope
10 | cout << (y-(-x)+1);
| ^~~~
a.cc:12:7: error: 'cout' was not declared in this scope
12 | cout << (-y-x+1);
| ^~~~
a.cc:16:7: error: 'cout' was not declared in this scope
16 | cout << (y-x);
| ^~~~
a.cc:18:7: error: 'cout' was not declared in this scope
18 | cout << min(y-x,y-(-x)+1);
| ^~~~
a.cc:18:15: error: 'min' was not declared in this scope; did you mean 'main'?
18 | cout << min(y-x,y-(-x)+1);
| ^~~
| main
a.cc:21:5: error: 'cout' was not declared in this scope
21 | cout << (x-y+2);
| ^~~~
|
s137629346 | p03838 | Java | import java.io.*;
import java.util.StringTokenizer;
public class TaskA {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Taska solver = new Taska();
solver.solve(1, in, out);
out.close();
}
static class Taska {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int x = in.nextInt();
int y = in.nextInt();
if (x == y) {
out.println(0);
return;
}
int d = Math.abs(Math.abs(x) - Math.abs(y));
int ans = d;
// make abs equal
if (Math.abs(x + d) == Math.abs(y)) {
if ((x + d) != y) ans++;
out.println(ans);
return;
}
ans++;
x *= -1;
if ((x + d) != y) ans++;
out.println(ans);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
| Main.java:4: error: class TaskA is public, should be declared in a file named TaskA.java
public class TaskA {
^
1 error
|
s767018647 | p03838 | C++ | #include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)
using namespace std;
int main(){
ll x, y;
cin >> x >> y;
if(x < y){
cout << y-x << endl;
}
else if(x > y){
else if(0 < x && y < 0){
cout << 1 + abs(y+x) << endl;
}
else{
cout << 2 + abs(y-x) << endl;
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:9: error: expected '}' before 'else'
19 | else if(0 < x && y < 0){
| ^~~~
a.cc:18:19: note: to match this '{'
18 | else if(x > y){
| ^
a.cc: At global scope:
a.cc:28:5: error: expected unqualified-id before 'return'
28 | return 0;
| ^~~~~~
a.cc:29:1: error: expected declaration before '}' token
29 | }
| ^
|
s423873746 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
#define int long long int
int main(){
// setnow;
int x,y;
cin >> x >> y;
if(x >= 0 && y >= 0){
if(x < y)
return cout << y - x, 0;
if(x > y)
return cout << 2 + x - y, 0;
}
if(x < 0 && y < 0){
if(x < y)
return cout << abs(x - y), 0;
if(x > y)
return cout << 2 + abs(x - y), 0;
}
if(x >= 0 && y < 0){
return cout << 1 + abs(x - (abs(y))), 0;
}
if(x < 0 && y >= 0){
return cout << 1 + abs(abs(x)- y), 0;
}
// cout << fixed << time;
return 0;
}
| a.cc:11:23: error: '::main' must return 'int'
11 | #define int long long int
| ^~~
a.cc:14:1: note: in expansion of macro 'int'
14 | int main(){
| ^~~
|
s385477685 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit ) for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;
//#define DEBUG
ll power(ll x,ll y){
ll t=1;
while(y>0){
if(y%2) y-=1,t=t*x%mod;
else y/=2,x=x*x%mod;
}
return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif
int main(){
ll x,y; scanf("%lld%lld",&x,&y);
if(y>=0){
ll ans = INF;
if(x<=y) ans = min(ans,1ll*y-x);
if(-x<=y) ans = min(ans,1ll*y+x+1);
if(abs(x)>=abs(y)){
if(x<0) ans=min(ans,abs(x)-abs(y)+1);
else abs=min(ans,2+abs(x)-abs(y));
}
printf("%lld\n",ans);
}else{
if(x<=y) printf("%lld\n",y-x);
else{
if(abs(x)>=abs(y)){
ll ans = 1+abs(x)-abs(y);
printf("%lld\n",ans);
}else{
ll ans = min(1+abs(y)-x,2+abs(y)+x);
printf("%lld\n",ans);
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:45:39: error: overloaded function with no contextual type information
45 | else abs=min(ans,2+abs(x)-abs(y));
| ^
|
s982220005 | p03838 | C++ | #include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
//const int mod=1e9+7;
//const int N=1e6+7;
int main(){
fast;
int t=1;
//cin>>t;
while(t--){
ll x,y,ans=LLONG_MAX;
cin>>x>>y;
if(x>=0 and y>=0){
if(x<=y) ans=y-x+1;
else ans=y+x+1;
}else if(x>=0 and y<0){
if(x>=abs(y)) ans=y+x+1;
else ans=abs(y)-x+1;
}else if(x<0 and y>=0){
if(abs(x)<=y) ans=y-abs(x)+1;
else ans=abs(x)-y+1;
}else if(x<0 and y<0){
if(x<=y) ans=y-x;
else ans=abs(y)-abs(x)+2;
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:20: error: 'LLONG_MAX' was not declared in this scope
37 | ll x,y,ans=LLONG_MAX;
| ^~~~~~~~~
a.cc:16:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
15 | #include <numeric>
+++ |+#include <climits>
16 |
|
s116169405 | p03838 | C++ | CE test | a.cc:1:1: error: 'CE' does not name a type
1 | CE test
| ^~
|
s305212880 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 999999999
#define MOD 1000000007
int main()
{
int x,y;
cin >> x;
cin >> y;
if((x < y) && (x >= 0 || y <= 0)){
cout << y-x;
}else if((y < x) && (x < 0 || y > 0)){
cout << x-y+2;
}else if((y < x) && (x == 0 || y == 0){
cout << x-y+1;
}else{
cout << abs(x+y)+1;
}
}
| a.cc: In function 'int main()':
a.cc:18:47: error: expected ')' before '{' token
18 | }else if((y < x) && (x == 0 || y == 0){
| ~ ^
| )
a.cc:23:1: error: expected primary-expression before '}' token
23 | }
| ^
|
s412016149 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(void){
ll x, y; cin >> x >> y;
if(x >= 0 && y >= 0 && x <= y){
printf("%lld\n", y - x);
}else if(x >= 0 && y < 0 && x >= abs(y)){
printf("%lld\n", x - abs(y) + 1);
}else if(x >= 0 && y < 0 && x < abs(y)){
printf("%lld\n", abs(y) - x + 1);
}else if(x < 0 && y >= 0 && abs(x) >= y){
printf("%lld\n", abs(x) - y + 1);
}else if(x < 0 && y >= 0 && abs(x) < y){
printf("%lld\n", y - abs(x) + 1);
}else if(x < 0 && y < 0 && x <= y){
printf("%lld\n", y - x);
}else if(x < 0 && y < 0 && x > y){
printf("%lld\n", x - y + 2);
}else if(x >= 0 && y >= 0 && x > y){
printf("%lld\n", y + x + 1);
}else{
int p++;
rep(i, 1000000000000000){
p++;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:22: error: expected initializer before '++' token
39 | int p++;
| ^~
a.cc:41:25: error: 'p' was not declared in this scope
41 | p++;
| ^
|
s767168274 | p03838 | C++ | import java.util.Arrays;
import java.util.Scanner;
public class Main {
MyScanner sc = new MyScanner();
Scanner sc2 = new Scanner(System.in);
long start = System.currentTimeMillis();
long fin = System.currentTimeMillis();
final int MOD = 1000000007;
int[] dx = { 1, 0, 0, -1 };
int[] dy = { 0, 1, -1, 0 };
void run() {
int x = sc.nextInt();
int y = sc.nextInt();
int min = Integer.MAX_VALUE / 2;
if (x < 0 && y < 0) {
if (x <= y) {
min = Math.min(min, y - x);
} else {
min = Math.min(min, 1 + (x - y) + 1);
}
} else if (x < 0 && y >= 0) {
min = Math.min(min, y - x);
if (-x <= y)
min = Math.min(min, y - (-x) + 1);
} else if (y < 0 && x >= 0) {
min = Math.min(min, Math.abs(x - Math.abs(y)) + 1);
} else {
if (x <= y) {
min = Math.min(min, y - x);
} else {
min = Math.min(min, x - y + 1);
}
}
System.out.println(min);
}
public static void main(String[] args) {
new Main().run();
}
void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}
void debug2(int[][] array) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.print(array[i][j]);
}
System.out.println();
}
}
boolean inner(int h, int w, int limH, int limW) {
return 0 <= h && h < limH && 0 <= w && w < limW;
}
void swap(int[] x, int a, int b) {
int tmp = x[a];
x[a] = x[b];
x[b] = tmp;
}
// find minimum i (k <= a[i])
int lower_bound(int a[], int k) {
int l = -1;
int r = a.length;
while (r - l > 1) {
int mid = (l + r) / 2;
if (k <= a[mid])
r = mid;
else
l = mid;
}
// r = l + 1
return r;
}
// find minimum i (k < a[i])
int upper_bound(int a[], int k) {
int l = -1;
int r = a.length;
while (r - l > 1) {
int mid = (l + r) / 2;
if (k < a[mid])
r = mid;
else
l = mid;
}
// r = l + 1
return r;
}
long gcd(long a, long b) {
return a % b == 0 ? b : gcd(b, a % b);
}
long lcm(long a, long b) {
return a * b / gcd(a, b);
}
boolean palindrome(String s) {
for (int i = 0; i < s.length() / 2; i++) {
if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
return false;
}
}
return true;
}
class MyScanner {
int nextInt() {
try {
int c = System.in.read();
while (c != '-' && (c < '0' || '9' < c))
c = System.in.read();
if (c == '-')
return -nextInt();
int res = 0;
do {
res *= 10;
res += c - '0';
c = System.in.read();
} while ('0' <= c && c <= '9');
return res;
} catch (Exception e) {
return -1;
}
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
String next() {
try {
StringBuilder res = new StringBuilder("");
int c = System.in.read();
while (Character.isWhitespace(c))
c = System.in.read();
do {
res.append((char) c);
} while (!Character.isWhitespace(c = System.in.read()));
return res.toString();
} catch (Exception e) {
return null;
}
}
int[] nextIntArray(int n) {
int[] in = new int[n];
for (int i = 0; i < n; i++) {
in[i] = nextInt();
}
return in;
}
int[][] nextInt2dArray(int n, int m) {
int[][] in = new int[n][m];
for (int i = 0; i < n; i++) {
in[i] = nextIntArray(m);
}
return in;
}
double[] nextDoubleArray(int n) {
double[] in = new double[n];
for (int i = 0; i < n; i++) {
in[i] = nextDouble();
}
return in;
}
long[] nextLongArray(int n) {
long[] in = new long[n];
for (int i = 0; i < n; i++) {
in[i] = nextLong();
}
return in;
}
char[][] nextCharField(int n, int m) {
char[][] in = new char[n][m];
for (int i = 0; i < n; i++) {
String s = sc.next();
for (int j = 0; j < m; j++) {
in[i][j] = s.charAt(j);
}
}
return in;
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Arrays;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.Scanner;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
4 | public class Main {
| ^~~~~~
|
s899659505 | p03838 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#define INT long long
#define MOD 1000000007
#define oo 987654321
#define OO 999999987654321ll
using namespace std;
INT x, y, ans;
queue<int> q;
int main()
{
cin>>x>>y;
ans = (y-x)>=0?(y-x):OO;
ans = min(ans, (-y-x)+1>=0?(-y-x)+1:OO);
ans = min(ans, (y+x)+1>=0?(y+x)+1:OO);
ans = min(ans, (-y+x)+2>=0?(-y+x)+2:OO)
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:44: error: expected ';' before 'cout'
23 | ans = min(ans, (-y+x)+2>=0?(-y+x)+2:OO)
| ^
| ;
24 | cout<<ans<<endl;
| ~~~~
|
s030027440 | p03838 | C++ | #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
long long abs(long long a){
return (a>0)?a:-a;
}
int main(){
long long x,y,cnt=0;
cin>>x>>y;
if((y<0 && x>0)||(y>0 && x<0)){x*=-1;cnt++;}
cout<<cnt+((y<x)?2:0)+abs(y-x)<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:34: error: call of overloaded 'abs(long long int)' is ambiguous
14 | cout<<cnt+((y<x)?2:0)+abs(y-x)<<endl;
| ~~~^~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:6:11: note: candidate: 'long long int abs(long long int)'
6 | long long abs(long long a){
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s381396732 | p03838 | C++ | #include<iostream>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
if(x>=0^y>=0){
cout<<fabs(x-y)+1<<endl;
}else{
cout<<fabs(x-y)<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:15: error: 'fabs' was not declared in this scope; did you mean 'labs'?
8 | cout<<fabs(x-y)+1<<endl;
| ^~~~
| labs
a.cc:10:15: error: 'fabs' was not declared in this scope; did you mean 'labs'?
10 | cout<<fabs(x-y)<<endl;
| ^~~~
| labs
|
s006700522 | p03839 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
is >> p.first >> p.second;
return is;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
for (auto& x : v) {
is >> x;
}
return is;
}
template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
for (auto& x : v) {
os << x << " ";
}
os << "\n";
return os;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, k;
cin >> n >> k;
vector<int64_t> a(n);
cin >> a;
vector<int64_t> p(n + 1, 0), pp(n + 1, 0), sp(n + 1, 0);
for (int i = 1; i <= n; ++i) p[i] = p[i - 1] + a[i - 1];
for (int i = 1; i <= n; ++i) {
pp[i] = pp[i - 1] + max(a[i - 1], 0ll);
sp[i] = sp[i - 1] + max(a[n - i], 0ll);
}
// cout << pp << sp << endl;
int64_t max_ans = 0;
for (int ks = 0; ks + k <= n; ++ks) {
// cout << ks << " " << pp[ks] << " " << sp[n - ks - k] << " " << p[ks + k] - p[ks] << endl;
max_ans = max(max_ans, pp[ks] + sp[n - ks - k] + max(0ll, p[ks + k] - p[ks]));
}
cout << max_ans;
}
| a.cc: In function 'int main()':
a.cc:50:32: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
50 | pp[i] = pp[i - 1] + max(a[i - 1], 0ll);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
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:50:32: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
50 | pp[i] = pp[i - 1] + max(a[i - 1], 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: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:50:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
50 | pp[i] = pp[i - 1] + max(a[i - 1], 0ll);
| ~~~^~~~~~~~~~~~~~~
a.cc:51:32: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
51 | sp[i] = sp[i - 1] + max(a[n - i], 0ll);
| ~~~^~~~~~~~~~~~~~~
/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:32: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
51 | sp[i] = sp[i - 1] + max(a[n - 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
/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:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
51 | sp[i] = sp[i - 1] + max(a[n - i], 0ll);
| ~~~^~~~~~~~~~~~~~~
a.cc:57:61: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
57 | max_ans = max(max_ans, pp[ks] + sp[n - ks - k] + max(0ll, p[ks + k] - p[ks]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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:57:61: 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'})
57 | max_ans = max(max_ans, pp[ks] + sp[n - ks - k] + max(0ll, p[ks + k] - p[ks]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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:57:61: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
57 | max_ans = max(max_ans, pp[ks] + sp[n - ks - k] + max(0ll, p[ks + k] - p[ks]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
|
s547131514 | p03839 | C++ | /**
* author: nok0
* created: 2020.09.13 22:45:14
**/
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(int i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V<V<T>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define VEC(type, name, size)\
V<type> name(size);\
IN(name)
#define VVEC(type, name, h, w)\
VV<type> name(h, V<type>(w));\
IN(name)
#define INT(...)\
int __VA_ARGS__;\
IN(__VA_ARGS__)
#define LL(...)\
ll __VA_ARGS__;\
IN(__VA_ARGS__)
#define STR(...)\
string __VA_ARGS__;\
IN(__VA_ARGS__)
#define CHAR(...)\
char __VA_ARGS__;\
IN(__VA_ARGS__)
#define DOUBLE(...)\
DOUBLE __VA_ARGS__;\
IN(__VA_ARGS__)
#define LD(...)\
LD __VA_ARGS__;\
IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p){
is >> p.first >> p.second;
return is;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p){
os << p.first << " " << p.second;
return os;
}
template <class T>
ostream &operator<<(ostream &os, const V<T> &v){
REP(i, SZ(v)){
if(i) os << " ";
os << v[i];
}
return os;
}
//debug
template <typename T>
void view(const V<T> &v){
cerr << "{ ";
for(const auto &e : v){
cerr << e << ", ";
}
cerr << "\b\b }";
}
template <typename T>
void view(const VV<T> &vv){
cerr << "{\n";
for(const auto &v : vv){
cerr << "\t";
view(v);
cerr << "\n";
}
cerr << "}";
}
template <typename T, typename U>
void view(const V<pair<T, U>> &v){
cerr << "{\n";
for(const auto &c : v) cerr << "\t(" << c.first << ", " << c.second << ")\n";
cerr << "}";
}
template <typename T, typename U>
void view(const map<T, U> &m){
cerr << "{\n";
for(auto &t : m) cerr << "\t[" << t.first << "] : " << t.second << "\n";
cerr << "}";
}
template <typename T, typename U>
void view(const pair<T, U> &p){ cerr << "(" << p.first << ", " << p.second << ")";}
template <typename T>
void view(const set<T> &s) {
cerr << "{ ";
for(auto &t : s) {
view(t);
cerr << ", ";
}
cerr << "\b\b }";
}
template <typename T>
void view(T e) { cerr << e;}
#ifdef LOCAL
void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
view(H);
cerr << ", ";
debug_out(T...);
}
#define debug(...) \
do{ \
cerr << __LINE__ << " [" << #__VA_ARGS__ << "] : ["; \
debug_out(__VA_ARGS__); \
cerr << "\b\b]\n"; \
} while(0)
#else
#define debug(...) (void(0))
#endif
template <class T> V<T> press(V<T> &x){
V<T> res = x;
sort(all(res));
res.erase(unique(all(res)), res.end());
REP(i, SZ(x)){
x[i] = lower_bound(all(res), x[i]) - res.begin();
}
return res;
}
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T divup(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const int inf = 1e9;
const ll INF = 1e18;
#pragma endregion
int main(){
INT(n, k);
VEC(ll, a, n);
V<ll> rui(n + 1, 0);
REP(i, n) rui[i + 1] = a[i] + rui[i];
V<ll> prui(n + 1, 0);
REP(i, n) prui[i + 1] = max(a[i], 0ll) + prui[i];
ll res = 0;
REP(i, n - k + 1){
ll pre = max(rui[i + k] - rui[i], 0ll);
debug(pre);
pre += prui[n] - (prui[i + k] - prui[i]);
debug(pre);
chmax(res, pre);
}
print(res);
} | a.cc:10:9: fatal error: atcoder/all: No such file or directory
10 | #include<atcoder/all>
| ^~~~~~~~~~~~~
compilation terminated.
|
s866591854 | p03839 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
const int mxn = 100002;
int n, k;
ll a[mxn];
ll s[2][mxn];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int t = 0; t < 2; t++){
for(int i = 1; i <= n; i++){
s[t][i] = max(0, a[i]) + s[t][i - 1];
}
reverse(a, a + n + 2);
}
reverse(s[1], s[1] + n + 2);
for(int i = 1; i <= n; i++) a[i] += a[i - 1];
ll ret = 0xcfcfcfcfcfcfcfcf;
for(int i = 1; i <= n - k + 1; i++){
ret = max(ret, s[0][i - 1] + s[1][i + k] + max(0, a[i + k - 1] - a[i - 1]));
}
cout << ret << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:26:38: error: no matching function for call to 'max(int, long long int&)'
26 | s[t][i] = max(0, a[i]) + s[t][i - 1];
| ~~~^~~~~~~~~
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:26:38: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
26 | s[t][i] = max(0, a[i]) + s[t][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: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:26:38: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
26 | s[t][i] = max(0, a[i]) + s[t][i - 1];
| ~~~^~~~~~~~~
a.cc:36:63: error: no matching function for call to 'max(int, long long int)'
36 | ret = max(ret, s[0][i - 1] + s[1][i + k] + max(0, a[i + k - 1] - a[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:36:63: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
36 | ret = max(ret, s[0][i - 1] + s[1][i + k] + max(0, a[i + k - 1] - 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
/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:36:63: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
36 | ret = max(ret, s[0][i - 1] + s[1][i + k] + max(0, a[i + k - 1] - a[i - 1]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s552921828 | p03839 | C++ | # include <iostream>
using namespace std;
long long N;
long long K;
long long a[100005];
long long prefixsum[100005];
long long pprefixsum[100005];
long long tempsum;
long long ans=0;
long long totalsum;
long long psum(long long left, long long right) //sum from left to right indexes//
{
return prefixsum[right]-prefixsum[left-1];
}
long long ppsum(long long left, long long right)
{
return pprefixsum[right]-pprefixsum[left-1];
}
long long main()
{
cin>>N>>K;
for (long long i=1; i<=N; i++)
{
cin>>a[i];
totalsum=totalsum+a[i];
}
for (long long i=1; i<=N; i++)
{
prefixsum[i]=prefixsum[i-1]+a[i];
}
for (long long i=1; i<=N; i++)
{
pprefixsum[i]=pprefixsum[i-1];
if (a[i]>0)
{
pprefixsum[i]=pprefixsum[i]+a[i];
}
}
for (long long i=1; i<=N-K+1; i++)
{
tempsum=psum(i, i+K-1);
if (tempsum>=0)
{
tempsum=tempsum+ppsum(1, i-1)+ppsum(i+K, N);
ans=max(ans, tempsum);
}
else
{
ans=max(ans, ppsum(1, i-1)+ppsum(i+K, N));
}
}
cout<<ans;
} | cc1plus: error: '::main' must return 'int'
|
s624686655 | p03839 | C++ | /**
* @FileName a.cpp
* @Author kanpurin
* @Created 2020.08.20 03:41:51
**/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
int n;cin >> n;
int k;cin >> k;
vector<ll> sum(n+1,0),best(n+1,0);
for (int i = 0; i < n; i++) {
int a;cin >> a;
sum[i + 1] = sum[i] + a;
best[i + 1] = best[i] + max(a,0);
}
ll ans = 0;
cerr << sum << endl;
cerr << best << endl;
for (int i = 0; i < n-k+1; i++) {
ans = max(ans,best[i] + best[n] - best[i+k] + max(0LL,sum[i+k] - sum[i]));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:10: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<long long int>')
21 | cerr << sum << endl;
| ~~~~ ^~ ~~~
| | |
| | std::vector<long long int>
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:7:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
|
s329500490 | p03839 | C++ | /**
* @FileName a.cpp
* @Author kanpurin
* @Created 2020.08.20 03:41:51
**/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
int n;cin >> n;
int k;cin >> k;
vector<ll> sum(n+1,0),best(n+1,0);
for (int i = 0; i < n; i++) {
int a;cin >> a;
sum[i + 1] = sum[i] + a;
best[i + 1] = best[i] + max(a,0);
}
ll ans = 0;
cerr << sum << endl;
cerr << best << endl;
for (int i = 0; i < n-k+1; i++) {
ans = max(ans,best[i] + best[n] - best[i+k] + max(0LL,sum[i+k] - sum[i]));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:10: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<long long int>')
21 | cerr << sum << endl;
| ~~~~ ^~ ~~~
| | |
| | std::vector<long long int>
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:7:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
|
s552002680 | p03839 | C++ | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<ll> a(n), sum(n+1), ss(n+1);
rep(i, n) {
cin >> a[i];
ss[i+1] = ss[i] + a[i];
sum[i+1] = max(sum[i], sum[i] + a[i]);
}
ll ans = 0;
rep(i, n-k+1) {
ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ll(ss[i+k]-ss[i]));
chmax(ans, l+r+mid);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:40:56: error: no matching function for call to 'max(long long int, ll)'
40 | ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ll(ss[i+k]-ss[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: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:40:56: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'long int'})
40 | ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ll(ss[i+k]-ss[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:40:56: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
40 | ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ll(ss[i+k]-ss[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
|
s084275559 | p03839 | C++ | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<ll> a(n), sum(n+1), ss(n+1);
rep(i, n) {
cin >> a[i];
ss[i+1] = ss[i] + a[i];
sum[i+1] = max(sum[i], sum[i] + a[i]);
}
ll ans = 0;
rep(i, n-k+1) {
ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ss[i+k]-ss[i]);
chmax(ans, l+r+mid);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:40:56: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
40 | ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ss[i+k]-ss[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: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:40:56: 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'})
40 | ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ss[i+k]-ss[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:40:56: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
40 | ll l = sum[i], r = sum[n] - sum[i+k], mid = max(0LL, ss[i+k]-ss[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~
|
s532076109 | p03839 | C++ | #include <bits/stdc++.h>
using namespace std;
#ifdef zxc
#include <sys/resource.h>
#include "debug.h"
#include "profile.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif
using ll = int64_t;
using ld = long double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const ll MOD = 1e9 + 7;
using cd = complex<double>;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
bool close_dbl(ld a, ld b) {
return abs(a - b) < EPS;
}
struct pt {
ll x, y, z;
};
pt operator-(const pt &fi, const pt &se) {
return {fi.x - se.x, fi.y - se.y, fi.z - se.z};
}
pt cross(const pt &fi, const pt &se) {
return {fi.y * se.z - fi.z * se.y, -(fi.x * se.z - fi.z * se.x), fi.y * se.z - fi.z * se.y};
}
int dumb(vector<pt> pts) {
int n = pts.size();
int ans = 0;
for (int i = 0; i < n; ++i) {
for (int e = i + 1; e < n; ++e) {
pt cock = pts[e] - pts[i];
int cur = 0;
for (int j = 0; j < n; ++j) {
auto vv = cross(cock, pts[j] - pts[i]);
cur += (vv.x == 0) && (vv.y == 0) && (vv.z == 0);
}
ans = max(ans, cur);
}
}
return ans;
}
signed main() {
#ifdef zxc
struct rlimit rl;
const rlim_t kStackSize = 512L * 1024L * 1024L;
assert(!getrlimit(RLIMIT_STACK, &rl));
rl.rlim_cur = kStackSize;
assert(!setrlimit(RLIMIT_STACK, &rl));
freopen("../input.txt", "r", stdin);
// freopen("../kolya_output.txt", "w", stdout);
#else
// mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
// freopen("", "r", stdin);
// freopen("hack.out", "w", stdout);
#endif
// auto solve = [](int _) {
// int n;
// cin >> n;
// int ans = min(n, 2);
// vector<pt> pts(n);
// for (int i = 0; i < n; ++i) {
// cin >> pts[i].x >> pts[i].y >> pts[i].z;
// }
// for (int i = 0; i < n; ++i) {
// vector<int> p(n);
// iota(p.begin(), p.end(), 0);
// p.erase(p.begin() + i);
// vector<ld> ang(n);
// for (int j = 0; j < n; ++j) {
// if (j == i) {
// continue;
// }
// ang[j] = atan2(pts[j].y - pts[i].y, pts[j].x - pts[i].x);
// }
// sort(p.begin(), p.end(), [&](int i, int j) {
// return ang[i] < ang[j];
// });
// for (int j = 0, e = 0; e < p.size(); e = j) {
// vector<ld> vals;
// while (j < p.size() && close_dbl(ang[p[j]], ang[p[e]])) {
// vals.push_back(atan2(pts[p[j]].z - pts[i].z, pts[p[j]].x - pts[i].x));
// ++j;
// }
// sort(vals.begin(), vals.end());
// int cur = 2;
// ld was = vals[0];
// for (int i = 1; i < vals.size(); ++i) {
// if (close_dbl(was, vals[i])) {
// ++cur;
// ans = max(ans, cur);
// } else {
// cur = 2;
// was = vals[i];
// }
// }
// }
// }
//
// cout << ans;
// };
pFunction solve = [](int _) {
int n;
cin >> n;
int k;
cin >> k;
vector<int> a(n + 1);
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
vector<int> pref_pos(n + 1);
vector<int> suff_pos(n + 2);
for (int i = 1; i <= n; ++i) {
pref_pos[i] = pref_pos[i - 1];
if (a[i] > 0) {
pref_pos[i] += a[i];
}
}
suff_pos.back() = max(a.back(), 0);
for (int i = n - 1; i >= 1; --i) {
suff_pos[i] = suff_pos[i + 1];
if (a[i] > 0) {
suff_pos[i] += a[i];
}
}
vector<ll> pref(n + 1);
for (int i = 1; i <= n; ++i) {
pref[i] = pref[i - 1] + a[i];
}
ll ans = 0;
for (int i = 1; i + k - 1 <= n; ++i) {
ll cur = pref[i + k - 1] - pref[i - 1];
ans = max(ans, max<ll>(cur, 0ll) + pref_pos[i - 1] + suff_pos[i + k]);
}
cout << ans;
};
fast_io();
cout.precision(9);
cout << fixed;
auto start = chrono::steady_clock::now();
auto end = chrono::steady_clock::now();
solve(1);
debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);
}
| a.cc: In function 'int main()':
a.cc:130:5: error: 'pFunction' was not declared in this scope
130 | pFunction solve = [](int _) {
| ^~~~~~~~~
a.cc:172:5: error: 'solve' was not declared in this scope
172 | solve(1);
| ^~~~~
|
s624789911 | p03839 | 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);
int n, k;
cin >> n >> k;
std::vector<int64_t> sums(n);
std::vector<int64_t> pos(n);
for (int i = 0; i < n; i++) {
int64_t x;
cin >> x;
sums[i] = x + (i > 0 ? sums[i - 1] : 0LL);
pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 0LL);
}
auto get_value = [&](auto& v, int l, int r) {
if (l == 0) {
return v[r];
}
return v[r] - v[l - 1];
};
int64_t answer = 0;
for (int i = 0; i < n; i++) {
if (i >= k - 1) {
auto pos_sum = get_value(pos, i - k + 1, i);
auto sum_sum = get_value(sums, i - k + 1, i);
answer = max(answer, pos.back() - pos_sum + max(sum_sum, 0LL));
}
}
cout << answer << endl;
}
| a.cc: In function 'int main()':
a.cc:29:21: error: no matching function for call to 'max(int64_t&, long long int)'
29 | pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 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:29:21: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
29 | pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 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: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:29:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
29 | pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 0LL);
| ~~~^~~~~~~~
a.cc:45:60: error: no matching function for call to 'max(long int&, long long int)'
45 | answer = max(answer, pos.back() - pos_sum + max(sum_sum, 0LL));
| ~~~^~~~~~~~~~~~~~
/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:60: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
45 | answer = max(answer, pos.back() - pos_sum + max(sum_sum, 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
/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:60: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
45 | answer = max(answer, pos.back() - pos_sum + max(sum_sum, 0LL));
| ~~~^~~~~~~~~~~~~~
|
s908408268 | p03839 | 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);
int n, k;
cin >> n >> k;
std::vector<int64_t> sums(n);
std::vector<int64_t> pos(n);
for (int i = 0; i < n; i++) {
int64_t x;
cin >> x;
sums[i] = x + (i > 0 ? sums[i - 1] : 0LL);
pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 0LL);
}
auto get_value = [&](auto& v, int l, int r) {
if (l == 0) {
return v[r];
}
return v[r] - v[l - 1];
};
int64_t answer = 0;
for (int i = 0; i < n; i++) {
if (i >= k - 1) {
auto pos_sum = get_value(pos, i - k + 1, i);
auto sum_sum = get_value(sums, i - k + 1, i);
answer = max(answer, pos.back() - pos_sum + max(sum_sum, 0LL));
}
}
cout << answer << endl;
}
| a.cc: In function 'int main()':
a.cc:29:21: error: no matching function for call to 'max(int64_t&, long long int)'
29 | pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 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:29:21: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
29 | pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 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: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:29:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
29 | pos[i] = max(x, 0LL) + (i > 0 ? pos[i - 1]: 0LL);
| ~~~^~~~~~~~
a.cc:45:60: error: no matching function for call to 'max(long int&, long long int)'
45 | answer = max(answer, pos.back() - pos_sum + max(sum_sum, 0LL));
| ~~~^~~~~~~~~~~~~~
/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:60: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
45 | answer = max(answer, pos.back() - pos_sum + max(sum_sum, 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
/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:60: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
45 | answer = max(answer, pos.back() - pos_sum + max(sum_sum, 0LL));
| ~~~^~~~~~~~~~~~~~
|
s780008110 | p03839 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<long long> csum_a(n + 1,0), csum_b(n + 1,0);
for (int i = 1; i <= n; ++i) {
long long tmp;
cin >> tmp;
csum_a[i] = csum_a[i - 1] + tmp;
csum_b[i] = csum_b[i - 1] + max(tmp, 0LL);
}
auto ans = INT64_MIN;
for (int i = 1; i + k - 1 <= n; ++i) {
auto left = csum_b[i - 1];
auto center = max(csum_a[i + k - 1] - csum_a[i - 1], 0LL);
auto right = csum_b[n] - csum_b[i + k - 1];
ans = max(ans, left + center + right);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:18: error: no matching function for call to 'max(long int&, long long int)'
22 | ans = max(ans, left + center + right);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:22:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
22 | ans = max(ans, left + center + right);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:22:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
22 | ans = max(ans, left + center + right);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s432061221 | p03839 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<long long> csum_a(n + 1), csum_b(n + 1);
for (int i = 1; i <= n; ++i) {
long long tmp;
cin >> tmp;
csum_a[i] = csum_a[i - 1] + tmp;
csum_b[i] = csum_b[i - 1] + max(tmp, 0LL);
}
auto ans = INT64_MIN;
for (int i = 1; i + k - 1 <= n; ++i) {
auto left = csum_b[i - 1];
auto center = max(csum_a[i + k - 1] - csum_a[i - 1], 0LL);
auto right = csum_b[n] - csum_b[i + k - 1];
ans = max(ans, left + center + right);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:18: error: no matching function for call to 'max(long int&, long long int)'
22 | ans = max(ans, left + center + right);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:22:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
22 | ans = max(ans, left + center + right);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:22:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
22 | ans = max(ans, left + center + right);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s761589059 | p03839 | C++ | eval"N,K,*A="+`dd`.split*?,
*r=(*q=b=c=i=0)
p A.flat_map{|a|q<<c+=a*-1[a];r<<b+=a;q[K]?[q[~K]-c+[b-r[~K],0].max]:[]}.max+c | a.cc:1:15: error: stray '`' in program
1 | eval"N,K,*A="+`dd`.split*?,
| ^
a.cc:1:18: error: stray '`' in program
1 | eval"N,K,*A="+`dd`.split*?,
| ^
a.cc:1:1: error: 'eval' does not name a type
1 | eval"N,K,*A="+`dd`.split*?,
| ^~~~
a.cc:3:73: error: expected unqualified-id before '.' token
3 | p A.flat_map{|a|q<<c+=a*-1[a];r<<b+=a;q[K]?[q[~K]-c+[b-r[~K],0].max]:[]}.max+c
| ^
|
s876974988 | p03839 | C++ | #include<bits/stdc++.h>
using namespace std;
long long N, K, a[100000], parsum1[100001], parsum2[100001];
long long ans = -(1LL<<60);;
int main(){
cin >> N >> K;
for(int i = 0; i < N; ++i) cin >> a[i];
long long sum1 = 0, sum2 = 0;
for(long long i = 1; i <= N; ++i){
sum1 += a[i-1]; parsum1[i] = sum1;
if(a[i-1] >= 0) sum2 += a[i-1];
parsum2[i] = sum2;
}
long long lsum = 0, csum = 0, rsum = 0;
for(long long i = 0; i < N - K; ++i){
csum = max(0, parsum1[i+K] - parsum1[i+1]);
lsum = parsum2[i];
rsum = parsum2[N] - parsum2[i+K];
ans = max(ans, lsum + csum + rsum);
cout << lsum << "+" << csum << "+" << rsum << "=" << lsum + csum + rsum << endl;
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:21:27: error: no matching function for call to 'max(int, long long int)'
21 | csum = max(0, parsum1[i+K] - parsum1[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:21:27: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
21 | csum = max(0, parsum1[i+K] - parsum1[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:21:27: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
21 | csum = max(0, parsum1[i+K] - parsum1[i+1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s347218027 | p03839 | C++ | package main
import (
"fmt"
"math"
)
func max(a, b int) int {
if a < b {
return b
}
return a
}
func max64(a, b int64) int64 {
if a < b {
return b
}
return a
}
func main() {
var n, k int
fmt.Scan(&n, &k)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
s := make([]int64, n+1)
w := make([]int64, n+1)
for i := 0; i < n; i++ {
s[i+1] = s[i] + int64(a[i])
w[i+1] = w[i] + int64(max(a[i], 0))
}
ans := int64(math.MinInt64)
for i := 0; i <= n-k; i++ {
x := w[n] - (w[i+k] - w[i])
x += max64(s[i+k]-s[i], 0)
ans = max64(ans, x)
}
fmt.Println(ans)
}
| a.cc:1:1: error: 'package' does not name a type
1 | package main
| ^~~~~~~
a.cc:15:1: error: 'func' does not name a type
15 | func max64(a, b int64) int64 {
| ^~~~
a.cc:22:1: error: 'func' does not name a type
22 | func main() {
| ^~~~
|
s092341231 | p03839 | C++ | #include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int64_t> s(n + 1);
vector<int64_t> w(n + 1);
for (int i = 0; i < n; i++) {
s[i + 1] = s[i] + (int64_t)a[i];
w[i + 1] = w[i] + (int64_t)max(a[i], 0);
}
int64_t ans = numeric_limits<int64_t>::lowest();
for (int i = 0; i <= n - k; i++) {
int64_t sum = w[n] - (w[i + k] - w[i]);
sum += max(s[i + k] - s[i], 0LL);
ans = max(ans, sum);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:15: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type, long long int)'
25 | sum += max(s[i + k] - s[i], 0LL);
| ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
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:15: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
25 | sum += 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:
/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:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
25 | sum += max(s[i + k] - s[i], 0LL);
| ~~~^~~~~~~~~~~~~~~~~~~~~~
|
s256268153 | p03839 | C++ | #include <cstdint>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int64_t> s(n + 1);
vector<int64_t> w(n + 1);
for (int i = 0; i < n; i++) {
s[i + 1] = s[i] + (int64_t)a[i];
w[i + 1] = w[i] + (int64_t)max(a[i], 0);
}
int64_t ans = numeric_limits<int64_t>::lowest();
for (int i = 0; i <= n - k; i++) {
int64_t sum = w[n] - (w[i + k] - w[i]);
sum += max(s[i + k] - s[i], 0LL);
ans = max(ans, sum);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:15: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type, long long int)'
24 | sum += 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: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:24:15: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
24 | sum += 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
|
s436517914 | p03839 | C++ | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
using namespace std;
bool prime_(int n){
if(n==1){
return false;
}else if(n==2){
return true;
}else{
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
}
long long gcd_(long long a, long long b){
if(a<b){
swap(a,b);
}
if(a%b==0){
return b;
}else{
return gcd_(b,a%b);
}
}
long long lcm_(long long x, long long y){
return (x/gcd_(x,y))*y;
}
int main(){
int n,k;
cin>>n>>k;
long long a[n];
REP(i,n){
cin>>a[i];
}
long long s[n],ps[n];
REP(i,n){
if(i==0){
s[i] = a[i];
ps[i] = max(0,a[i]);
}else{
s[i] = s[i-1] + a[i];
ps[i] = ps[i-1] + max(0,a[i]);
}
}
long long ans = 0;
long long mid;
long long temp;
REP(i,n-k){
if(i==0){
mid = max(0,s[i+k-1]);
}else{
mid = max(0,s[i+k-1]-s[i-1]);
}
temp = mid;
if(i==0){
;
}else{
temp += ps[i-1];
}
temp += ps[n-1] - ps[i+k-1];
ans = max(ans,temp);
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:18: error: no matching function for call to 'max(int, long long int&)'
58 | ps[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:58:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
58 | ps[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:58:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
58 | ps[i] = max(0,a[i]);
| ~~~^~~~~~~~
a.cc:61:28: error: no matching function for call to 'max(int, long long int&)'
61 | ps[i] = ps[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:61:28: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
61 | ps[i] = ps[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:61:28: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
61 | ps[i] = ps[i-1] + max(0,a[i]);
| ~~~^~~~~~~~
a.cc:70:16: error: no matching function for call to 'max(int, long long int&)'
70 | mid = max(0,s[i+k-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:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
70 | mid = max(0,s[i+k-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:70:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
70 | mid = max(0,s[i+k-1]);
| ~~~^~~~~~~~~~~~
a.cc:72:16: error: no matching function for call to 'max(int, long long int)'
72 | mid = max(0,s[i+k-1]-s[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:72:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
72 | mid = max(0,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
/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:72:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
72 | mid = max(0,s[i+k-1]-s[i-1]);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s713091583 | p03839 | C++ | #include <iostream>
#include <vector>
int main()
{
// input
int N, K;
std::cin >> N >> K;
std::vector<long long> a(N);
for(int i=0; i<N; i++) scanf(" %lld", &a[i]);
std::vector<long long> sum_l(N), sum_r(N);
sum_l[0] = a[0] > 0 ? a[0] : 0;
sum_r[N-1] = a[N-1] > 0 ? a[N-1] : 0;
for(int i=1; i<N; i++){
sum_l[i] = sum_l[i-1];
sum_r[N-1-i] = sum_r[N-i];
if(a[i] > 0) sum_l[i] += a[i];
if(a[N-1-i] > 0) sum_r[N-1-i] += a[N-1-i];
}
std::vector<long long> sum_K(N, 0);
for(int i=0; i<K; i++) sum_K[0] += a[i];
for(int i=1; i+K-1<N; i++) sum_K[i] = sum_K[i-1] - a[i-1] + a[i+K-1];
long long max = 0;
for(int i=0; i+K+1<N; i++){
long long tmp = sum_l[i] + sum_r[i+K+1];
if(sum_K[i+1] > 0) tmp += sum_K[i+1];
if(max < tmp) max = tmp;
}
if(K<N && max < sum_r[K]) max = sum_r[K];
if(K<N && max < sum_K[0] + sum_r[K]) max = sum_K[0] + sum_r[K];
if(K<N && max < sum_l[N-1-K]) max = sum_l[N-1-K];
if(K<N && max < sum_l[N-1-K] + sum_K[N-K]) max = sum_l[N-1-K] + sum_K[N-K];
if(K==N && max < sum_K[0]) max = sum_K[0];
// output
std::cout << max << std::endl; | a.cc: In function 'int main()':
a.cc:38:35: error: expected '}' at end of input
38 | std::cout << max << std::endl;
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s678916490 | p03839 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void print(const vector<int> &v) {
for(auto x : v) {
cout << x << " ";
}
cout << endl;
}
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
VL a(n), b(n+1, 0), c(n+1, 0);
rep(i, n){
cin >> a[i];
}
rep(i, n) {
b[i+1] = b[i] + a[i];
c[i+1] = c[i] + max(0, a[i]);
}
ll ans = -LINF;
for(int i = 0; i + k <= n; ++i) {
int left = c[i] - c[0];
int right = c[n] - c[i + k];
if(b[i + k] - b[i] >= 0) {
ans = max(ans, b[i + k] - b[i] + left + right);
}
else {
ans = max(ans, left + right);
}
}
out(ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:44:24: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
44 | c[i+1] = c[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:44:24: 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'})
44 | c[i+1] = c[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:44:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
44 | c[i+1] = c[i] + max(0, a[i]);
| ~~~^~~~~~~~~
a.cc:54:16: error: no matching function for call to 'max(ll&, int)'
54 | ans = max(ans, left + right);
| ~~~^~~~~~~~~~~~~~~~~~~
/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:54:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
54 | ans = max(ans, left + right);
| ~~~^~~~~~~~~~~~~~~~~~~
/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:54:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
54 | ans = max(ans, left + right);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s390396163 | p03839 | C++ | #pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}
constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, k; cin>>n>>k;
vector<int> a(n);
for(int i=0; i<n; i++) cin>>a[i];
vector<ll> asum(n+1, 0);
vector<ll> b(n+1, 0);
for(int i=0; i<n; i++){
asum[i+1] = asum[i] + a[i];
b[i+1] = b[i] + max(a[i], 0LL);
}
ll ans = 0;
for(int i=0; i+k-1<n; i++){
ll range = asum[i+k] - asum[i];
ll a_black = (b[n] - b[i+k]) + (b[i]);
chmax(ans, max(range, 0LL) + a_black);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:57:28: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int)'
57 | b[i+1] = b[i] + max(a[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: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:57:28: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
57 | b[i+1] = b[i] + max(a[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:13:
/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:57:28: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
57 | b[i+1] = b[i] + max(a[i], 0LL);
| ~~~^~~~~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.