submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s818229859 | p03715 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define eps 0.0000001
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x7fffffff;
const int maxn = 1e6+10;
const int mod = 1e9+7;
void init() {
}
void solve() {
int H, W;
cin >> H >> W;
if(H%3==0|| W%3==0) {
cout << "0" << endl;
return;
} else {
if(W>H)
swap(H, W);
LL ans = INF;
LL s1, s2, s3, s4, s5, s6;
for(int i = 1; i<=H; i++) {
s1 = i*W;
if(W%2==0) {
s4 = s3 = (H-i)*(W/2);
} else {
s3 = (H-i)*(W/2);
s4 = (H-i)*((W+1)/2);
}
// s3 = (H-i)*(W/2);
// s4 = s2 - s3;
LL Min = min(min(s1, s3), s4);
LL Max = max(max(s1, s3), s4);
ans = min(ans, Max-Min);
if((H-i)%2==0) {
s5 = s6 = ((H-i)/2) * W;
} else {
s5 = ((H-i)/2)*W;
s6 = ((H-i+1)/2)*W;
}
// s5 = ((H-i)/2) * W;
// s6 = s2 - s5;
Min = min(min(s1, s5), s6);
Max = max(max(s1, s5), s6);
ans = min(ans, Max-Min);
}
for(int i = 1; i<=W; i++) {
s1 = i*H;
if(H%2==0) {
s4 = s3 = (W-i)*(H/2);
} else {
s3 = (W-i)*(H/2);
s4 = (W-i)*((H+1)/2);
}
// s3 = (H-i)*(W/2);
// s4 = s2 - s3;
int Min = min(min(s1, s3), s4);
int Max = max(max(s1, s3), s4);
ans = min(ans, Max-Min);
if((W-i)%2==0) {
s5 = s6 = ((W-i)/2) * H;
} else {
s5 = ((W-i)/2)*H;
s6 = ((W-i+1)/2)*H;
}
// s5 = ((H-i)/2) * W;
// s6 = s2 - s5;
Min = min(min(s1, s5), s6);
Max = max(max(s1, s5), s6);
ans = min(ans, Max-Min);
}
cout << ans << endl;
}
}
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif // LOCAL
init();
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:80:22: error: no matching function for call to 'min(LL&, int)'
80 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
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:80:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
80 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:13:
/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:80:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
80 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
a.cc:92:22: error: no matching function for call to 'min(LL&, int)'
92 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:92:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
92 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:92:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
92 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
|
s745779964 | p03715 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define eps 0.0000001
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x7fffffff;
const int maxn = 1e6+10;
const int mod = 1e9+7;
void init() {
}
void solve() {
int H, W;
cin >> H >> W;
if(H%3==0|| W%3==0) {
cout << "0" << endl;
return;
} else {
if(W>H)
swap(H, W);
LL ans = INF;
LL s1, s2, s3, s4, s5, s6;
for(int i = 1; i<=H; i++) {
s1 = i*W;
if(W%2==0) {
s4 = s3 = (H-i)*(W/2);
} else {
s3 = (H-i)*(W/2);
s4 = (H-i)*((W+1)/2);
}
// s3 = (H-i)*(W/2);
// s4 = s2 - s3;
int Min = min(min(s1, s3), s4);
int Max = max(max(s1, s3), s4);
ans = min(ans, Max-Min);
if((H-i)%2==0) {
s5 = s6 = ((H-i)/2) * W;
} else {
s5 = ((H-i)/2)*W;
s6 = ((H-i+1)/2)*W;
}
// s5 = ((H-i)/2) * W;
// s6 = s2 - s5;
Min = min(min(s1, s5), s6);
Max = max(max(s1, s5), s6);
ans = min(ans, Max-Min);
}
for(int i = 1; i<=W; i++) {
s1 = i*H;
if(H%2==0) {
s4 = s3 = (W-i)*(H/2);
} else {
s3 = (W-i)*(H/2);
s4 = (W-i)*((H+1)/2);
}
// s3 = (H-i)*(W/2);
// s4 = s2 - s3;
int Min = min(min(s1, s3), s4);
int Max = max(max(s1, s3), s4);
ans = min(ans, Max-Min);
if((W-i)%2==0) {
s5 = s6 = ((W-i)/2) * H;
} else {
s5 = ((W-i)/2)*H;
s6 = ((W-i+1)/2)*H;
}
// s5 = ((H-i)/2) * W;
// s6 = s2 - s5;
Min = min(min(s1, s5), s6);
Max = max(max(s1, s5), s6);
ans = min(ans, Max-Min);
}
cout << ans << endl;
}
}
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif // LOCAL
init();
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:53:22: error: no matching function for call to 'min(LL&, int)'
53 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
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:53:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
53 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:13:
/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:53:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
53 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
a.cc:65:22: error: no matching function for call to 'min(LL&, int)'
65 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:65:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
65 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:65:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
65 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
a.cc:80:22: error: no matching function for call to 'min(LL&, int)'
80 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:80:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
80 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:80:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
80 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
a.cc:92:22: error: no matching function for call to 'min(LL&, int)'
92 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:92:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
92 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
/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:92:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
92 | ans = min(ans, Max-Min);
| ~~~^~~~~~~~~~~~~~
|
s981777881 | p03715 | C++ | #include<bits/stdc++.h>
#define LL long long
const LL INF=1e20;
LL sum[4]
LL t[3];
using namespace std;
LL n,m;
int main()
{
scanf("%lld%lld",&n,&m);
if(n%3==0||m%3==0)
{
printf("0");
}
sum[0]=(LL)0;
sum[1]=(LL)0;
sum[2]=INF;
sum[3]=INF;
else
{
LL x=m/2;
LL y=m-m/2;
LL a=n/2;
LL b=n-n/2;
sum[0]=n*((m-2*(m/3))-m/3);
sum[1]=m*((n-2*(n/3))-n/3);
for(LL i=1;i<n;i++)
{
t[0]=i*y;
t[1]=i*x;
t[2]=m*n-t[0]-t[1];
sort(t,t+3);
sum[2]=min(sum[2],t[2]-t[0]);
}
for(LL i=1;i<m;i++)
{
t[0]=i*b;
t[1]=i*a;
t[2]=m*n-t[0]-t[1];
sort(t,t+3);
sum[3]=min(sum[3],t[2]-t[0]);
}
sort(sum,sum+4);
printf("%lld",sum[0]);
}
return 0;
} | a.cc:3:14: warning: overflow in conversion from 'double' to 'long long int' changes value from '1.0e+20' to '9223372036854775807' [-Woverflow]
3 | const LL INF=1e20;
| ^~~~
a.cc:2:12: error: expected initializer before 'long'
2 | #define LL long long
| ^~~~
a.cc:5:1: note: in expansion of macro 'LL'
5 | LL t[3];
| ^~
a.cc: In function 'int main()':
a.cc:15:9: error: 'sum' was not declared in this scope
15 | sum[0]=(LL)0;
| ^~~
a.cc:19:9: error: 'else' without a previous 'if'
19 | else
| ^~~~
a.cc:29:25: error: 't' was not declared in this scope
29 | t[0]=i*y;
| ^
a.cc:37:25: error: 't' was not declared in this scope
37 | t[0]=i*b;
| ^
|
s979911117 | p03715 | C | #include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int f(int a,int b,int c){
return MAX(a,MAX(b,c))-MIN(a,MIN(b,c));
}
int main(){
int a,b,c,d,e,g,min;
scanf("%d %d",&a,&b);
if(a%3==0||b%3==0){
print("0\n");
return 0;
}
c=a/3;
d=b/3;
e=a/2;
g=b/2;
min=1e9;
min=MIN(min,f(c*b,(a-c)*e,(a-c)*(b-e)));
min=MIN(min,f((a-c)*b,a*e,a*(b-e)));
printf("%d\n",min);
return 0;
}
| main.c: In function 'main':
main.c:11:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
11 | print("0\n");
| ^~~~~
| printf
|
s262464793 | p03715 | C++ | #include <bits//stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll ans=9999999999999999,h,w;
cin>>h>>w;
if(h%3==0||w%3==0){
ans=0;
}
if(w%3==1){
ll a=(w-1)/3;
if(a>0&&w-a>0)
ans=min(ans,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))));
a=(w+2)/3;
if(a>0&&w-a>0)
ans=min(ans,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))));
}
if(w%3==2){
ll a=(w-2)/3;
if(a>0&&w-a>0)
ans=min(ans,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))))));
a=(w+1)/3;
if(a>0&&w-a>0)
ans=min(ans,max(0,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))))));
}
if(h%3==1){
ll a=(h-1)/3;
if(a>0&&h-a>0)
ans=min(ans,max(0,max(0,max(0,max(0,max(0,abs(max(w*a,(h-a)*(ll)ceil(w/2.0))-min(w*a,(h-a)*(ll)floor((w/2.0))))));
a=(h+2)/3;
if(a>0&&h-a>0)
ans=min(ans,max(0,abs(max(w*a,(h-a)*(ll)ceil(w/2.0))-min(w*a,(h-a)*(ll)floor((w/2.0))))));
}
if(h%3==2){
ll a=(h-2)/3;
if(a>0&&h-a>0)
ans=min(ans,max(0,max(0,abs(max(w*a,(h-a)*(ll)ceil(w/2.0))-min(w*a,(h-a)*(ll)floor((w/2.0))))));
a=(h+1)/3;
if(a>0&&h-a>0)
ans=min(ans,max(0,abs(max(w*a,(h-a)*(ll)ceil(w/2.0))-min(w*a,(h-a)*(ll)floor((w/2.0))))));
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:46: error: no matching function for call to 'max(int, long long int)'
13 | ans=min(ans,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:13:46: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
13 | ans=min(ans,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:13:46: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
13 | ans=min(ans,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:16:40: error: no matching function for call to 'max(int, long long int)'
16 | ans=min(ans,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:16:40: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
16 | ans=min(ans,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:16:40: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
16 | ans=min(ans,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:21:52: error: no matching function for call to 'max(int, long long int)'
21 | ans=min(ans,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:21:52: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
21 | ans=min(ans,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:21:52: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
21 | ans=min(ans,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0))))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:24:58: error: no matching function for call to 'max(int, long long int)'
24 | ans=min(ans,max(0,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:24:58: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
24 | ans=min(ans,max(0,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:24:58: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
24 | ans=min(ans,max(0,max(0,max(0,max(0,abs(max(h*a,(w-a)*(ll)ceil(h/2.0))-min(h*a,(w-a)*(ll)floor((h/2.0)))))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:64: error: no matching function for call to 'max(int, long long int)'
29 | ans=min(ans,max(0,max(0,max(0,max(0,max(0,abs(max(w*a,(h-a)*(ll)ceil(w/2.0))-min(w*a,(h-a)*(ll)floor((w/2.0))))));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:29:64: note: deduced conflicting types for parameter 'const _Tp' (' |
s638566178 | p03715 | C | #include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int f(int a,int b,int c){
return MAX(a,MAX(b,c))-MIN(a,MIN(b,c));
}
int main(){
int a,b,c,d,e,g;
scanf("%d %d",&a,&b);
if(a%3==0||b%3==0){
print("0\n");
return 0;
}
c=a/3;
d=b/3;
e=a/2;
g=b/2;
min=1e9;
min=MIN(min,f(c*b,(a-c)*e,(a-c)*(b-e)));
min=MIN(min,f((a-c)*b,a*e,a*(b-e)));
printf("%d\n",min);
return 0;
}
| main.c: In function 'main':
main.c:11:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
11 | print("0\n");
| ^~~~~
| printf
main.c:18:3: error: 'min' undeclared (first use in this function); did you mean 'main'?
18 | min=1e9;
| ^~~
| main
main.c:18:3: note: each undeclared identifier is reported only once for each function it appears in
|
s355456762 | p03715 | C++ | #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int h0,w0,ANS[1000000],h,w;
int ans(int r){
int s[3];
s[0]=h*r;
w-=r;
if(h>w){int t=w;w=h;h=t;}
if(h%2==0||w%2==0){
s[1]=w*h/2;
s[2]=w*h/2;
}else{
s[1]=h*(w/2);
s[2]=h*w-s[1];
}
sort(s,s+3);
return s[2]-s[0];
}
int main(){
cin>>h0>>w0;
h=h0;w=w0;
//if(h0%3==0||w0%3==0)cout<<0<<endl;
else{
for(int i=0;i<w0;i++){
h=h0;w=w0;
ANS[i]=ans(i);
}
sort(ANS,ANS+w0);
int a1=ANS[0];
for(int i=0;i<h0;i++){
h=w0;w=h0;
ANS[i]=ans(i);
}
sort(ANS,ANS+h0);
int a2=ANS[0];
cout<<min(a1,a2)<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:5: error: 'else' without a previous 'if'
26 | else{
| ^~~~
|
s106601797 | p03715 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define eps 0.0000001
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x7fffffff;
const int maxn = 1e6+10;
const int mod = 1e9+7;
void init() {
}
void solve() {
int H, W;
cin >> H >> W;
if(H%3==0|| W%3==0) {
cout << "0" << endl;
return;
} else {
int ans = inf;
int s1, s2, s3, s4;
for(int i = 1; i<=H; i++) {
s1 = i*W;
s2 = (H-i)*W;
s3 = (H-i)*(W/2);
s4 = s2 - s3;
int Min = min(min(s1, s3), s4);
int Max = max(max(s1, s3), s4);
ans = min(ans, Max-Min);
s5 = ((H-i)/2) * W;
s6 = s2 - s5;
Min = min(min(s1, s5), s6);
Max = max(max(s1, s5), s6);
ans = min(ans, Max-Min);
}
for(int i = 1; i<=W; i++) {
s1 = i*H;
s2 = (W-i)*H;
s3 = (W-i)*(H/2);
s4 = s2 - s3;
int Min = min(min(s1, s3), s4);
int Max = max(max(s1, s3), s4);
ans = min(ans, Max-Min);
s5 = ((W-i)/2)*H;
s6 = s2 - s5;
Min = min(min(s1, s5), s6);
Max = max(max(s1, s5), s6);
ans = min(ans, Max-Min);
}
cout << ans << endl;
}
}
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif // LOCAL
init();
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:49:13: error: 's5' was not declared in this scope; did you mean 's4'?
49 | s5 = ((H-i)/2) * W;
| ^~
| s4
a.cc:50:13: error: 's6' was not declared in this scope; did you mean 's4'?
50 | s6 = s2 - s5;
| ^~
| s4
a.cc:68:13: error: 's5' was not declared in this scope; did you mean 's4'?
68 | s5 = ((W-i)/2)*H;
| ^~
| s4
a.cc:69:13: error: 's6' was not declared in this scope; did you mean 's4'?
69 | s6 = s2 - s5;
| ^~
| s4
|
s298778201 | p03715 | C++ | #include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
int s = 0;
if (h % 3 && w % 3) {
s = min(h, w);
int i = h / 2;
for (int j = w / 3 - 1; j <= w / 3 + 2; j++) {
int a[] = {h * j, i * (w - j), (h - i) * (w - j)};
sort(a, a + 3);
s = min(s, a[2] - a[0]);
}
{
int t = h;
h = w;
w = t;
}
int i = h / 2;
for (int j = w / 3 - 1; j <= w / 3 + 2; j++) {
int a[] = {h * j, i * (w - j), (h - i) * (w - j)};
sort(a, a + 3);
s = min(s, a[2] - a[0]);
}
}
cout << s << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:21: error: redeclaration of 'int i'
23 | int i = h / 2;
| ^
a.cc:12:21: note: 'int i' previously declared here
12 | int i = h / 2;
| ^
|
s731079109 | p03715 | C++ | #include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)
namespace {
struct input_returnner {
ll N; input_returnner(ll N_ = 0) :N(N_) {}
template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
template<typename T> operator T() const { T res; cin >> res; return res; }
template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
};
template<typename T> input_returnner in() { return in<T>(); }
input_returnner in() { return input_returnner(); }
input_returnner in(ll N) { return std::move(input_returnner(N)); }
}
const ll MOD = 1e9 + 7;
struct ModInt {
ll v = 0;
ModInt() {}
template<class T> ModInt(const T& right) {
v = right;
if (v >= 0) v %= MOD;
else v += ((-v) / MOD + 1)*MOD;
v %= MOD;
}
void operator = (const ModInt& right) { v = right.v; }
template<class T> void operator = (const T& right) {
v = right;
if (v >= 0) v %= MOD;
else v = v += ((-v) / MOD + 1)*MOD;
v %= MOD;
}
ModInt operator + (const ModInt& right) { return (v + right.v) % MOD; }
ModInt operator - (const ModInt& right) { return (MOD - (v - right.v)); }
ModInt operator * (const ModInt& right) { return (v * right.v) % MOD; }
ModInt operator / (const ModInt& right) { return v / right.v; }
void operator += (const ModInt& right) { v = (v + right.v) % MOD; }
void operator -= (const ModInt& right) { v = (MOD - (v - right.v)); }
void operator *= (const ModInt& right) { v = (v* right.v) % MOD; }
void operator /= (const ModInt& right) { v = v / right.v; }
bool operator == (const ModInt& right) { return v == right.v; }
};
ostream& operator << (ostream& os, const ModInt& value) {
os << value.v;
return os;
}
void solve();
/// ---template---
signed main(void) {
SETUP;
solve();
return 0;
}
#define int long long
int getA(int w,int h, int x){
vector<int> a(3);
int y = h / 2;
a[0] = h*x;
a[1] = y*(w - x);
a[2] = (h - y)*(w - x);
return max(ALL(a)) - min(ALL(a));
}
int f(int w, int h) {
int res = 1e10+1;
if (h >= 3 and h % 3 != 0) res = w*(h / 3);
int H = h / 2;
double x = H*w / double(h + H);
res = min(abs(H*(w - int(ceil(x))) - int(ceil(x))*h), res);
H = ceil(h / 2.0);
x = H*w / (h + H);
res = min(abs(H*(w - int(x)) - int(x)*h), res);
return res;
}
void solve() {
int w, h; cin >> w >> h;
cout << min(f(w, h), f(h, w)) << endl;
} | a.cc: In function 'long long int f(long long int, long long int)':
a.cc:119:13: error: expected primary-expression before 'long'
119 | #define int long long
| ^~~~
a.cc:135:30: note: in expansion of macro 'int'
135 | res = min(abs(H*(w - int(ceil(x))) - int(ceil(x))*h), res);
| ^~~
a.cc:135:29: error: expected ')' before 'long'
135 | res = min(abs(H*(w - int(ceil(x))) - int(ceil(x))*h), res);
| ~ ^
| )
a.cc:119:13: error: expected primary-expression before 'long'
119 | #define int long long
| ^~~~
a.cc:138:30: note: in expansion of macro 'int'
138 | res = min(abs(H*(w - int(x)) - int(x)*h), res);
| ^~~
a.cc:138:29: error: expected ')' before 'long'
138 | res = min(abs(H*(w - int(x)) - int(x)*h), res);
| ~ ^
| )
|
s742027569 | p03715 | C++ | #include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)
namespace {
struct input_returnner {
ll N; input_returnner(ll N_ = 0) :N(N_) {}
template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
template<typename T> operator T() const { T res; cin >> res; return res; }
template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
};
template<typename T> input_returnner in() { return in<T>(); }
input_returnner in() { return input_returnner(); }
input_returnner in(ll N) { return std::move(input_returnner(N)); }
}
const ll MOD = 1e9 + 7;
struct ModInt {
ll v = 0;
ModInt() {}
template<class T> ModInt(const T& right) {
v = right;
if (v >= 0) v %= MOD;
else v += ((-v) / MOD + 1)*MOD;
v %= MOD;
}
void operator = (const ModInt& right) { v = right.v; }
template<class T> void operator = (const T& right) {
v = right;
if (v >= 0) v %= MOD;
else v = v += ((-v) / MOD + 1)*MOD;
v %= MOD;
}
ModInt operator + (const ModInt& right) { return (v + right.v) % MOD; }
ModInt operator - (const ModInt& right) { return (MOD - (v - right.v)); }
ModInt operator * (const ModInt& right) { return (v * right.v) % MOD; }
ModInt operator / (const ModInt& right) { return v / right.v; }
void operator += (const ModInt& right) { v = (v + right.v) % MOD; }
void operator -= (const ModInt& right) { v = (MOD - (v - right.v)); }
void operator *= (const ModInt& right) { v = (v* right.v) % MOD; }
void operator /= (const ModInt& right) { v = v / right.v; }
bool operator == (const ModInt& right) { return v == right.v; }
};
ostream& operator << (ostream& os, const ModInt& value) {
os << value.v;
return os;
}
void solve();
/// ---template---
signed main(void) {
SETUP;
solve();
return 0;
}
#define int ll
int getA(int w,int h, int x){
vector<int> a(3);
int y = h / 2;
a[0] = h*x;
a[1] = y*(w - x);
a[2] = (h - y)*(w - x);
return max(ALL(a)) - min(ALL(a));
}
int f(int w, int h) {
int res = 1e10+1;
if (h >= 3 and h % 3 != 0) res = w*(h / 3);
int H = h / 2;
double x = H*w / double(h + H);
res = min(abs(H*(w - int(ceil(x))) - int(ceil(x))*h), res);
H = ceil(h / 2.0);
x = H*w / (h + H);
res = min(abs(H*(w - int(x)) - int(x)*h), res);
return res;
}
void solve() {
int w, h; cin >> w >> h;
cout << min(f(w, h), f(h, w)) << endl;
} | a.cc: In function 'long long int f(long long int, long long int)':
a.cc:45:12: error: expected primary-expression before 'long'
45 | #define ll long long
| ^~~~
a.cc:119:13: note: in expansion of macro 'll'
119 | #define int ll
| ^~
a.cc:135:30: note: in expansion of macro 'int'
135 | res = min(abs(H*(w - int(ceil(x))) - int(ceil(x))*h), res);
| ^~~
a.cc:135:29: error: expected ')' before 'long'
135 | res = min(abs(H*(w - int(ceil(x))) - int(ceil(x))*h), res);
| ~ ^
| )
a.cc:45:12: error: expected primary-expression before 'long'
45 | #define ll long long
| ^~~~
a.cc:119:13: note: in expansion of macro 'll'
119 | #define int ll
| ^~
a.cc:138:30: note: in expansion of macro 'int'
138 | res = min(abs(H*(w - int(x)) - int(x)*h), res);
| ^~~
a.cc:138:29: error: expected ')' before 'long'
138 | res = min(abs(H*(w - int(x)) - int(x)*h), res);
| ~ ^
| )
|
s640032982 | p03715 | C++ | #include<iostream>
#include<algorithm>
#include <stdlib>
using namespace std;
const int MAX = 2147483647;
int main() {
int H, W, ans = MAX, area1, area2, area3;
cin >> H >> W;
for (int i = 1;i < (H+H%2)/2;i ++) {
ans = min(abs((H-3*i)*W), ans);
area1 = i*W;
area2 = (H-i)*(W+W%2)/2;
area3 = H*W-area1-area2;
ans = min(max(max(abs(area3-area1),abs(area2-area1)),abs(area3-area2)),ans);
}
for (int i = 1;i < (W+W%2)/2;i ++) {
ans = min(abs((W-3*i)*H), ans);
area1 = i*H;
area2 = (W-i)*(H+H%2)/2;
area3 = H*W-area1-area2;
ans = min(max(max(abs(area3-area1),abs(area2-area1)),abs(area3-area2)),ans);
}
cout << ans;
return 0;
} | a.cc:3:10: fatal error: stdlib: No such file or directory
3 | #include <stdlib>
| ^~~~~~~~
compilation terminated.
|
s209954949 | p03715 | C++ | for (int i=0; i<=h; i++) {
long long s1=i*w;
long long s2=0;
long long s3=0;
long long last=h-i;
long long now=0;
if (last % 2==0) s2=(last/2)*w,now=max(now,(long long)abs(s1-s2));
else if (w % 2==0) s2=(w / 2)*last,now=max(now,(long long)abs(s1-s2));
else {
if (last < w) s2=(w/2)*last,s3=(w/2+1)*last;
else s2=(w)*(last/2),s3=(w)*(last/2+1);
now=max((long long)abs(s1-s2),(long long)abs(s1-s3));
now=max(now,(long long)abs(s2-s3));
}
ans=min(ans,now);
} | a.cc:1:1: error: expected unqualified-id before 'for'
1 | for (int i=0; i<=h; i++) {
| ^~~
a.cc:1:15: error: 'i' does not name a type
1 | for (int i=0; i<=h; i++) {
| ^
a.cc:1:21: error: 'i' does not name a type
1 | for (int i=0; i<=h; i++) {
| ^
|
s779021221 | p03715 | C++ |
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;
const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;
ll w, h, ans = mod, s[3];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> w >> h;
if (!(w % 3) || !(h % 3))
ans = 0;
fori (i, 1, w)
{
s[0] = i * h;
s[1] = ((w - i) * (h / 2));
s[2] = ((w - i) * ((h + 1) / 2));
ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
}
fori (i, 1, h)
{
s[0] = i * w;
s[1] = ((h - i) * (w / 2));
s[2] = ((h - i) * ((w + 1) / 2));
ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
}
cout << ans << endl;
} | a.cc:22:9: error: 'pair' does not name a type
22 | typedef pair<int, int> pii;
| ^~~~
a.cc:23:9: error: 'pair' does not name a type
23 | typedef pair<int, ll> pil;
| ^~~~
a.cc:24:9: error: 'pair' does not name a type
24 | typedef pair<ll, int> pli;
| ^~~~
a.cc:25:9: error: 'pair' does not name a type
25 | typedef pair<ll, ll> pll;
| ^~~~
a.cc:26:9: error: 'pair' does not name a type
26 | typedef pair<int, pll> pip;
| ^~~~
a.cc:27:9: error: 'pair' does not name a type
27 | typedef pair<ll, pll> plp;
| ^~~~
a.cc:28:9: error: 'pair' does not name a type
28 | typedef pair<pll, int> ppi;
| ^~~~
a.cc:29:9: error: 'pair' does not name a type
29 | typedef pair<pll, ll> ppl;
| ^~~~
a.cc:30:9: error: 'pair' does not name a type
30 | typedef pair<pll, pll> ppp;
| ^~~~
a.cc:31:9: error: 'vector' does not name a type
31 | typedef vector<int> vi;
| ^~~~~~
a.cc:32:9: error: 'vector' does not name a type
32 | typedef vector<ll> vll;
| ^~~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'ios_base' has not been declared
41 | ios_base::sync_with_stdio(false);
| ^~~~~~~~
a.cc:42:9: error: 'cin' was not declared in this scope
42 | cin.tie(0);
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 |
a.cc:52:33: error: 'max_element' was not declared in this scope
52 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:52:58: error: 'min_element' was not declared in this scope
52 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:52:23: error: 'min' was not declared in this scope; did you mean 'main'?
52 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~
| main
a.cc:59:33: error: 'max_element' was not declared in this scope
59 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:59:58: error: 'min_element' was not declared in this scope
59 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:59:23: error: 'min' was not declared in this scope; did you mean 'main'?
59 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~
| main
a.cc:62:9: error: 'cout' was not declared in this scope
62 | cout << ans << endl;
| ^~~~
a.cc:62:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:62:24: error: 'endl' was not declared in this scope
62 | cout << ans << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 |
|
s106188761 | p03715 | C++ |
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;
const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;
ll w, h, ans = mod, s[3];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> w >> h;
if (!(w % 3) || !(h % 3))
ans = 0;
fori (i, 1, w)
{
s[0] = i * h;
s[1] = ((w - i) * (h / 2));
s[2] = ((w - i) * ((h + 1) / 2));
ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
}
fori (i, 1, h)
{
s[0] = i * w;
s[1] = ((h - i) * (w / 2));
s[2] = ((h - i) * ((w + 1) / 2));
ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
}
cout << ans << endl;
} | a.cc:22:9: error: 'pair' does not name a type
22 | typedef pair<int, int> pii;
| ^~~~
a.cc:23:9: error: 'pair' does not name a type
23 | typedef pair<int, ll> pil;
| ^~~~
a.cc:24:9: error: 'pair' does not name a type
24 | typedef pair<ll, int> pli;
| ^~~~
a.cc:25:9: error: 'pair' does not name a type
25 | typedef pair<ll, ll> pll;
| ^~~~
a.cc:26:9: error: 'pair' does not name a type
26 | typedef pair<int, pll> pip;
| ^~~~
a.cc:27:9: error: 'pair' does not name a type
27 | typedef pair<ll, pll> plp;
| ^~~~
a.cc:28:9: error: 'pair' does not name a type
28 | typedef pair<pll, int> ppi;
| ^~~~
a.cc:29:9: error: 'pair' does not name a type
29 | typedef pair<pll, ll> ppl;
| ^~~~
a.cc:30:9: error: 'pair' does not name a type
30 | typedef pair<pll, pll> ppp;
| ^~~~
a.cc:31:9: error: 'vector' does not name a type
31 | typedef vector<int> vi;
| ^~~~~~
a.cc:32:9: error: 'vector' does not name a type
32 | typedef vector<ll> vll;
| ^~~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'ios_base' has not been declared
41 | ios_base::sync_with_stdio(false);
| ^~~~~~~~
a.cc:42:9: error: 'cin' was not declared in this scope
42 | cin.tie(0);
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 |
a.cc:52:33: error: 'max_element' was not declared in this scope
52 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:52:58: error: 'min_element' was not declared in this scope
52 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:52:23: error: 'min' was not declared in this scope; did you mean 'main'?
52 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~
| main
a.cc:59:33: error: 'max_element' was not declared in this scope
59 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:59:58: error: 'min_element' was not declared in this scope
59 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~~~~~~~~~
a.cc:59:23: error: 'min' was not declared in this scope; did you mean 'main'?
59 | ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
| ^~~
| main
a.cc:62:9: error: 'cout' was not declared in this scope
62 | cout << ans << endl;
| ^~~~
a.cc:62:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:62:24: error: 'endl' was not declared in this scope
62 | cout << ans << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 |
|
s751569375 | p03715 | C++ | #include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#define int long long
using namespace std;
signed main() {
int a, b; cin >> a >> b;
int ans = LLONG_MAX;
for (int i = 1; i < a; i++) {
ans = min(ans, max(b*i, (b - b / 2)*(a - i)) - min(b*i, b / 2 * (a - i)));
}
for (int j = 1; j < b; j++) {
ans = min(ans, max(a*j, (a - a / 2)*(b - j)) - min(a*j, b / 2 * (b - j)));
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:18:19: error: 'LLONG_MAX' was not declared in this scope
18 | int ans = LLONG_MAX;
| ^~~~~~~~~
a.cc:13:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
12 | #include<functional>
+++ |+#include <climits>
13 | #define int long long
|
s851339427 | p03715 | C++ | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
using namespace std;
int main() {
long long h, w;
scanf("%lld%lld", &h, &w);
long long ans = LLONG_MAX;
for (int magic = 0; magic < 2; magic++) {
swap(h, w);
for (int i = 1; i < h; i++) {
long long p1 = i * w;
{
long long p2 = (h - i) * (w / 2);
long long p3 = (h - i) * (w - w / 2);
ans = min(ans, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
}
{
long long hh = h - i;
long long p2 = (hh / 2) * w;
long long p3 = (hh - hh / 2) * w;
ans = min(ans, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
}
}
}
printf("%lld\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:19:19: error: 'LLONG_MAX' was not declared in this scope
19 | long long ans = LLONG_MAX;
| ^~~~~~~~~
a.cc:13:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
12 | #include <numeric>
+++ |+#include <climits>
13 |
|
s217381192 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{long long ans=-100000000000000;
long long n,cnt=0,sum=0;cin>>n; vector<int>vec(3*n);
for(int i=0;i<3*n;i++){
cin>>vec[i];
}
for(int i=n-1;i<=2*n-1;i++)
{
long long sum1=0;
long long sum2 =0;
vector<int> v1=vec;
sort(v1.begin(),v1.begin()+i);
sort(v1.begin()+i+1,v1.end());
sum1=accumulate(v1.begin()+(i-(n-1)),v1.begin()+i);
sum2=accumulate(v1.begin()+(i+1),v1.begin()+(i+n));
ans=max(ans,sum1-sum2);
}
cout << ans <<endl;
}
while(true){
auto mini=min_element(vec.begin(),vec.begin()+(3*n)/2);
auto q=find(vec.begin(),vec.begin()+(3*n)/2,*mini);
vec.erase(q);
cnt++;
if(cnt==n){
break;
}
auto maxi=max_element(vec.begin()+n/2,vec.end());
auto q1=find(vec.begin()+n/2,vec.end(),*maxi);
//cout<<*q1<<endl;
vec.erase(q1);
cnt++;
if(cnt==n){
break;
}
}
int sum1=0;
for(int i=0;i<vec.size()/2;i++){
sum+=vec[i];
}
for(int i=vec.size()/2;i<vec.size();i++){
sum-=vec[i];
}
cout<<sum<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:22: error: no matching function for call to 'accumulate(__gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
18 | sum1=accumulate(v1.begin()+(i-(n-1)),v1.begin()+i);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
134 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
161 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate expects 4 arguments, 2 provided
a.cc:19:26: error: no matching function for call to 'accumulate(__gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
19 | sum2=accumulate(v1.begin()+(i+1),v1.begin()+(i+n));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
134 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
161 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate expects 4 arguments, 2 provided
a.cc: At global scope:
a.cc:29:5: error: expected unqualified-id before 'while'
29 | while(true){
| ^~~~~
a.cc:50:5: error: expected unqualified-id before 'for'
50 | for(int i=0;i<vec.size()/2;i++){
| ^~~
a.cc:50:17: error: 'i' does not name a type
50 | for(int i=0;i<vec.size()/2;i++){
| ^
a.cc:50:32: error: 'i' does not name a type
50 | for(int i=0;i<vec.size()/2;i++){
| ^
a.cc:53:7: error: expected unqualified-id before 'for'
53 | for(int i=vec.size()/2;i<vec.size();i++){
| ^~~
a.cc:53:30: error: 'i' does not name a type
53 | for(int i=vec.size()/2;i<vec.size();i++){
| ^
a.cc:53:43: error: 'i' does not name a type
53 | for(int i=vec.size()/2;i<vec.size();i++){
| ^
a.cc:57:1: error: 'cout' does not name a type
57 | cout<<sum<<endl;
| ^~~~
a.cc:58:5: error: expected unqualified-id before 'return'
58 | return 0;
| ^~~~~~
a.cc:59:1: error: expected declaration before '}' token
59 | }
| ^
|
s665589191 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
long long arr[100010],N,totalkiri=0,totalkanan=0,tmp;
priority_queue<long long,vector<long long>,greater<long long>> kiri;
priority_queue<long long> kanan;
void Input(){
cin>>N;
for(long long i=0; i<N; i++){
cin>>tmp; kiri.push(tmp); totalkiri+=tmp;
}
for(long long i=0; i<N; i++){
cin>>arr[i];
}
for(long long i=0; i<N; i++){
cin>>tmp; kanan.push(tmp); totalkanan+=tmp;
}
}
void Solve(){
long long i=0,j=N-1;
while(i<=j){
if(arr[i]-kiri.top()>=kanan.top()-arr[j]){
totalkiri-=kiri.top(); totalkiri+=arr[i];
kiri.pop(); kiri.push(arr[i]); i++;
}else if(arr[i]-kiri.top()<kanan.top()-arr[j]){
totalkanan-=kanan.top(); totalkanan+=arr[j];
kanan.pop(); kanan.push(arr[j]); j--;
}else if(arr[i]-kiri.top()<0){
i++;
}else if(kanan.top()-arr[j]<0){
j--;
}
}
cout<<totalkiri-totalkanan<<'\n';
}
long long main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
Input();
Solve();
} | cc1plus: error: '::main' must return 'int'
|
s509026782 | p03716 | C++ | #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
__f(comma+1, args...);
}
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
os << "{ ";
for(auto& y : x) os << y << " ; ";
return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
return os << "[ " << p.first << ", " << p.second << "]" ;
}
#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"
// priority_queue<ll, vector<ll>, less<ll>>pq; // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq; // Min Heap
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;
int main()
{
FAST_IO;
ll n, ans = -1e18;
cin >> n;
ll a[3*n], fr[3*n], ba[3*n];
multiset<ll>s;
for(int i=0;i<3*n;i++) cin >> a[i];
for(int i=0;i<3*n;i++)
{
if(sz(s) < n)
{
s.insert(a[i]);
if(i > 0) fr[i] = fr[i - 1] + a[i];
else fr[i] = a[i];
}
else
{
ll w = *s.begin();
fr[i] = fr[i - 1];
if(w >= a[i]) continue;
else
{
s.insert(a[i]);
s.erase(s.find(w));
fr[i] += a[i] - w;
}
}
}
multiset<ll, greater<ll>>s1;
for(int i=3*n-1;i>=0;i--)
{
if(sz(s1) < n)
{
s1.insert(a[i]);
if(i < 3 * n - 1) ba[i] = ba[i + 1] + a[i];
else ba[i] = a[i];
}
else
{
ll w = *s1.begin();
ba[i] = ba[i + 1];
if(w <= a[i]) continue;
else
{
s1.insert(a[i]);
s1.erase(s1.find(w));
ba[i] += a[i] - w;
}
}
}
for(int i=0;i<3*n;i++)
{
if(i >= n && i <= 2 * n)
ans = max(ans, fr[i - 1] - ba[i]);
}
cout << ans << endl;
return 0;
} | In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:5:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::greater<long long int>, std::allocator<long long int> >::_Rb_tree_impl<std::greater<long long int>, true>::~_Rb_tree_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<long long int>]': target specific option mismatch
182 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
In file included from /usr/include/c++/14/map:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
658 | struct _Rb_tree_impl
| ^~~~~~~~~~~~~
|
s159351500 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
int N;
cin >> N;
ll a[3*N];
for (int i = 0; i < 3*N; i++) {
cin >> a[i];
}
priority_queue<ll, vector<ll>, greater<ll>> Q1;
priority_queue<ll, vector<ll>, less<ll>> Q2;
ll R1[N];
ll R2[N];
ll sum = 0;
for (int i = 0; i < N; i++) {
Q1.push(a[i]);
Q2.push(a[(2*N)+i]);
sum += a[i];
sum -= a[(2*N)+i];
}
for (int i = 0; i < N; i++) {
ll c = a[N+i] - Q1.top();
c = max(0,c);
Q1.pop();
Q1.push(a[N+i]);
if (i == 0) {
R1[i] = c;
} else {
R1[i] = R1[i-1] + c;
}
}
for (int i = N-1; i >= 0; i--) {
ll b = Q2.top() - a[N+i];
b = max(0,b);
Q2.pop();
Q2.push(a[N+i]);
if (i == N-1) {
R2[i] = b;
} else {
R2[i] = R2[i+1] + b;
}
}
ll max_plus = -9999999999999;
max_plus = max(max_plus,R1[N-1]);
max_plus = max(max_plus,R2[N-1]);
for (int i = 0; i < N - 1; i++) {
max_plus = max(max_plus,R1[i]+R2[i+1]);
}
cout << sum + max_plus << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:26:12: error: no matching function for call to 'max(int, ll&)'
26 | c = max(0,c);
| ~~~^~~~~
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:26:12: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
26 | c = max(0,c);
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
26 | c = max(0,c);
| ~~~^~~~~
a.cc:37:12: error: no matching function for call to 'max(int, ll&)'
37 | b = max(0,b);
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:37:12: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
37 | b = max(0,b);
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:37:12: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
37 | b = max(0,b);
| ~~~^~~~~
|
s441249558 | p03716 | C++ | #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
ll n, a[400000],pref[400000],suf[400000];
signed main(){
scanf("%lld",&n);
n*=3;
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
ll sum=0;
priority_queue <ll,vector <ll>,greater <ll>> que;
for(int i=0;i<n;i++){
que.push(a[i]);
sum+=a[i];
if(que.size()>n/3){
sum-=que.top();
que.pop();
}
pref[i]=sum;
}
priority_queue <ll> que2;
sum=0;
for(int i=n-1;i>=0;i--)
{
que2.push(a[i]);
sum+=A[i];
if(que2.size()>n/3)
{
sum-=que2.top();
que2.pop();
}
if(i>=1) pref[i-1]-=sum;
}
ll ans=pref[n/3-1];
for(int i=n/3-1;i+n/3<n;i++)ans=max(ans,pref[i]);
cout<<ans<<endl; return 0;
} | a.cc: In function 'int main()':
a.cc:28:22: error: 'A' was not declared in this scope
28 | sum+=A[i];
| ^
|
s691084506 | p03716 | C++ | #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
ll n, a[400000],pref[400000],suf[400000];
signed main(){
scanf("%lld",&n);
n*=3;
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
ll sum=0;
priority_queue <ll,vector <ll>,greater <ll>> que;
for(int i=0;i<n;i++){
que.push(a[i]);
sum+=a[i];
if(que.size()>n/3){
sum-=que.top();
que.pop();
}
pref[i]=sum;
}
priority_queue <ll> que2;
sum=0;
for(int i=n-1;i>=0;i--)
{
que2.push(A[i]);
sum+=A[i];
if(que2.size()>n/3)
{
sum-=que2.top();
que2.pop();
}
if(i>=1) dp[i-1]-=sum;
}
ll ans=pref[n/3-1];
for(int i=n/3-1;i+n/3<n;i++)ans=max(ans,pref[i]);
cout<<ans<<endl; return 0;
} | a.cc: In function 'int main()':
a.cc:27:27: error: 'A' was not declared in this scope
27 | que2.push(A[i]);
| ^
a.cc:34:26: error: 'dp' was not declared in this scope; did you mean 'dup'?
34 | if(i>=1) dp[i-1]-=sum;
| ^~
| dup
|
s323349374 | p03716 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
int main()
{ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n;
cin>>n;
ll z1=0,z2=0;
ll a[n+1],b[n+1];
priority_queue <ll> l2;
priority_queue <ll, vector<ll>, greater<ll> > l1;
vector<ll> v;
for(ll i=0;i<n*3;i++)
{ll x;
cin>>x;
if(i<n)
{
l1.push(x);
z1+=x;
}
if(i>=2*n)
{
l2.push(x);
z2+=x;
}
v.push_back(x);
}
a[0]=z1;
b[n]=z2;
for(ll i=n;i<2*n;i++ )
{
if(v[i]>l1.top())
{ z1-=l1.top();
z1+=v[i];
l1.pop();
l1.push(v[i]);
}
a[i-n+1]=z1;
}
for(ll i=(2*n)-1,j=n-1;i>=n;i--,j--)
{
if(v[i]<l2.top())
{ z2-=l2.top();
z2+=v[i];
l2.pop();
l2.push(v[i]);
}
b[j]=z2;
}
long long int ans=-1e15;
for(ll i=0;i<=n;i++)
{ans=max(ans,a[i]-b[i]);
}
cout<<ans;
}
| a.cc: In function 'int main()':
a.cc:61:13: error: no matching function for call to 'max(long long int&, ll)'
61 | {ans=max(ans,a[i]-b[i]);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:61:13: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'long long unsigned int'})
61 | {ans=max(ans,a[i]-b[i]);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:61:13: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
61 | {ans=max(ans,a[i]-b[i]);
| ~~~^~~~~~~~~~~~~~~
|
s707520467 | p03716 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll n;
cin>>n;
vector<pair<ll,ll> > b;
vector<ll> c;
for(int i=0;i<n*3;i++)
{ll x;
cin>>x;
if(i<2*n)
{
b.push_back(make_pair(x,i);
}
c.push_back(x);
}
sort(b.begin(),b.end());
ll z1=0,ans=0;
for(int i=n;i<2*n;i++)
{
z1+=b[i].first;
ans=max(ans,b[i].second);
}
vector<ll> d;
++ans;
d.assign(c.begin()+ans,c.end());
sort(d.begin(),d.end());
ll j=0,z2=0;
vector<ll>::iterator it;
for( it=d.begin();it!=d.end();it++)
{j++;
z2+=*it;
if(j==n)break;
}
cout<<z1-z2;
}
| a.cc: In function 'int main()':
a.cc:15:39: error: expected ')' before ';' token
15 | b.push_back(make_pair(x,i);
| ~ ^
| )
|
s160065142 | p03716 | C++ | #include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
int N;
cin >> N;
priority_queue<long long, vector<long long>, greater<long long>>R;
priority_queue<long long>B;
vector<long long>R_a(N + 1, 0);
vector<long long>B_a(N + 1, 0);
vector<long long>A(N * 3);
for (int i = 0; i < N * 3; i ++) cin >> A[i];
for (int i = 0; i < N; i ++) {
R_a[0] += A[i];
R.push(A[i]);
}
for (int i = 1; i <= N; i ++) {
int i_ = N - 1 + i;
R_a[i] = R_a[i - 1] + A[i_];
R.push(A[i_]);
R_a[i] -= R.front();
R.pop();
}
for (int i = N * 3 - 1; i >= N * 2; i --) {
B_a[0] += A[i];
B.push(A[i]);
}
for (int i = 1; i <= N; i ++) {
int i_ = N * 2 - i;
B_a[i] = B_a[i - 1] + A[i_];
B.push(A[i_]);
B_a[i] -= B.front();
B.pop();
}
long long ans = 1e15;
ans *= -1;
for (int i = 0; i <= N; i ++) {
ans = max(ans, R_a[i] - B_a[i]);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:21:17: error: 'class std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >' has no member named 'front'
21 | R_a[i] -= R.front();
| ^~~~~
a.cc:32:17: error: 'class std::priority_queue<long long int>' has no member named 'front'
32 | B_a[i] -= B.front();
| ^~~~~
|
s671662441 | p03716 | C++ | import heapq
n = int(input())
a = list(map(int,input().split()))
ans = -float("inf")
for k in range(n, 2 * n + 1):
b = list()
c = list()
heapq.heappush(b, a[:k])
heapq.heappush(c,a[k:])
b = b[0]
heapq.heapify(b)
for i in range(k-n):
heapq.heappop(b)
c = list(map(lambda x: x*(-1),c[0]))
heapq.heapify(c)
for i in range(2*n-k):
heapq.heappop(c)
c = list(map(lambda x: x*(-1),c))
heapq.heapify(c)
ans = max(ans, sum(b)-sum(c))
print(ans)
| a.cc:1:1: error: 'import' does not name a type
1 | import heapq
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s306207185 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
const int INF = 100000002;
int main(){
int n; cin >> n;
vl a(3*n); rep(i, 3*n) cin >> a[i];
// left
vl s(2*n+1, 0);
priority_queue<ll, vl, greater<ll>> que1;
rep(i,n){
s[i+1] = s[i] + a[i];
que1.push(a[i]);
}
for(int i = n; i<n*2; i++){
ll mi = que1.top();
if(a[i] > mi){
s[i+1] = s[i] - mi + a[i];
que1.pop();
que1.push(mi);
}
else s[i+1] = s[i];
}
// right
vl t(2*n+1, 0);
priority_queue<ll> que2;
rep(i,n){
t[i+1] = t[i] + a[3*n-1 - i];
que2.push(a[3*n-1 - i]);
}
for(int i=n; i<2*n; i++){
ll mi que2.top();
if(mi > a[3*n-1 -i]){
t[i+1] = t[i] - mi + a[3*n-1 -i];
que2.pop();
que2.push(a[3*n-1 -i]);
}else{
t[i+1] = t[i];
}
}
// aggregate
ll ans = -(1LL<<60);
for(int i = n; i<2*n; i++){
ans = max(ans, s[i]-t[3*n-i]);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:42:23: error: expected initializer before 'que2'
42 | ll mi que2.top();
| ^~~~
a.cc:43:20: error: 'mi' was not declared in this scope; did you mean 'i'?
43 | if(mi > a[3*n-1 -i]){
| ^~
| i
|
s286659739 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define allcout(V) \
for(auto x : V) { \
cout << x << ' '; \
} \
cout << endl;
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return 1;
}
return 0;
}
signed main() {
int N;
cin >> N;
int a[3 * N];
rep(i, 3 * N) cin >> a[i];
vector<int> left(N + 1), right(N + 1);
multiset<int> S;
int sum = 0;
rep(i, N) {
S.insert(a[i]);
sum += a[i];
}
left[0] = sum;
for(int i = N; i <= 2 * N - 1; i++) {
int m = *S.begin();
if(a[i] > m) {
sum = sum - m + a[i];
S.erase(m);
S.insert(a[i]);
}
left[i - N + 1] = sum;
}.
multiset<int> SS;
sum = 0;
for(int i = N * 3 - 1; i >= N * 2; i--) {
SS.insert(a[i]);
sum += a[i];
}
right[N] = sum;
for(int i = N * 2 - 1; i >= N; i--) {
int m = *(--SS.end());
if(a[i] < m) {
sum = sum - m + a[i];
SS.erase(m);
SS.insert(a[i]);
}
right[i - N] = sum;
}
int ans = -INF;
rep(i, N + 1) ans = max(ans, left[i] - right[i]);
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:50:6: error: expected primary-expression before '.' token
50 | }.
| ^
a.cc:52:5: error: invalid use of 'class std::multiset<long long int>'
52 | multiset<int> SS;
| ^~~~~~~~~~~~~
a.cc:55:9: error: 'SS' was not declared in this scope; did you mean 'S'?
55 | SS.insert(a[i]);
| ^~
| S
a.cc:60:21: error: 'SS' was not declared in this scope; did you mean 'S'?
60 | int m = *(--SS.end());
| ^~
| S
|
s358930873 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
void solve()
{
long long int n,sum1=0,sum2=0;
cin>>n;
long long int l[n],m[n],r[n];
for(int i=0;i<n;i++)
cin>>l[i];
for(int i=0;i<n;i++)
cin>>m[i];
for(int i=0;i<n;i++)
cin>>r[i];
int e=0;
int a=0,b=0;
while(e<n)
{
if(l[a]>=m[b])
sum1+=l[a++];
else
sum1+=m[b++];
e++;
}
e=0;
a=0;
while(e<n)
{
if(b<n&& m[b]<=r[a])
sum2+=m[b++];
else
sum2+=r[a++];
e++;
}
cout<<(sum1-sum2)<<endl;
}
int main()
{
int t=1;
//cin>>t;
while(t--)
solve();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
void solve()
{
long long int n,sum1=0,sum2=0;
cin>>n;
long long int l[n],m[n],r[n];
for(int i=0;i<n;i++)
cin>>l[i];
for(int i=0;i<n;i++)
cin>>m[i];
for(int i=0;i<n;i++)
cin>>r[i];
int e=0;
int a=0,b=0;
while(e<n)
{
if(l[a]>=m[b])
sum1+=l[a++];
else
sum1+=m[b++];
e++;
}
e=0;
a=0;
while(e<n)
{
if(b<n&& m[b]<=r[a])
sum2+=m[b++];
else
sum2+=r[a++];
e++;
}
cout<<(sum1-sum2)<<endl;
}
int main()
{
int t=1;
//cin>>t;
while(t--)
solve();
return 0;
}
| a.cc:62:6: error: redefinition of 'void solve()'
62 | void solve()
| ^~~~~
a.cc:4:6: note: 'void solve()' previously defined here
4 | void solve()
| ^~~~~
a.cc:107:5: error: redefinition of 'int main()'
107 | int main()
| ^~~~
a.cc:49:5: note: 'int main()' previously defined here
49 | int main()
| ^~~~
|
s660378648 | p03716 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<vector<int > > vec2int;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
int n;
cin >> n;
int n3 = 3*n;
priority_queue<int, vecint, greater<int> > q1;
priority_queue<int> q2;
vecint a(n3);
vecll sum1(n + 1,0);// [0,i + n - 1]
vecll sum2(n + 1,0);// [3n - i,3n] 0<= i <= n
int tmp;
REP(i,n3){
cin >> tmp;
a[i] = tmp;
if(i < n){
q1.push(tmp);
sum1[0] += tmp;
}else if(2*n <= i){
q2.push(tmp);
sum2[n] += tmp;
}
}
//////initial
/// sum1
for(int k = n;k < 2*n; k ++){
tmp = q1.top();q1.pop();
if(tmp <= a[k]){
// tmp remove (push a[k])
q1.push(a[k]);
sum1[k - n + 1] = sum1[k - n] + a[k] - tmp;
}else{
// tmp remain (deny a[k])
q1.push(tmp);
sum1[k - n + 1] = sum1[k - n];
}
}
// REP(i,n + 1){
// cout << sum1[i] << endl;
// }
// sum2
for(int k = 2*n - 1;k >= n; k --){
tmp = q2.top();q2.pop();
if(tmp >= a[k]){
// tmp remove (push a[k])
q2.push(a[k]);
sum2[k - n] = sum2[k - n + 1] + a[k] - tmp;
}else{
// tmp remain (deny a[k])
q2.push(tmp);
sum2[k - n] = sum2[k - n + 1];
}
}
ll ans = sum1[0] - sum2[0];
REP(i, n + 1){
ans = max(ans, sum1[i] - sum2[i]);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:21:3: error: 'vecll' was not declared in this scope
21 | vecll sum1(n + 1,0);// [0,i + n - 1]
| ^~~~~
a.cc:22:8: error: expected ';' before 'sum2'
22 | vecll sum2(n + 1,0);// [3n - i,3n] 0<= i <= n
| ^~~~~
| ;
a.cc:29:7: error: 'sum1' was not declared in this scope
29 | sum1[0] += tmp;
| ^~~~
a.cc:32:7: error: 'sum2' was not declared in this scope
32 | sum2[n] += tmp;
| ^~~~
a.cc:44:7: error: 'sum1' was not declared in this scope
44 | sum1[k - n + 1] = sum1[k - n] + a[k] - tmp;
| ^~~~
a.cc:48:7: error: 'sum1' was not declared in this scope
48 | sum1[k - n + 1] = sum1[k - n];
| ^~~~
a.cc:61:7: error: 'sum2' was not declared in this scope
61 | sum2[k - n] = sum2[k - n + 1] + a[k] - tmp;
| ^~~~
a.cc:65:7: error: 'sum2' was not declared in this scope
65 | sum2[k - n] = sum2[k - n + 1];
| ^~~~
a.cc:70:12: error: 'sum1' was not declared in this scope
70 | ll ans = sum1[0] - sum2[0];
| ^~~~
a.cc:70:22: error: 'sum2' was not declared in this scope
70 | ll ans = sum1[0] - sum2[0];
| ^~~~
|
s229492592 | p03716 | C++ | #include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
ll n;
cin>>n;
vll a(n);
vll h(n);
vll d(n);
ll cu=0;
ll ccu=0;
PQR M;
PQ B;
rep(i,3*n){
cin>>a[i];
if(i<n) {
cu+=a[i];
M.pu(a[i]);
}
else if(i>=2*n){
ccu+=a[i];
B.pu(a[i]);
}
}
h.pb(cu);
d.pb(ccu);
for(int i=n;i<2*n;i++){
cu+=a[i];
M.pu(a[i]);
cu-=M.top();
M.pop();
h.pb(cu);
}
for(int i=2*n;i<3*n;i++){
ccu+=a[i];
B.pb(a[i]);
ccu-=B.top();
B.pop();
d.pb(ccu);
}
ll ans=0;
rep(i,n+1){
ans=max(ans,h[i]-d[n-i]);
}
COUT(ans);
} | a.cc: In function 'int main()':
a.cc:15:12: error: 'class std::priority_queue<long long int>' has no member named 'push_back'
15 | #define pb push_back
| ^~~~~~~~~
a.cc:72:7: note: in expansion of macro 'pb'
72 | B.pb(a[i]);
| ^~
|
s409930984 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<ll> a(3 * n), s(n), t(n), u(n);
rep(i, 0, 3 * n) cin >> a[i];
ll ans = 0, sum;
rep(i, 0, n) {
s[i] = a[i];
t[i] = a[i + n];
u[i] = a[i + 2 * n];
ans += s[i] - u[i];
}
sort(s.begin(), s.end());
sort(u.rbegin(), u.rend());
rep(i, 0, n) {
s[i] = t[i] - s[i];
u[i] -= t[n - 1 - i];
}
rep(i, 1, n) {
s[i] += s[i - 1];
u[i] += u[i - 1];
}
//debug(s), debug(u);
rep(i, 1, n) {
s[i] = max(s[i], s[i - 1]);
u[i] = max(u[i], u[i - 1]);
}
sum = max(s[n - 1], u[n - 1]);
rep(i, 0, n - 1) {
sum = max(sum, s[i] + u[n - 2 - i]);
}
sum = max(sum, 0);
cout << ans + sum << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:41:14: error: no matching function for call to 'max(ll&, int)'
41 | sum = max(sum, 0);
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:41:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
41 | sum = max(sum, 0);
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:41:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
41 | sum = max(sum, 0);
| ~~~^~~~~~~~
|
s490774553 | p03716 | C++ | #include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll prev[500010];
ll suf[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
int main(){
cin>>n;
for(int i=0;i<3*n;i++)cin>>a[i];
ll sum=0;
for(int i=0;i<n;i++){
sum+=a[i];
q.push(a[i]);
}
prev[n-1]=sum;
for(int i=n;i<2*n;i++){
sum+=a[i];
q.push(a[i]);
sum-=q.top();
q.pop();
prev[i]=sum;
}
sum=0;
for(int i=3*n-1;i>=2*n;i--){
sum+=a[i];
p.push(-a[i]);
}
suf[2*n]=sum;
for(int i=2*n-1;i>=n;i--){
sum+=a[i];
p.push(-a[i]);
sum-=-p.top();
p.pop();
suf[i]=sum;
}
ll mx=-LLINF;
for(int i=n-1;i<2*n;i++){
mx=max(mx,prev[i]-suf[i+1]);
}
cout<<mx<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'prev' is ambiguous
20 | prev[n-1]=sum;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
a.cc:26:17: error: reference to 'prev' is ambiguous
26 | prev[i]=sum;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
a.cc:43:27: error: reference to 'prev' is ambiguous
43 | mx=max(mx,prev[i]-suf[i+1]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
|
s121751037 | p03716 | C++ | #include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll prev[500010];
ll suf[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
void run(){
cin>>n;
for(int i=0;i<3*n;i++)cin>>a[i];
ll sum=0;
for(int i=0;i<n;i++){
sum+=a[i];
q.push(a[i]);
}
prev[n-1]=sum;
for(int i=n;i<2*n;i++){
sum+=a[i];
q.push(a[i]);
sum-=q.top();
q.pop();
prev[i]=sum;
}
sum=0;
for(int i=3*n-1;i>=2*n;i--){
sum+=a[i];
p.push(-a[i]);
}
suf[2*n]=sum;
for(int i=2*n-1;i>=n;i--){
sum+=a[i];
p.push(-a[i]);
sum-=-p.top();
p.pop();
suf[i]=sum;
}
ll mx=-LLINF;
for(int i=n-1;i<2*n;i++){
mx=max(mx,prev[i]-suf[i+1]);
}
cout<<mx<<endl;
}
int main(){
run();
return 0;
}
| a.cc: In function 'void run()':
a.cc:20:9: error: reference to 'prev' is ambiguous
20 | prev[n-1]=sum;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
a.cc:26:17: error: reference to 'prev' is ambiguous
26 | prev[i]=sum;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
a.cc:43:27: error: reference to 'prev' is ambiguous
43 | mx=max(mx,prev[i]-suf[i+1]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
|
s911536306 | p03716 | C++ | #include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll prev[500010];
ll suf[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
void run(){
cin>>n;
for(int i=0;i<3*n;i++)cin>>a[i];
ll sum=0;
for(int i=0;i<n;i++){
sum+=a[i];
q.push(a[i]);
}
prev[n-1]=sum;
for(int i=n;i<2*n;i++){
sum+=a[i];
q.push(a[i]);
sum-=q.top();
q.pop();
prev[i]=sum;
}
sum=0;
for(int i=3*n-1;i>=2*n;i--){
sum+=a[i];
p.push(-a[i]);
}
suf[2*n]=sum;
for(int i=2*n-1;i>=n;i--){
sum+=a[i];
p.push(-a[i]);
sum-=-p.top();
p.pop();
suf[i]=sum;
}
ll mx=-LLINF;
for(int i=n-1;i<2*n;i++){
mx=max(mx,prev[i]-suf[i+1]);
}
cout<<mx<<endl;
}
int main(){
run();
return 0;
}
| a.cc: In function 'void run()':
a.cc:20:9: error: reference to 'prev' is ambiguous
20 | prev[n-1]=sum;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
a.cc:26:17: error: reference to 'prev' is ambiguous
26 | prev[i]=sum;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
a.cc:43:27: error: reference to 'prev' is ambiguous
43 | mx=max(mx,prev[i]-suf[i+1]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500010]'
6 | ll prev[500010];
| ^~~~
|
s530424410 | p03716 | C++ | #include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll prev[500100];
ll suf[500100];
ll a[500100];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
void run(){
cin>>n;
for(int i=0;i<3*n;i++)cin>>a[i];
ll sum=0;
for(int i=0;i<n;i++){
sum+=a[i];
q.push(a[i]);
}
prev[n-1]=sum;
for(int i=n;i<2*n;i++){
prev[i]+=a[i];
q.push(a[i]);
sum-=q.top();
q.pop();
prev[i]=sum;
}
sum=0;
for(int i=3*n-1;i>=2*n;i--){
sum+=a[i];
p.push(-a[i]);
}
suf[2*n]=sum;
for(int i=2*n-1;i>=n;i--){
sum+=a[i];
p.push(-a[i]);
sum-=-p.top();
p.pop();
suf[i]=sum;
}
ll mx=-LLINF;
for(int i=n-1;i<2*n;i++){
mx=max(mx,prev[i]-suf[i+1]);
}
cout<<mx<<endl;
}
int main(){
run();
return 0;
} | a.cc: In function 'void run()':
a.cc:20:9: error: reference to 'prev' is ambiguous
20 | prev[n-1]=sum;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500100]'
6 | ll prev[500100];
| ^~~~
a.cc:22:17: error: reference to 'prev' is ambiguous
22 | prev[i]+=a[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500100]'
6 | ll prev[500100];
| ^~~~
a.cc:26:17: error: reference to 'prev' is ambiguous
26 | prev[i]=sum;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500100]'
6 | ll prev[500100];
| ^~~~
a.cc:43:27: error: reference to 'prev' is ambiguous
43 | mx=max(mx,prev[i]-suf[i+1]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:6:4: note: 'll prev [500100]'
6 | ll prev[500100];
| ^~~~
|
s351635824 | p03716 | C++ | /*
https://arc074.contest.atcoder.jp/tasks/arc074_b?lang=en
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10;
int n;
ll ans=LONG_LONG_MIN;
ll a[N];
ll sum1,sum2;
multiset<ll>l,r;
int main()
{
scanf("%d",&n);
for(int i=0;i<3*n;i++)
{
cin>>a[i];
r.insert(a[i]);
sum2+=a[i];
}
for(int i=0;i<n;i++)
{
l.insert(a[i]);
sum1+=a[i];
r.erase(a[i]);
}
sum2-=sum1;
while(l.size()<=2*n)
{
ans=max(ans,(sum1-sum2));
sum1+=a[l.size()];
sum2-=a[l.size()];
r.erase(a[l.size()]);
l.insert(a[l.size()]);
for(int i=0;i<5;i++)
{
sum1-=*(l.begin()+i);
sum2-=*(r.begin()+i);
}
}
cout<<ans<<"\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:38:42: error: no match for 'operator+' (operand types are 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} and 'int')
38 | sum1-=*(l.begin()+i);
| ~~~~~~~~~^~
| | |
| | int
| std::multiset<long long int>::iterator {aka std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator}
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
1798 | operator+(typename move_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
38 | sum1-=*(l.begin()+i);
| ^
In file included 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/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3616 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<long long int>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3719 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<long long int>'
38 | sum1-=*(l.begin()+i);
| ^
/usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3726 | operator+(_CharT __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'std::__cx |
s562261237 | p03716 | C++ | #include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int n,a[300005];
priority_queue<int> res;
int main()
{
ios::sync_with_stdio(false);
cin>>n;
for (int i=0;i<3*n;i++)
{
cin>>a[i];
}
for (int i=n-1;i<2n;i++)
{
priority_queue<int,vector<int>,greater<int> > ql;
priority_queue<int> qr;
int pr;
for (int j=0;j<=i;j++)
{
ql.push(a[j]);
}
for (int j=i+1;j<3*n;j++)
{
qr.push(a[j]);
}
for (int j=1;j<=ql.size()-n;j++)
{
ql.pop();
}
for (int j=1;j<=qr.size()-n;j++)
{
qr.pop();
}
for (int j=0;j<ql.size();j++)
{
pr+=ql.top();
ql.pop();
}
for (int j=0;j<qr.size();j++)
{
pr-=qr.top();
qr.pop;
}
res.push(pr);
}
cout<<res.top();
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:26: error: unable to find numeric literal operator 'operator""n'
15 | for (int i=n-1;i<2n;i++)
| ^~
a.cc:44:28: error: invalid use of non-static member function 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>]'
44 | qr.pop;
| ~~~^~~
In file included from /usr/include/c++/14/queue:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:771:7: note: declared here
771 | pop()
| ^~~
|
s434710437 | p03716 | C++ | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
int N; cin >> N;
vector<long long> a(N*3);
for (int i = 0; i < N*3; ++i) cin >> a[i];
// 左から前処理
vector<long long> S(N*2+1, 0);
priority_queue<long long, vector<long long>, greater<long long> > que1;
for (int i = 0; i < N; ++i) {
S[i+1] = S[i] + a[i];
que1.push(a[i]);
}
for (int i = N; i < 2 * N; i++) {
que1.push(a.at(i));
ll mi = que1.top();
que1.pop();
S.at(i + 1) = S.at(i) + a.at(i) - mi;
}
// 右から前処理
vector<long long> T(N*2+ 1, 0);
priority_queue<long long> que2;
for (int i = 0; i < N; ++i) {
T[i+1] = T[i] + a[N*3-1 - i];
que2.push(a[N*3-1 - i]);
}
for (int i = N; i < 2 * N; i++) {
que2.push(a.at(3 * N - 1 - i));
ll ma = que2.top();
que2.pop();
T.at(i + 1) = T.at(i) + a.at(3 * N - 1 - i) - ma;
}
// 集計
long long res = -(1LL<<60);
for (int i = N; i <= N*2; ++i) {
res = max(res, S[i] - T[N*3-i]);
}
cout << res << endl;
} | a.cc: In function 'int main()':
a.cc:20:9: error: 'll' was not declared in this scope
20 | ll mi = que1.top();
| ^~
a.cc:22:43: error: 'mi' was not declared in this scope; did you mean 'i'?
22 | S.at(i + 1) = S.at(i) + a.at(i) - mi;
| ^~
| i
a.cc:34:9: error: 'll' was not declared in this scope
34 | ll ma = que2.top();
| ^~
a.cc:36:55: error: 'ma' was not declared in this scope; did you mean 'a'?
36 | T.at(i + 1) = T.at(i) + a.at(3 * N - 1 - i) - ma;
| ^~
| a
|
s925761015 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
if(n>1000){
return 0;
}
vector<int> a(3*n);
for(int i=0;i<3*n;i++){
cin >> a[i];
}
long long m=INF;
for(int i=0;i<n+1;i++){
priority_queue<int> p;
priority_queue<int,vector<int>,greater<int>> q;
long long sum1=0;
long long sum2=0;
for(int j=0;j<n+i;j++){
p.push(a[j]);
}
for(int j=n+i;j<3*n;j++){
q.push(a[j]);
}
for(int j=0;j<n;j++){
sum1+=p.top();
p.pop();
sum2+=q.top();
q.pop();
}
if(i==0){
m=sum1-sum2;
}
m=max(m,sum1-sum2);
}
cout << m << endl;
}
| a.cc: In function 'int main()':
a.cc:16:18: error: 'INF' was not declared in this scope
16 | long long m=INF;
| ^~~
|
s764562251 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
const int INF=-1000000000
int main(){
int n;
cin >> n;
if(n>1000){
return 0;
}
vector<int> a(3*n);
for(int i=0;i<3*n;i++){
cin >> a[i];
}
long long m=INF;
for(int i=0;i<n+1;i++){
priority_queue<int> p;
priority_queue<int,vector<int>,greater<int>> q;
long long sum1=0;
long long sum2=0;
for(int j=0;j<n+i;j++){
p.push(a[j]);
}
for(int j=n+i;j<3*n;j++){
q.push(a[j]);
}
for(int j=0;j<n;j++){
sum1+=p.top();
p.pop();
sum2+=q.top();
q.pop();
}
m=max(m,sum1-sum2);
}
cout << m << endl;
}
| a.cc:7:1: error: expected ',' or ';' before 'int'
7 | int main(){
| ^~~
|
s333346623 | p03716 | C++ |
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
int main(){
int N; cin >> N;
vector<long long> a(N*3);
for (int i = 0; i < N*3; ++i) cin >> a[i];
// 左から前処理
vector<long long> S(N*2+1, 0);
priority_queue<long long, vector<long long>, greater<long long >> que1;
for(int i = 0; i < N; ++i) {
S[i+1] = S[i] + a[i];
que1.push(a[i]);
}
for(int i = N; i < N*2; ++i) {
long long mi = que1.top();
if (a[i] > mi) {
S[i+1] = S[i] - mi + a[i];
que1.pop();
que1.push(a[i]);
}
else S[i+1] = S[i];
}
// 右から前処理
vector<long long> T(N*2+1, 0);
priority_queue<long long> que2;
for(int i = 0; i < N; ++i) {}
T[i+1] = T[i] + a[N*3-1-i];
que2.push(a[N*3-1-i]);
for(int i = N; i < N*2: ++i) {
long long ma = que2.top();
if (a[N*3-1-i] < ma) {
T[i+1] = T[i] - ma + a[N*3-1-i];
que2.pop();
que2.push(a[N*3-1-i]);
}
else T[i+1] = T[i];
}
long long res = -(1LL<<60);
for (int i = N; i <= N*2; ++i) {
res = max(res, S[i] - T[N*3-i]);
}
cout << res << endl;
} | a.cc: In function 'int main()':
a.cc:42:7: error: 'i' was not declared in this scope
42 | T[i+1] = T[i] + a[N*3-1-i];
| ^
a.cc:45:20: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
45 | for(int i = N; i < N*2: ++i) {
| ^
a.cc:45:27: error: expected ';' before ':' token
45 | for(int i = N; i < N*2: ++i) {
| ^
| ;
a.cc:56:5: error: expected primary-expression before 'for'
56 | for (int i = N; i <= N*2; ++i) {
| ^~~
a.cc:55:32: error: expected ')' before 'for'
55 | long long res = -(1LL<<60);
| ^
| )
56 | for (int i = N; i <= N*2; ++i) {
| ~~~
a.cc:45:8: note: to match this '('
45 | for(int i = N; i < N*2: ++i) {
| ^
a.cc:60:13: error: 'res' was not declared in this scope; did you mean 'rep'?
60 | cout << res << endl;
| ^~~
| rep
|
s532825479 | p03716 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define MAX_N 100000
#define INF LLONG_MAX
typedef long long ll;
ll ans = -INF;
int n;
ll a[3*MAX_N];
void solver(priority_queue<ll, vector<ll>, greater<ll> > que_front, priority_queue<ll> que_back, int i){
ll rep = 0;
REP(j,i){
if(a[n + j] > que_front.top()){
que_front.pop();
que_front.push(a[n + j]);
}
}
REP(j,n - i){
if(a[n + i + j] < que_back.top()){
que_back.pop();
que_back.push(a[n + i + j]);
}
}
REP(j,n){
rep += que_front.top() - que_back.top();
que_front.pop();
que_back.pop();
}
ans = max(ans, rep);
}
void solve(){
priority_queue<ll, vector<ll>, greater<ll> > que_front;
priority_queue<ll> que_back;
cin >> n;
REP(i,n){
cin >> a[i];
que_front.push(a[i]);
}
REP(i,n){
cin >> a[n + i];
}
REP(i,n){
cin >> a[2 * n + i];
que_back.push(a[2 * n + i]);
}
REP(i, n)
solver(que_front, que_back, i);
cout << ans << endl;
}
int main(){
solve();
return 0;
} | a.cc:9:13: error: 'LLONG_MAX' was not declared in this scope
9 | #define INF LLONG_MAX
| ^~~~~~~~~
a.cc:12:11: note: in expansion of macro 'INF'
12 | ll ans = -INF;
| ^~~
a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <algorithm>
+++ |+#include <climits>
5 | using namespace std;
|
s493626075 | p03716 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define MAX_N 100000
#define INF LLONG_MAX
typedef long long ll;
ll ans = -INF;
int n;
ll a[3*MAX_N];
void solver(priority_queue<ll, vector<ll>, greater<ll> > que_front, priority_queue<ll> que_back, int i){
ll rep = 0;
REP(j,i){
if(a[n + j] > que_front.top()){
que_front.pop();
que_front.push(a[n + j]);
}
}
REP(j,n - i){
if(a[n + i + j] < que_back.top()){
que_back.pop();
que_back.push(a[n + i + j]);
}
}
REP(j,n){
rep += que_front.top() - que_back.top();
que_front.pop();
que_back.pop();
}
ans = max(ans, rep);
}
void solve(){
priority_queue<ll, vector<ll>, greater<ll> > que_front;
priority_queue<ll> que_back;
cin >> n;
REP(i,n){
cin >> a[i];
que_front.push(a[i]);
}
REP(i,n){
cin >> a[n + i];
}
REP(i,n){
cin >> a[2 * n + i];
que_back.push(a[2 * n + i]);
}
REP(i, n)
solver(que_front, que_back, i);
cout << ans << endl;
}
int main(){
solve();
return 0;
} | a.cc:9:13: error: 'LLONG_MAX' was not declared in this scope
9 | #define INF LLONG_MAX
| ^~~~~~~~~
a.cc:12:11: note: in expansion of macro 'INF'
12 | ll ans = -INF;
| ^~~
a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <algorithm>
+++ |+#include <climits>
5 | using namespace std;
|
s195556231 | p03716 | C++ | #include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<set>
#include <iomanip>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
#define MOD 1000000007
int main(){
int n;cin>>n;
vector<ll> a(3*n);
for(int i=0;i<3*n;i++)cin>>a[i];
priority_queue<ll> mque;
priority_queue<ll,vector<ll>,greater<ll>> que;
vector<ll> Lmax(3*n,0),Rmin(3*n,0);
for(int i=0;i<n;i++){
Lmax[n]+=a[i];//右半開
que.push(a[i]);
}
for(int i=2*n;i<3*n;i++){
Rmin[2*n]+=a[i];//右半開
mque.push(a[i]);
}
for(int i=n;i<2*n;i++){
if(a[i]>que.top()){
Lmax[i+1]=Lmax[i]+a[i]-que.top();
que.pop();
que.push(a[i]);
}
else{
Lmax[i+1]=Lmax[i];
}
}
for(int i=2*n-1;i>=n;i--){
if(a[i]<mque.top()){
Rmin[i]=Rmin[i+1]+a[i]-mque.top();
mque.pop();
mque.push(a[i]);
}
else{
Rmin[i]=Rmin[i+1];
}
}
ll ans=LLONG_MIN;
for(int i=n;i<=2*n;i++){
//cout<<Lmax[i]<<endl;
//cout<<Rmin[i]<<endl;
ans=max(ans,Lmax[i]-Rmin[i]);
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:49:12: error: 'LLONG_MIN' was not declared in this scope
49 | ll ans=LLONG_MIN;
| ^~~~~~~~~
a.cc:11:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
10 | #include<stack>
+++ |+#include <climits>
11 | typedef long long ll;
|
s933616622 | p03716 | C++ | #include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int main() {
int n;
cin >> n;
vector<ll> a(3*n);
rep(i, 3*n) {
cin >> a[i];
}
vector<ll> lsum(n+1);
vector<ll> rsum(n+1);
// まず左から
priority_queue<ll, vector<ll>, greater<ll> > lp;
ll now_lsum = 0;
rep(i, n) {
now_lsum += a[i];
lp.push(a[i]);
}
rep(i, n+1) {
lsum[i] = now_lsum;
ll new_l = a[n+i];
lp.push(new_l);
ll pop_l = lp.top();
lp.pop();
now_lsum = now_lsum + new_l - pop_l;
}
//rep(i, n+1) cout << lsum[i] << endl;
// 次は右
priority_queue<ll> rp;
ll now_rsum = 0;
rep(i, n) {
now_rsum += a[2*n+i];
rp.push(a[2*n+i]);
}
for(int i = n; i>=0; --i) {
rsum[i] = now_rsum;
ll new_r = a[n+i-1];
rp.push(new_r);
ll pop_r = rp.top();
rp.pop();
now_rsum = now_rsum + new_r - pop_r;
}
//rep(i, n+1) cout << "right sum: " << rsum[i] << endl;
ll ans = LLONG_MIN;
rep(i, n+1) {
ans = max(lsum[i]-rsum[i], ans);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:64:14: error: 'LLONG_MIN' was not declared in this scope
64 | ll ans = LLONG_MIN;
| ^~~~~~~~~
a.cc:8:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
7 | #include <map>
+++ |+#include <climits>
8 |
|
s692478577 | p03716 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
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;
}
class UnionFind {
public:
//各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
vector<int> Parent;
//クラスを作るときは、Parentの値を全て-1にする。
//以下のようにすると全てバラバラの頂点として解釈できる。
UnionFind(int N) {
Parent = vector<int>(N, -1);
}
//Aがどのグループに属しているか調べる
int root(int A) {
if (Parent[A] < 0) return A;
return Parent[A] = root(Parent[A]);
}
//自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)];//先祖をrootで取っておきたい。
}
//AとBをくっ付ける
bool connect(int A, int B) {
//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
A = root(A);
B = root(B);
if (A == B) {
//すでにくっついてるからくっ付けない
return false;
}
//大きい方(A)に小さいほう(B)をくっ付けたい
//大小が逆だったらAとBをひっくり返す。
if (size(A) < size(B)) swap(A, B);
//Aのサイズを更新する
Parent[A] += Parent[B];
//Bの親をAに変更する
Parent[B] = A;
return true;
}
};
int main(){
int n;
cin>>n;
long long a[3*n+1];//1-indexedで考える
REPP(i,3*n){
cin>>a[i];
}
long long fs[2*n+1];//n~2*nの範囲だけ使う
long long bs[3*n+1];//(n+1)~(2*n+1)の範囲だけ使う
priority_queue<long long,vector<long long>,greater<long long>> fq;
priority_queue<long long> bq;
fs[n] = 0;
bs[2*n+1] = 0;
REPP(i,n){
fs[n] += a[i];
fq.push(a[i]);
}
for(int i=2*n+1;i<=3*n;i++){
bs[2*n+1] += a[i];
bq.push(a[i]);
}
for(int i=n+1;i<=2*n;i++){
if(fq.top()<a[i]){
fs[i] = fs[i-1]+a[i]-fq.top();
fq.pop();
fq.push(a[i]);
}else{
fs[i] = fs[i-1];
}
}
for(int i=2*n;i>=n+1;i--){
if(bq.top()>a[i]){
bs[i] = bs[i+1]-bq.top()+a[i];
bq.pop();
bq.push(a[i]);
}else{
bs[i] = bs[i+1];
}
}
long long ans = -INF;
REPP(int i=n;i<=2*n;i++){
ans = max(ans, fs[i]-bs[i+1]);
}
cout<<ans<<endl;
return 0;
}
| a.cc:136:26: error: macro "REPP" requires 2 arguments, but only 1 given
136 | REPP(int i=n;i<=2*n;i++){
| ^
a.cc:3:9: note: macro "REPP" defined here
3 | #define REPP(i,n) for(int i=1;i<=n;i++)
| ^~~~
a.cc: In function 'int main()':
a.cc:136:3: error: 'REPP' was not declared in this scope
136 | REPP(int i=n;i<=2*n;i++){
| ^~~~
|
s469604053 | p03716 | C | #include<iostream>
#include <vector>
#include <queue>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
int main(){
int n; scanf("%d",&n);
vector<int> a(3*n);
rep(i,3*n) scanf("%d",&a[i]);
priority_queue<int,vector<int>,greater<int>> q1;
priority_queue<int> q2;
vector<long long> c1(n+1),c2(n+1);
long long s = 0;
rep(i,3*n){
int x = a[i];
if(i < n-1){
q1.push(x);
s+=x;
}else if(i < 2*n){
s+=x;
q1.push(x);
if(i != n-1){
int y = q1.top();
q1.pop();
s-=y;
}
c1[i-(n-1)] = s;
}
//cout << s << endl;
}
s = 0;
rep(i,3*n){
int x = a[3*n - 1 - i];
if(i < n-1){
q2.push(x);
s+=x;
}else if(i < 2*n){
s+=x;
q2.push(x);
if(i != n-1){
int y = q2.top();
q2.pop();
s-=y;
}
c2[i-(n-1)] = s;
}
//cout << s << endl;
}
//for(auto i : c1) cerr << i << endl;
vector<long long> sum(n);
rep(i,n+1){
//cout << c1[i] << " " << c2[n-i] << endl;
sum[i] = c1[i] - c2[n-i];
}
sort(sum.begin(),sum.end());
cout << sum[n-1] << endl;
return 0;
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s575188568 | p03716 | C++ | #include<iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
int main(){
int n; scanf("%d",&n);
vector<int> a(3*n);
rep(i,3*n) scanf("%d",&a[i]);
priority_queue<int,vector<int>,greater<int>> q1;
priority_queue<int> q2;
vector<long long> c1(n+1),c2(n+1);
long long s = 0;
rep(i,3*n){
int x = a[i];
if(i < n-1){
q1.push(x);
s+=x;
}else if(i < 2*n){
s+=x;
q1.push(x);
if(i != n-1){
int y = q1.top();
q1.pop();
s-=y;
}
c1[i-(n-1)] = s;
}
//cout << s << endl;
}
s = 0;
rep(i,3*n){
int x = a[3*n - 1 - i];
if(i < n-1){
q2.push(x);
s+=x;
}else if(i < 2*n){
s+=x;
q2.push(x);
if(i != n-1){
int y = q2.top();
q2.pop();
s-=y;
}
c2[i-(n-1)] = s;
}
//cout << s << endl;
}
//for(auto i : c1) cerr << i << endl;
vector<long long> sum(n);
rep(i,n+1){
//cout << c1[i] << " " << c2[n-i] << endl;
sum[i] = c1[i] - c2[n-i];
}
sort(sum.begin(),sum.end());
cout << sum[n-1] << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:57:9: error: 'sort' was not declared in this scope; did you mean 'short'?
57 | sort(sum.begin(),sum.end());
| ^~~~
| short
|
s524582778 | p03716 | C++ | #include<iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
int main(){
int n; scanf("%d",&n);
vector<int> a(3*n);
rep(i,3*n) scanf("%d",&a[i]);
priority_queue<int,vector<int>,greater<int>> q1;
priority_queue<int> q2;
vector<int> c1(n+1),c2(n+1);
long long s = 0;
rep(i,3*n){
int x = a[i];
if(i < n-1){
q1.push(x);
s+=x;
}else if(i < 2*n){
s+=x;
q1.push(x);
if(i != n-1){
int y = q1.top();
q1.pop();
s-=y;
}
c1[i-(n-1)] = s;
}
//cout << s << endl;
}
s = 0;
rep(i,3*n){
int x = a[3*n - 1 - i];
if(i < n-1){
q2.push(x);
s+=x;
}else if(i < 2*n){
s+=x;
q2.push(x);
if(i != n-1){
int y = q2.top();
q2.pop();
s-=y;
}
c2[i-(n-1)] = s;
}
//cout << s << endl;
}
//for(auto i : c1) cerr << i << endl;
vector<int> sum(n);
rep(i,n+1){
//cout << c1[i] << " " << c2[n-i] << endl;
sum[i] = c1[i] - c2[n-i];
}
sort(sum.begin(),sum.end());
cout << sum[n-1] << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:57:9: error: 'sort' was not declared in this scope; did you mean 'short'?
57 | sort(sum.begin(),sum.end());
| ^~~~
| short
|
s245540412 | p03716 | C++ | #include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const int MAX = 510000;
const int MOD = 1000000007;
int main(){
ll N;cin>>N;
vector<ll> a(3*N);
ll i,j,k;
rep(i,3*N){
cin>>a[i];
}
ll ans = 0;
rep(i,N) ans += a[i];
for(i=2*N;i<3*N;i++) ans -= a[i];
// cout<<ans<<endl;
vector<ll> b(N),c(N);
//bに関して
rep(i,N){
b[i] = a[i];
}
sort(b.begin(),b.end());
rep(i,N){
b[i] = a[i+N] - b[i];
if(b[i]<0) b[i] = 0;
}
//cに関して
for(i=2*N;i<3*N;i++){
c[i-2*N] = a[i];
}
sort(c.begin(),c.end(),greater<ll>());
//O(n^2)の解法
if(N>1000) return -1:
ans = -INF;
vector<ll> pre,aft;
for(i=N;i<=2*N;i++){
pre.clear();aft.clear();
ll tmp = 0;
rep(j,i){
pre.pb(a[j]);
}
for(j=i;j<3*N;j++){
aft.pb(a[j]);
}
SORT(pre);
SORT(aft);
ll x = pre.size();
ll y = aft.size();
for(j=x-1;j>=x-N;j--){
tmp += pre[j];
}
rep(j,N){
tmp -= aft[j];
}
// cout<<tmp<<endl;
ans = max(ans,tmp);
}
cout<<ans<<endl;
//O(nlogn)の解法
}
| a.cc: In function 'int main()':
a.cc:61:23: error: expected ';' before ':' token
61 | if(N>1000) return -1:
| ^
| ;
a.cc:61:23: error: expected primary-expression before ':' token
|
s149179509 | p03716 | C++ | #include <algorithm>
#include <array>
#include <bitset>
#include <cstddef>
#include <tuple>
#include <utility>
#include <vector>
template <std::size_t BitLength, class Abelian> struct foldable_wavelet_matrix {
using mapped_structure = Abelian;
using mapped_type = typename mapped_structure::value_type;
using key_type = std::bitset<BitLength>;
struct bitvector {
struct node_type;
using container_type = std::vector<node_type>;
using size_type = typename container_type::size_type;
struct node_type {
size_type count;
mapped_type sum;
node_type()
: count(static_cast<size_type>(0)),
sum(mapped_structure::identity()) {}
};
container_type vec;
bitvector() : vec() {}
void resize(const size_type size) {
vec.resize(size + static_cast<size_type>(1));
}
void set(const size_type index) {
vec[index].count = static_cast<size_type>(1);
}
template <class InputIterator>
void build(const std::vector<InputIterator> &a) {
for (size_type i = a.size(); i != static_cast<size_type>(0);) {
--i;
vec[i].count += vec[i + static_cast<size_type>(1)].count;
vec[i].sum = mapped_structure::operation(
a[i]->second, vec[i + static_cast<size_type>(1)].sum);
}
}
size_type count(const size_type index) const { return vec[index].count; }
size_type zeros() const { return vec.front().count; }
mapped_type fold(const size_type first, const size_type last) const {
return mapped_structure::operation(
vec[first].sum, mapped_structure::inverse(vec[last].sum));
}
};
using size_type = typename bitvector::size_type;
std::array<bitvector, BitLength> matrix;
foldable_wavelet_matrix():matrix(){}
template <class InputIterator>
explicit foldable_wavelet_matrix(InputIterator first,
const InputIterator last) {
using iterator = InputIterator;
const size_type size = static_cast<size_type>(std::distance(first, last));
std::vector<iterator> cur, pre;
cur.reserve(size);
for (; first != last; ++first) {
cur.push_back(first);
}
pre = cur;
std::size_t i = BitLength;
while (i != static_cast<std::size_t>(0)) {
--i;
bitvector &vec = matrix[i];
vec.resize(size);
std::swap(cur, pre);
typename std::vector<iterator>::iterator zero_itr = cur.begin(),
one_itr = cur.end();
for (size_type k = static_cast<size_type>(0); zero_itr != one_itr; ++k) {
if (pre[k]->first.test(i)) {
--one_itr;
*one_itr = pre[k];
}
else {
vec.set(k);
*zero_itr = pre[k];
++zero_itr;
}
}
std::reverse(one_itr, cur.end());
vec.build(cur);
}
}
std::tuple<mapped_type, mapped_type, mapped_type>
fold_leg(size_type first, size_type last, const key_type &key) const {
mapped_type less = mapped_structure::identity(),
greater = mapped_structure::identity();
std::size_t i = BitLength;
while (i != static_cast<std::size_t>(0)) {
--i;
const bitvector &vec = matrix[i];
const size_type f = vec.count(first), l = vec.count(last),
z = vec.zeros();
if (key.test(i)) {
less = mapped_structure::operation(std::move(less),
vec.fold(z - f, z - l));
first += f;
last += l;
}
else {
greater = mapped_structure::operation(vec.fold(first + f, last + l),
std::move(greater));
first = z - f;
last = z - l;
}
}
return std::forward_as_tuple(
std::move(less), matrix.front().fold(first, last), std::move(greater));
}
std::pair<mapped_type, mapped_type>
fold_quantile(size_type first, size_type last, size_type k) const {
mapped_type less = mapped_structure::identity(),
greater = mapped_structure::identity();
std::size_t i = BitLength;
while (i != static_cast<std::size_t>(0)) {
--i;
const bitvector &vec = matrix[i];
const size_type f = vec.count(first), l = vec.count(last),
z = vec.zeros();
if (f - l <= k) {
k -= f - l;
less = mapped_structure::operation(std::move(less),
vec.fold(z - f, z - l));
first += f;
last += l;
}
else {
greater = mapped_structure::operation(vec.fold(first + f, last + l),
std::move(greater));
first = z - f;
last = z - l;
}
}
return std::make_pair(
mapped_structure::operation(std::move(less),
matrix.front().fold(first, first + k)),
mapped_structure::operation(matrix.front().fold(first + k, last),
std::move(greater)));
}
};
template <class T> class plus_abelian {
public:
using value_type = T;
static value_type operation(const value_type &x, const value_type &y) {
return x + y;
}
static value_type identity() { return static_cast<value_type>(0); }
static value_type inverse(const value_type &x) { return -x; }
static value_type reverse(const value_type &x) { return x; }
};
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <iostream>
#include <limits>
#include <utility>
#include <vector>
#include<cstdio>
int main() {
using i64 = std::int_fast64_t;
static constexpr int BitLen = 30;
int n;
std::cin >> n;
std::vector<i64> a(3 * n);
for (auto &e : a) {
scanf("%lld", &e);
}
foldable_wavelet_matrix<BitLen, plus_abelian<i64>> fwm;
{
std::vector<std::pair<std::bitset<BitLen>, i64>> b(3 * n);
for (int i = 0; i < 3 * n; ++i) {
b[i].first = a[i];
b[i].second = a[i];
}
fwm = foldable_wavelet_matrix<BitLen, plus_abelian<i64>>(b.cbegin(),
b.cend());
}
i64 max = std::numeric_limits<i64>::min();
for (int i = n; i <= 2 * n; ++i) {
max = std::max(max, fwm.fold_quantile(0, i, i - n).second -
fwm.fold_quantile(i, 3 * n, n).first);
}
printf("%lld\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:205:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
205 | printf("%lld\n", ans);
| ^~~
| abs
|
s583555851 | p03716 | C++ | #include <array>
#include <cstddef>
#include <cstdint>
#include <vector>
using usize = std::size_t;
using u64 = long long;
struct foldable_wavelet_matrix {
static constexpr usize BitLen = static_cast<usize>(4);
struct bitvector {
struct node_type {
usize count;
u64 sum;
};
std::vector<node_type> vector;
bitvector() : vector() {}
void resize(const usize size) { vector.resize(size+1); }
void set(const usize index) { vector[index+1].count = static_cast<usize>(1); }
void build(const std::vector<u64> &a) {
const usize size = a.size();
for (usize i = static_cast<usize>(0); i != size; ++i) {
vector[i + static_cast<usize>(1)].count += vector[i].count;
vector[i + static_cast<usize>(1)].sum = vector[i].sum + a[i];
}
}
usize count(const usize index) const { return vector[index].count; }
usize zeros() const { return vector.size()-1 - vector.back().count; }
u64 fold(const usize first, const usize last) const {
return vector[last].sum - vector[first].sum;
}
};
std::array<bitvector, BitLen> matrix;
explicit foldable_wavelet_matrix(std::vector<u64> a) {
const usize size = a.size();
std::vector<u64> b(size);
usize bitpos = BitLen;
while (bitpos != static_cast<usize>(0)) {
--bitpos;
bitvector &v = matrix[bitpos];
v.resize(size);
auto zero_itr = b.begin(), one_itr = b.end();
for (usize i = static_cast<usize>(0); i != size; ++i) {
if ((a[i] >> bitpos & static_cast<u64>(1)) == static_cast<u64>(1)) {
v.set(i);
--one_itr;
*one_itr = a[i];
}
else {
*zero_itr = a[i];
++zero_itr;
}
}
std::reverse(one_itr, b.end());
v.build(b);
std::swap(a, b);
}
}
u64 fold_topk(usize first, usize last, usize k) const {
u64 ret = static_cast<u64>(0);
usize bitpos = BitLen;
while (bitpos != static_cast<usize>(0)) {
--bitpos;
const bitvector &v = matrix[bitpos];
const usize f_cnt = v.count(first), l_cnt = v.count(last),
zeros = v.zeros();
if (k < l_cnt - f_cnt) {
first = zeros + f_cnt;
last = zeros + l_cnt;
}
else {
k -= l_cnt - f_cnt;
ret += v.fold(zeros + f_cnt, zeros + l_cnt);
first -= f_cnt;
last -= l_cnt;
}
}
return ret + matrix.front().fold(last - k, last);
}
};
#include<vector>
#include<iostream>
#include<algorithm>
int main() {
usize n;
std::cin >> n;
std::vector<u64> a(3*n );
for (auto &e : a) {
std::cin >> e;
}
foldable_wavelet_matrix fwm(a);
u64 max = -1000000000LL * 100000LL;
for (int i = n;i <= 2 * n;++i) {
max = std::max(max,
fwm.fold_topk(0, i, n)
- (fwm.fold_topk(i, 3 * n, 3 * n - i)
- fwm.fold_topk(i, 3 * n, 3 * n - i - n)));
}
std::cout << max << std::endl;
return 0;
}
| a.cc: In constructor 'foldable_wavelet_matrix::foldable_wavelet_matrix(std::vector<long long int>)':
a.cc:61:30: error: 'reverse' is not a member of 'std'
61 | std::reverse(one_itr, b.end());
| ^~~~~~~
|
s714809031 | p03716 | Java | import java.util.*;
public class Main {
static Scanner scanner = new Scanner(System.in);
public static void main(String[]$) {
int n = scanner.nextInt();
int m = n * 3;
long[] a = new long[m];
for (int i = 0; i < m; i++) {
a[i] = scanner.nextInt();
}
PriorityQueue<Long> queue = new PriorityQueue<>();
long[] max = new long[n + 1];
long sum = 0;
for (int i = 0; i < m; i++) {
queue.add(a[i]);
if (i >= n && i <= n * 2) {
max[i - n] = sum;
sum -= queue.poll();
}
sum += a[i];
}
queue = new PriorityQueue<>(Comparator.reverseOrder());
long[] min = new long[n + 1];
sum = 0;
for (int i = m; i > 0; i--) {
queue.add(a[i - 1]);
Utils.println(i, sum, queue);
if (i >= n && i <= n * 2) {
min[i - n] = sum;
sum -= queue.poll();
}
sum += a[i - 1];
}
long ans = Integer.MIN_VALUE;
for (int i = 0; i <= n; i++) {
ans = Math.max(ans, max[i] - min[i]);
}
System.out.println(ans);
}
} | Main.java:30: error: cannot find symbol
Utils.println(i, sum, queue);
^
symbol: variable Utils
location: class Main
1 error
|
s112560671 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
int n;
int a[114514 * 3];
vector<int>ansl, ansr;
priority_queue<int, vector<int>, greater<int>())l;
priority_queue<int>r;
int suml = 0, sumr = 0;
int ans = -inf;
signed main() {
cin >> n;
rep(i, n * 3) {
cin >> a[i];
if (i < n) {
l.push(a[i]);
suml += a[i];
}
else if (2 * n <= i) {
r.push(a[i]);
sumr += a[i];
}
}
ansl.push_back(suml);
for (int i = n; i < 2 * n; i++) {
l.push(a[i]);
suml += a[i];
suml -= l.top();
l.pop();
ansl.push_back(suml);
}
ansr.push_back(sumr);
for (int i = 2 * n - 1; i >= n; i--) {
r.push(a[i]);
sumr += a[i];
sumr -= r.top();
r.pop();
ansr.push_back(sumr);
}
reverse(ansr.begin(), ansr.end());
for (int i = n; i < 2 * n; i++) {
ans = max(ans, ansl[i - n] - ansr[i - n]);
}
cout << ans << endl;
} | a.cc:9:47: error: type/value mismatch at argument 3 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue'
9 | priority_queue<int, vector<int>, greater<int>())l;
| ^
a.cc:9:47: note: expected a type, got 'std::greater<long long int>{std::binary_function<long long int, long long int, bool>()}'
a.cc:9:48: error: expected unqualified-id before ')' token
9 | priority_queue<int, vector<int>, greater<int>())l;
| ^
a.cc: In function 'int main()':
a.cc:18:25: error: 'l' was not declared in this scope
18 | l.push(a[i]);
| ^
a.cc:29:17: error: 'l' was not declared in this scope
29 | l.push(a[i]);
| ^
|
s051487213 | p03716 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
#include <iomanip>
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
void print(const std::vector<long long> &v) {
std::for_each(v.begin(), v.end(),
[](long long x) { std::cout << x << " "; });
std::cout << std::endl;
}
int main() {
int N;
cin >> N;
vector<long long> a(3 * N);
REP(i, 3 * N) cin >> a[i];
vector<long long> S(N * 2 + 1, 0);
priority_queue<long long, vector<long long>, greater<long long>> que1;
for(int i = 0; i < N; i++) { //はじめにN個で初期化計算
S[i + 1] = S[i] + a[i]; //累積和
que1.push(a[i]);
}
for(int i = N; i < N * 2; i++) {
long long mi = que.top();
if(a[i] > mi) {
S[i + 1] = S[i] + a[i] - mi;
que1.pop();
que1.push(a[i]);
} else
S[i + 1] = S[i];
}
vector<long long> T(N * 2 + 1, 0);
prioroity_queue<long long> que2;
//初期化処理
for(int i = 0; i < N; i++) {
T[i + 1] = T[i] + a[N * 3 - 1 - i];
que2.pop();
que2.push(a[N * 3 - 1 - i]);
}
for(int i = N; i < N * 2; ++i) {
long long ma = que2.top();
if(a[N * 3 - 1 - i] < ma) {
T[i + 1] = T[i] - ma + a[N * 3 - 1 - i];
que2.pop();
que2.push(a[N * 3 - 1 - i]);
} else
T[i + 1] = T[i];
}
long long res = -INF;
for(int i = N; i <= N * 2; i++) {
res = max(res, S[i] - T[N * 3 - i]);
}
cout << res << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:46:24: error: 'que' was not declared in this scope; did you mean 'que1'?
46 | long long mi = que.top();
| ^~~
| que1
a.cc:56:5: error: 'prioroity_queue' was not declared in this scope
56 | prioroity_queue<long long> que2;
| ^~~~~~~~~~~~~~~
a.cc:56:21: error: expected primary-expression before 'long'
56 | prioroity_queue<long long> que2;
| ^~~~
a.cc:60:9: error: 'que2' was not declared in this scope; did you mean 'que1'?
60 | que2.pop();
| ^~~~
| que1
a.cc:64:24: error: 'que2' was not declared in this scope; did you mean 'que1'?
64 | long long ma = que2.top();
| ^~~~
| que1
|
s439847023 | p03716 | C++ | using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello{
public static void Main(){
int N = NextInt();
int[] a = LineInt();
long[] memo = new long[3*N];
long Num = 0;
PriorityQueue<long,long> PQ1 = new PriorityQueue<long,long>();
for(int i = 0;i < N;i++){
Num += a[i];
PQ1.Add(a[i],a[i]);
}
memo[N-1] = Num;
for(int i = N;i < 2*N;i++){
//追加して最小を吐き出す
Num += a[i];
PQ1.Add(a[i],a[i]);
Num -= PQ1.Take();
//iまでの取れる最大値をメモする
memo[i] = Num;
}
//逆方向も考える
Num = 0;
PriorityQueue<long,long> PQ2 = new PriorityQueue<long,long>(false);
long ans = 0;
for(int i = 2*N;i < 3*N;i++){
Num += a[i];
PQ2.Add(a[i],a[i]);
}
ans = memo[2*N-1]-Num;
for(int i = 2*N - 1;i >= N;i--){
//大きいのから追い出していく
Num += a[i];
PQ2.Add(a[i],a[i]);
Num -= PQ2.Take();
//現在の取れる後半の最小の値 = Num
//このときの前半の最大値 = memo[i-1]
ans = Math.Max(ans,memo[i-1] - Num);
}
Console.WriteLine(ans);
}
}
public class PriorityQueue<Tkey, Tvalue> where Tkey : IComparable
{
private List<Tkey> keys = new List<Tkey>();
private List<Tvalue> values = new List<Tvalue>();
private int size = 0;
private static bool Descending;
private static int Compare(Tkey a, Tkey b) { return (Descending ? a.CompareTo(b) : b.CompareTo(a)); }
public PriorityQueue(bool b = true) { Clear(); Descending = b; }
public int Count() { return size; }
public void Clear() { keys = new List<Tkey>(); values = new List<Tvalue>(); size = 0; }
public void Add(Tkey e, Tvalue v)
{
keys.Add(e);
values.Add(v);
int x = size;
size += 1;
while (x != 0)
{
int par = (x % 2 == 0 ? x - 2 : x - 1) / 2;
if (Compare(keys[par], e) <= 0) break;
Tkey a = keys[x]; keys[x] = keys[par]; keys[par] = a;
Tvalue b = values[x]; values[x] = values[par]; values[par] = b;
x = par;
}
}
public void Poll()
{
Tkey k = keys[size - 1];
Tvalue v = values[size - 1];
int x = 0;
size--;
if (size == 0) { Clear(); return; }
keys.RemoveAt(size);
values.RemoveAt(size);
while (true)
{
int l = x * 2 + 1;
int r = x * 2 + 2;
if (size - 1 < l) break;
int y = 0;
if (size - 1 == l) { y = l; }
else if (Compare(keys[l], keys[r]) == 1) { y = r; }
else { y = l; }
if (Compare(keys[y], k) > 0) break;
keys[x] = keys[y];
values[x] = values[y];
x = y;
}
keys[x] = k;
values[x] = v;
}
public Tvalue Take() { Tvalue ret = values[0]; Poll(); return ret; }
public Tvalue Peek() { return values[0]; }
public void Debug()
{
Console.Write("key : ");
foreach (var k in keys) Console.Write(k + " ");
Console.WriteLine();
Console.Write("value : ");
foreach (var k in values) Console.Write(k + " ");
Console.WriteLine();
}
}
public class Input
{
private static Queue<string> queue = new Queue<string>();
private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
public static string NextString() { Confirm(); return queue.Dequeue(); }
public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections.Generic;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Linq;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'static'
4 | using static Input;
| ^~~~~~
a.cc:5:1: error: expected unqualified-id before 'public'
5 | public class Hello{
| ^~~~~~
a.cc:46:1: error: expected unqualified-id before 'public'
46 | public class PriorityQueue<Tkey, Tvalue> where Tkey : IComparable
| ^~~~~~
a.cc:110:1: error: expected unqualified-id before 'public'
110 | public class Input
| ^~~~~~
|
s362772945 | p03716 | C++ | using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello{
public static void Main(){
int N = NextInt();
int[] a = LineInt();
long[] memo = new long[3*N];
long Num = 0;
PriorityQueue<long,long> PQ1 = new PriorityQueue<long,long>();
for(int i = 0;i < N;i++){
Num += a[i];
PQ1.Add(a[i],a[i]);
}
memo[N-1] = Num;
for(int i = N;i < 2*N;i++){
//追加して最小を吐き出す
Num += a[i];
PQ1.Add(a[i],a[i]);
Num -= PQ1.Take();
//iまでの取れる最大値をメモする
memo[i] = Num;
}
//逆方向も考える
Num = 0;
PriorityQueue<long,long> PQ2 = new PriorityQueue<long,long>(false);
long ans = -10000000000000007;
for(int i = 2*N;i < 3*N;i++){
Num += a[i];
PQ2.Add(a[i],a[i]);
}
for(int i = 2*N - 1;i >= N;i--){
//大きいのから追い出していく
Num += a[i];
PQ2.Add(a[i],a[i]);
Num -= PQ2.Take();
//現在の取れる後半の最小の値 = Num
//このときの前半の最大値 = memo[i-1]
ans = Math.Max(ans,memo[i-1] - Num);
}
Console.WriteLine(ans);
}
}
public class PriorityQueue<Tkey, Tvalue> where Tkey : IComparable
{
private List<Tkey> keys = new List<Tkey>();
private List<Tvalue> values = new List<Tvalue>();
private int size = 0;
private static bool Descending;
private static int Compare(Tkey a, Tkey b) { return (Descending ? a.CompareTo(b) : b.CompareTo(a)); }
public PriorityQueue(bool b = true) { Clear(); Descending = b; }
public int Count() { return size; }
public void Clear() { keys = new List<Tkey>(); values = new List<Tvalue>(); size = 0; }
public void Add(Tkey e, Tvalue v)
{
keys.Add(e);
values.Add(v);
int x = size;
size += 1;
while (x != 0)
{
int par = (x % 2 == 0 ? x - 2 : x - 1) / 2;
if (Compare(keys[par], e) <= 0) break;
Tkey a = keys[x]; keys[x] = keys[par]; keys[par] = a;
Tvalue b = values[x]; values[x] = values[par]; values[par] = b;
x = par;
}
}
public void Poll()
{
Tkey k = keys[size - 1];
Tvalue v = values[size - 1];
int x = 0;
size--;
if (size == 0) { Clear(); return; }
keys.RemoveAt(size);
values.RemoveAt(size);
while (true)
{
int l = x * 2 + 1;
int r = x * 2 + 2;
if (size - 1 < l) break;
int y = 0;
if (size - 1 == l) { y = l; }
else if (Compare(keys[l], keys[r]) == 1) { y = r; }
else { y = l; }
if (Compare(keys[y], k) > 0) break;
keys[x] = keys[y];
values[x] = values[y];
x = y;
}
keys[x] = k;
values[x] = v;
}
public Tvalue Take() { Tvalue ret = values[0]; Poll(); return ret; }
public Tvalue Peek() { return values[0]; }
public void Debug()
{
Console.Write("key : ");
foreach (var k in keys) Console.Write(k + " ");
Console.WriteLine();
Console.Write("value : ");
foreach (var k in values) Console.Write(k + " ");
Console.WriteLine();
}
}
public class Input
{
private static Queue<string> queue = new Queue<string>();
private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
public static string NextString() { Confirm(); return queue.Dequeue(); }
public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections.Generic;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Linq;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'static'
4 | using static Input;
| ^~~~~~
a.cc:5:1: error: expected unqualified-id before 'public'
5 | public class Hello{
| ^~~~~~
a.cc:45:1: error: expected unqualified-id before 'public'
45 | public class PriorityQueue<Tkey, Tvalue> where Tkey : IComparable
| ^~~~~~
a.cc:109:1: error: expected unqualified-id before 'public'
109 | public class Input
| ^~~~~~
|
s554866261 | p03716 | C++ | #include <bits/stdc++.h>
#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;
typedef long long ll;
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
namespace pb_ds {
namespace io {
const int MaxBuff = 1 << 15;
const int Output = 1 << 23;
char B[MaxBuff], *S = B, *T = B;
#define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
char Out[Output], *iter = Out;
inline void flush() {
fwrite(Out, 1, iter - Out, stdout);
iter = Out;
}
}
template<class Type = int> inline Type read() {
using namespace io;
register char ch; register Type ans = 0; register bool neg = 0;
while(ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
ch == '-' ? neg = 1 : ans = ch - '0';
while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
return neg ? -ans : ans;
}
}
using namespace pb_ds;
void File() {
#ifdef zjp_shadow
freopen ("D.in", "r", stdin);
freopen ("D.out", "w", stdout);
#endif
}
const int N = 3e5 + 1e3;
int n, a[N];
ll pre[N], suf[N];
priority_queue<int> Max;
priority_queue<int, vector<int>, greater<int>> Min;
int main () {
File();
n = read();
For (i, 1, n * 3) a[i] = read();
For (i, 1, n)
Min.push(a[i]), pre[i] = pre[i - 1] + a[i];
For (i, n + 1, 2 * n) {
pre[i] = pre[i - 1];
if (a[i] > Min.top())
pre[i] += a[i] - Min.top(), Min.pop(), Min.push(a[i]);
}
Fordown (i, n * 3, n * 2 + 1)
Max.push(a[i]), suf[i] = suf[i + 1] + a[i];
Fordown (i, n * 2, n + 1) {
suf[i] = suf[i + 1];
if (a[i] < Max.top())
suf[i] += a[i] - Max.top(), Max.pop(), Max.push(a[i]);
}
ll ans = pre[n] - suf[n + 1];
For (i, n, 2 * n)
chkmax(ans, pre[i] - suf[i + 1]);
printf ("%lld\n", ans);
return 0;
| a.cc: In function 'Type pb_ds::read()':
a.cc:32:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | register char ch; register Type ans = 0; register bool neg = 0;
| ^~
a.cc:32:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | register char ch; register Type ans = 0; register bool neg = 0;
| ^~~
a.cc:32:64: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | register char ch; register Type ans = 0; register bool neg = 0;
| ^~~
a.cc: In function 'int main()':
a.cc:63:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
63 | For (i, 1, n * 3) a[i] = read();
| ^
a.cc:3:40: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:63:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
63 | For (i, 1, n * 3) a[i] = read();
| ^
a.cc:3:49: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:65:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
65 | For (i, 1, n)
| ^
a.cc:3:40: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:65:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
65 | For (i, 1, n)
| ^
a.cc:3:49: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:68:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
68 | For (i, n + 1, 2 * n) {
| ^
a.cc:3:40: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:68:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
68 | For (i, n + 1, 2 * n) {
| ^
a.cc:3:49: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:74:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
74 | Fordown (i, n * 3, n * 2 + 1)
| ^
a.cc:4:44: note: in definition of macro 'Fordown'
4 | #define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
| ^
a.cc:74:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
74 | Fordown (i, n * 3, n * 2 + 1)
| ^
a.cc:4:53: note: in definition of macro 'Fordown'
4 | #define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
| ^
a.cc:77:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
77 | Fordown (i, n * 2, n + 1) {
| ^
a.cc:4:44: note: in definition of macro 'Fordown'
4 | #define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
| ^
a.cc:77:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
77 | Fordown (i, n * 2, n + 1) {
| ^
a.cc:4:53: note: in definition of macro 'Fordown'
4 | #define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
| ^
a.cc:84:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
84 | For (i, n, 2 * n)
| ^
a.cc:3:40: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:84:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
84 | For (i, n, 2 * n)
| ^
a.cc:3:49: note: in definition of macro 'For'
3 | #define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
| ^
a.cc:88:18: error: expected '}' at end of input
88 | return 0;
| ^
a.cc:58:13: note: to match this '{'
58 | int main () {
| ^
a.cc: In instantiation of 'Type pb_ds::read() [with Type = int]':
a.cc:62:10: required from here
62 | n = read();
| ~~~~^~
a.cc:32:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | register char ch; register Type ans = 0; register bool neg = 0;
| ^~
a.cc:32:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | register char ch; register Type ans = 0; register bool neg = 0;
| ^~~
a.cc:32:64: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | register char ch; register Type ans = 0; register bool neg = 0;
| ^~~
|
s763436142 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[333333],sum,c[333333],d[333333],ans=-1e15;
priority_queue<int,vector<int>,greater<int>>q;
priority_queue<int,vector<int>>Q;
signed main(){
cin>>n;
rep(i,3*n)cin>>a[i];
rep(i,n){
q.push(a[i]);
sum+=a[i];
}
c[n-1]=sum;
for(int i=n;i<2*n;i++){
int p=q.top();
if(p<a[i]){
q.pop();
q.push(a[i]);
sum+=a[i]-p;
}
c[i]=sum;
}
sum=0;
for(int i=3*n-1;i>=2*n;i--){
Q.push(a[i]);
sum+=a[i];
}
d[2*n-1]=sum;
for(int i=2*n-1;i>=n;i--){
int p=Q.top();
if(p>a[i]){
Q.pop();
Q.push(a[i]);
sum+=a[i]-p;
}
d[i]=sum;
}
for(int i=n;i<2*n;i++){ans=max(ans,c[i-1]-d[i]);
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:2: error: expected '}' at end of input
43 | }
| ^
a.cc:8:14: note: to match this '{'
8 | signed main(){
| ^
|
s807714229 | p03716 | C++ | #include <iostream>
#include <queue>
#include <vector>
#include <list>
using namespace std;
int a[300000];
int main()
{
int N;
priority_queue<int, vector<int>, greater<int>> pf, cf;
priority_queue<int> ps, cs;
int sum_f, sum_s;
queue<int> dif_f;
vector<int> dif_s;
long long int max;
sum_f = sum_s = 0;
max = - (long long int)pow(10, 9);
cin >> N;
for (int i = 0; i < N * 3; i++)
{
cin >> a[i];
if (i < N)
{
pf.push(a[i]);
sum_f += a[i];
}
else if(2 * N <= i)
{
ps.push(a[i]);
sum_s += a[i];
}
}
for (int i = N; i <= 2 * N; i++)
{
dif_f.push(sum_f);
pf.push(a[i]);
sum_f += a[i];
sum_f -= pf.top();
pf.pop();
}
for (int i = 2 * N - 1; i >= N - 1; i--)
{
dif_s.push_back(sum_s);
ps.push(a[i]);
sum_s += a[i];
sum_s -= ps.top();
ps.pop();
}
for (int i = 0; i < (int)dif_f.size(); i++)
{
if (max < dif_f.front() - dif_s.back())
max = dif_f.front() - dif_s.back();
dif_f.pop();
dif_s.pop_back();
}
cout << max << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:32: error: 'pow' was not declared in this scope
19 | max = - (long long int)pow(10, 9);
| ^~~
|
s048096247 | p03716 | C++ | #include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int main(void)
{
LL n;
vector<LL> a(n*3);
for(auto &x:a) cin >> x;
vector<LL> l(n+2),r(n+2);
priority_queue<LL> lp,rp;
REP(i,n) {
l[0]+=x[i];
lp.push(-x[i]);
r[n+1]+=x[i+n*2];
rp.push(x[i]);
}
REP(i,n+1) {
lp.push(-x[n+i]);
l[i+n]=l[i+n-1]+x[n+i]+lp.top();
lp.pop();
rp.push(x[n*2-i-1]);
r[n-i]=r[n-i+1]+x[n*2-i-1]-rp.top();
rp.pop();
}
LL answer=l[0]-r[0];
REP(i,n+2) {
answer=max(answer,l[i]-r[i]);
}
cout << answer << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:16:11: error: 'x' was not declared in this scope
16 | l[0]+=x[i];
| ^
a.cc:22:14: error: 'x' was not declared in this scope
22 | lp.push(-x[n+i]);
| ^
|
s631684184 | p03716 | C++ | #include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
int main() {
int N; cin >> N;
ll a[300100]; FOR(i, 0, 3 * N) cin >> a[i];
priority_queue<ll, vector<ll>, greater<ll>> pque_front;
priority_queue<ll> pque_back;
ll sum1i= 0, sum2i = 0;
FOR(j, 0, N) {
sum1i += a[j];
pque_front.push(a[j]);
}
FOR(j, 2 * N , 3 * N) {
sum2i += a[j];
pque_back.push(a[j]);
}
ll sum1[300100], sum2[300100];
sum1[N - 1] = sum1i;
sum2[2 * N] = sum2i;
ll ans = sum1 - sum2;
FOR(j, N , 2 * N ){
sum1[j] = sum1[j - 1] + a[j];
pque_front.push(a[j]);
sum1[j] = sum[j - 1] - pque_front.top();
pque_front.pop();
sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
pque_back.push(a[j]);
sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
pque_back.pop();
}
FOR(j, N , 2 * N ){
ll sum = sum1[j] - sum2[3 * N - 1 - j];
ans = max(ans, sum);
}
printf("%lld\n", ans);
}
| a.cc: In function 'int main()':
a.cc:39:19: error: 'sum' was not declared in this scope; did you mean 'sum2'?
39 | sum1[j] = sum[j - 1] - pque_front.top();
| ^~~
| sum2
|
s343369349 | p03716 | C++ | #include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
int main() {
int N; cin >> N;
ll a[300100]; FOR(i, 0, 3 * N) cin >> a[i];
priority_queue<ll, vector<ll>, greater<ll>> pque_front;
priority_queue<ll> pque_back;
ll sum1i= 0, sum2i = 0;
FOR(j, 0, N) {
sum1i += a[j];
pque_front.push(a[j]);
}
FOR(j, 2 * N , 3 * N) {
sum2i += a[j];
pque_back.push(a[j]);
}
ll sum1[300100], sum2[300100];
sum1[N - 1] = sum1i;
sum2[2 * N] = sum2i;
ll ans = sum1 - sum2;
FOR(j, N , 2 * N ){
sum1[j] = sum[j - 1] + a[j];
pque_front.push(a[j]);
sum1[j] = sum[j - 1] - pque_front.top();
pque_front.pop();
sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
pque_back.push(a[j]);
sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
pque_back.pop();
}
FOR(j, N , 2 * N ){
ll sum = sum1[j] - sum2[3 * N - 1 - j];
ans = max(ans, sum);
}
printf("%lld\n", ans);
}
| a.cc: In function 'int main()':
a.cc:37:19: error: 'sum' was not declared in this scope; did you mean 'sum2'?
37 | sum1[j] = sum[j - 1] + a[j];
| ^~~
| sum2
|
s708472388 | p03716 | C++ | #include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
int main() {
int N; cin >> N;
ll a[300100]; FOR(i, 0, 3 * N) cin >> a[i];
priority_queue<ll, vector<ll>, greater<ll>> pque_front;
priority_queue<ll> pque_back;
ll sum1= 0, sum2 = 0;
FOR(j, 0, N) {
sum1 += a[j];
pque_front.push(a[j]);
}
FOR(j, 2 * N , 3 * N) {
sum2 += a[j];
pque_back.push(a[j]);
}
ll sum1[300100], sum2[300100];
sum1[N - 1] = sum1;
sum2[2 * N] = sum2;
ll ans = sum1 - sum2;
FOR(j, N , 2 * N ){
sum1[j] = sum[j - 1] + a[j];
pque_front.push(a[j]);
sum1[j] = sum[j - 1] - pque_front.top();
pque_front.pop();
sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
pque_back.push(a[j]);
sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
pque_back.pop();
}
FOR(j, N , 2 * N ){
ll sum = sum1[j] - sum2[3 * N - 1 - j];
ans = max(ans, sum);
}
printf("%lld\n", ans);
}
| a.cc: In function 'int main()':
a.cc:29:8: error: conflicting declaration 'll sum1 [300100]'
29 | ll sum1[300100], sum2[300100];
| ^~~~
a.cc:17:8: note: previous declaration as 'll sum1'
17 | ll sum1= 0, sum2 = 0;
| ^~~~
a.cc:29:22: error: conflicting declaration 'll sum2 [300100]'
29 | ll sum1[300100], sum2[300100];
| ^~~~
a.cc:17:17: note: previous declaration as 'll sum2'
17 | ll sum1= 0, sum2 = 0;
| ^~~~
a.cc:31:9: error: invalid types 'll {aka long long int}[int]' for array subscript
31 | sum1[N - 1] = sum1;
| ^
a.cc:32:9: error: invalid types 'll {aka long long int}[int]' for array subscript
32 | sum2[2 * N] = sum2;
| ^
a.cc:37:13: error: invalid types 'll {aka long long int}[int]' for array subscript
37 | sum1[j] = sum[j - 1] + a[j];
| ^
a.cc:37:19: error: 'sum' was not declared in this scope; did you mean 'sum2'?
37 | sum1[j] = sum[j - 1] + a[j];
| ^~~
| sum2
a.cc:39:13: error: invalid types 'll {aka long long int}[int]' for array subscript
39 | sum1[j] = sum[j - 1] - pque_front.top();
| ^
a.cc:42:13: error: invalid types 'll {aka long long int}[int]' for array subscript
42 | sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
| ^
a.cc:42:35: error: invalid types 'll {aka long long int}[int]' for array subscript
42 | sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
| ^
a.cc:44:13: error: invalid types 'll {aka long long int}[int]' for array subscript
44 | sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
| ^
a.cc:44:35: error: invalid types 'll {aka long long int}[int]' for array subscript
44 | sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
| ^
a.cc:49:22: error: invalid types 'll {aka long long int}[int]' for array subscript
49 | ll sum = sum1[j] - sum2[3 * N - 1 - j];
| ^
a.cc:49:32: error: invalid types 'll {aka long long int}[int]' for array subscript
49 | ll sum = sum1[j] - sum2[3 * N - 1 - j];
| ^
|
s511506431 | p03716 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define _SI(arr) (sizeof(arr)/sizeof(arr[0])
int main() {
ll N;
cin >> N;
vector<ll> a(3 * N), v1, v2;
for (ll i = 0; i < 3 * N; i++)cin >> a[i];
priority_queue<ll, vector<ll>, greater<ll>> que1; // 昇順
priority_queue<ll, vector<ll>> que2; // 降順
ll cnt1 = 0, cnt2 = 0, max = LLONG_MIN;
for (ll i = 0; i < N; i++)
{
que1.push(a[i]);
cnt1 += a[i];
que2.push(a[3 * N - i - 1]);
cnt2 += a[3 * N - i - 1];
}
v1.push_back(cnt1);
v2.push_back(cnt2);
for (ll i = N; i < 2 * N; i++)
{
que1.push(a[i]);
cnt1 += a[i] - que1.top();
que1.pop();
v1.push_back(cnt1);
que2.push(a[3 * N - i - 1]);
cnt2 += a[3 * N - i - 1] - que2.top();
que2.pop();
v2.push_back(cnt2);
}
for (ll i = 0; i <= N; i++)
{
if (max < v1[i] - v2[N - i])
{
max = v1[i] - v2[N - i];
}
}
cout << max << endl;
}
| a.cc: In function 'int main()':
a.cc:26:38: error: 'LLONG_MIN' was not declared in this scope
26 | ll cnt1 = 0, cnt2 = 0, max = LLONG_MIN;
| ^~~~~~~~~
a.cc:11:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
10 | #include <map>
+++ |+#include <climits>
11 |
|
s218651744 | p03716 | C++ |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 9999999999
/*Solve*/
int main(){
int n;
cin >> n;
ll a[100010];
ll ans=0;
rep(i,3*n){
cin >> a[i];
}
ll tmp=0;
FOR(i,n,2*n+1){
priority_queue<pair<ll,ll>> fhlf;
priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<>> shlf;
tmp=0;
rep(j,3*n){
if(j<i){
fhlf.push({a[j],j});
}else{shlf.push({a[j],j});}
}
rep(i,n){
tmp+=fhlf.top().first-shlf.top().first;
fhlf.pop();
shlf.pop();
}
if(ans<tmp)ans=tmp;
} | a.cc: In function 'int main()':
a.cc:38:6: error: expected '}' at end of input
38 | }
| ^
a.cc:13:11: note: to match this '{'
13 | int main(){
| ^
|
s283199518 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(3 * n);
for (int i = 0; i < 3 * n; i++) {
int a_;
cin >> a_;
a[i] = a_;
}
vector<int> dp(n);
vector<long long> maxv(n + 1, 0);
for (int i = 0; i < n; i++) {
dp[i] = a[i];
maxv[0] += (long long)a[i];
}
sort(dp.begin(), dp.end());
for (int i = 0; i < n; i++) {
int crr = a[n + i];
maxv[i + 1] = maxv[i];
if (crr > dp[0]) {
maxv[i + 1] += (long long)crr;
maxv[i + 1] -= (long long)dp[0];
int lb = lower_bound(dp.begin(), dp.end(), crr) - dp.begin();
dp.insert(dp.begin() + lb, crr);
dp.erase(dp.begin());
}
}
vector<int> ep(n);
vector<long long> minv(n + 1, 0);
for (int i = 0; i < n; i++) {
ep[i] = a[2 * n + i];
minv[0] += (long long)a[2 * n + i];
}
sort(ep.begin(), ep.end());
for (int i = 0; i < n; i++) {
int crr = a[2 * n - 1 - i];
minv[i + 1] = minv[i];
if (crr < ep[n - 1]) {
minv[i + 1] += (long long)crr;
minv[i + 1] -= (long long)ep[n - 1];
int lb = lower_bound(ep.begin(), ep.end(), crr) - ep.begin();
ep.insert(ep.begin() + lb, crr);
ep.pop_back();
}
}
int ans = -1e9;
for (int i = 0; i <= n; i++) {
ans = max(ans, maxv[i] - minv[n - i]);
}
cout << ans << '\n';
return 0;
} | a.cc: In function 'int main()':
a.cc:53:14: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
53 | ans = max(ans, maxv[i] - minv[n - 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:53:14: 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'})
53 | ans = max(ans, maxv[i] - minv[n - 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:53:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
53 | ans = max(ans, maxv[i] - minv[n - i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s722996661 | p03716 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n;
cin>>n;
ll a[n*3],bb[n+1],cc[n+1];
bb[0]=0,cc[n]=0;
priority_queue<ll> c;
priority_queue<ll,vector<ll>,greater<ll>> b;
for(int i=0;i<n*3;i++){
cin>>a[i];
if(i<n){
b.push(a[i]);
bb[0]+=a[i];
}
else if(i>=n*2){
c.push(a[i]);
cc[n]+=a[i];
}
}
for(int i=1;i<=n;i++){
b.push(a[i+n-1]);
bb[i]=bb[i-1]+a[i+n-1]-b.top();
b.pop();
} | a.cc: In function 'int main()':
a.cc:26:4: error: expected '}' at end of input
26 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s863849489 | p03716 | C++ | /* ****GT_18**** */
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl '\n'
#define pii pair<ll int,ll int>
#define vi vector<ll int>
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define sz(x) (ll int)x.size()
#define hell 1000000007
#define rep(i,a,b) for(ll int i=a;i<b;i++)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define mp make_pair
using namespace std;
#define N 100005
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int TESTS=1;
// cin>>TESTS;
while(TESTS--)
{
int n,i,ans=INT_MIN;
ll sum=0;
priority_queue<int> q;
priority_queue<int,vector<int>,greater<int>>p;
cin>>n;
ll arr[3*n+1],g[3*n],s[3*n];
rep(i,0,3*n)
cin>>arr[i];
for(i=0;i<3*n;i++)
{
sum+=arr[i];
p.push(arr[i]);
if(i>=n)
{
sum-=p.top();
p.pop();
}
g[i]=sum;
}sum=0;
for(i=3*n-1;i>=0;i--)
{
s[i]=sum;
sum+=arr[i];
q.push(arr[i]);
if(i<2*n)
{
sum-=q.top();
q.pop();
}
}
for(i=n-1;i<2*n;i++)
{
ans=max(ans,g[i]-s[i]);
}
cout<<ans;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:68:32: error: no matching function for call to 'max(int&, long long int)'
68 | ans=max(ans,g[i]-s[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:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:68:32: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
68 | ans=max(ans,g[i]-s[i]);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:68:32: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
68 | ans=max(ans,g[i]-s[i]);
| ~~~^~~~~~~~~~~~~~~
|
s965107179 | p03716 | C++ | #include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,a,summa1=0,summa2=0;
cin>>n;
set<pair<long long int,long long int> > s1;
set<pair<long long int,long long int> > s2;
vector<pair<long long int,long long int> > v;
for(long long int i=1;i<=3*n;i++)
{
cin>>a;
if(i<=3*n/2)
{
pair<long long int,long long int> p;
p=make_pair(a,i);
s1.insert(p);
v.push_back(p);
}
else
{
pair<long long int,long long int> p;
p=make_pair(a,i);
s2.insert(p);
//s2.insert(a);
}
}
set<pair<long long int,long long int> >::iterator itit=s2.end();
itit--;
if(n%2==1)
{
//cout<<1;
s2.erase(itit);
}
//cout<<" "<<it->first<<" ";
long long int count=0;
while(count<n/2)
{
set<pair<long long int,long long int> >::iterator it=s2.end();
it--;
//cout<<it->first;
long long int sum1=it->first-s1.begin()->first;
//cout<<sum1<<" ";
vector<pair<long long int,long long int> >::iterator op=v.end();
opt--;
long long int sum2=it->first+(--it)->first-2*opt->first;
//cout<<sum2;
if(sum2>sum1)
{
pair<long long int,long long int> p;
//pair<long long int,long long int> p1;
// pair<long long int,long long int> p2;
vector<pair<long long int,long long int> >::iterator op=v.end();
op--;
p=make_pair(op->first,op->second);
s1.erase(s1.find(p));
//s1.erase(p);
//p1=make_pair(s2.end()->first,s2.end()->second);
//p2=make_pair((s2.end()-1)->first,(s2.end-1)->second);
//s2.erase(p1);
//s2.erase(p2);
it++;
s2.erase(it);
it--;
s2.erase(it);
s2.insert(p);
v.erase(op);
}
else
{
it++;
s1.erase(s1.begin());
s2.erase(it);
long long int k=s1.begin()->second;
v.erase(v.begin()+k-1);
}
count++;
}
set<pair<long long int,long long int> >::iterator itr1;
{
for(itr1=s1.begin();itr1!=s1.end();itr1++)
{
summa1+=itr1->first;
}
for(itr1=s2.begin();itr1!=s2.end();itr1++)
{
summa2+=itr1->first;
}
}
cout<<summa1-summa2;
return 0;
} | a.cc: In function 'int main()':
a.cc:46:25: error: 'opt' was not declared in this scope; did you mean 'op'?
46 | opt--;
| ^~~
| op
|
s448684017 | p03716 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
//変数
int N;
vector<int> a;
//解法
void solve() {
ll ans = LLONG_MIN;
rep(i, N + 1) {
vector<int> front, back;
rep(j, N*3) {
if (j < N + i) {
front.emplace_back(a[j]);
}
else {
back.emplace_back(a[j]);
}
}
sort(front.begin(), front.end(), less<int>());
sort(back.begin(), back.end(), greater<int>());
front.erase(front.begin(), front.begin() + i);
back.erase(back.begin(), back.begin() + (N - i));
int size = front.size();
ll sum1=0, sum2=0,sum;
rep(j, size) sum1 += front[j];
size = back.size();
rep(j, size) sum2 += back[j];
sum = sum1 - sum2;
if (ans < sum) ans = sum;
}
cout << ans;
return;
}
int main() {
//入力
cin >> N;
a.resize(3*N);
rep(i, 3*N) cin >> a[i];
solve();
cout << endl;
return 0;
}
| a.cc: In function 'void solve()':
a.cc:23:18: error: 'LLONG_MIN' was not declared in this scope
23 | ll ans = LLONG_MIN;
| ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
8 | #include <functional>
+++ |+#include <climits>
9 | #include <limits>
|
s379661981 | p03716 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
//変数
int N;
vector<int> a;
//解法
void solve() {
ll ans = LLONG_MIN;
rep(i, N + 1) {
vector<int> front, back;
rep(j, N*3) {
if (j < N + i) {
front.emplace_back(a[j]);
}
else {
back.emplace_back(a[j]);
}
}
sort(front.begin(), front.end(), less<int>());
sort(back.begin(), back.end(), greater<int>());
front.erase(front.begin(), front.begin() + i);
back.erase(back.begin(), back.begin() + (N - i));
int size = front.size();
ll sum1=0, sum2=0,sum;
rep(j, size) sum1 += front[j];
size = back.size();
rep(j, size) sum2 += back[j];
sum = sum1 - sum2;
if (ans < sum) ans = sum;
}
cout << ans;
return;
}
int main() {
//入力
cin >> N;
a.resize(3*N);
rep(i, 3*N) cin >> a[i];
solve();
cout << endl;
return 0;
}
| a.cc: In function 'void solve()':
a.cc:22:18: error: 'LLONG_MIN' was not declared in this scope
22 | ll ans = LLONG_MIN;
| ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
8 | #include <functional>
+++ |+#include <climits>
9 | using namespace std;
|
s954534837 | p03716 | C++ | #include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX_V 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
ll N;
ll a[300001];
ll sm[2][100001];
int main(void) {
cin >> N;
ll i;
for(i=0; i<N*3; i++) {
cin >> a[i];
}
priority_queue<ll, greater<ll>> pque1;
for(i=0; i<N; i++) {
sm[0][0]+=a[i];
pque1.push(a[i]);
}
for(i=0; i<N; i++) {
sm[0][i+1]=sm[0][i];
sm[0][i+1]+=a[N+i];
sm[0][i+1]-=pque1.top();
pque1.pop();
}
priority_queue<ll> pque2;
for(i=0; i<N; i++) {
sm[1][N]+=a[N*2+i];
pque2.push(a[N*2+i]);
}
for(i=0; i<N; i++) {
sm[1][N-1-i]=sm[1][N-i];
sm[1][N-1-i]+=a[N*2-i-1];
sm[1][N-1-i]-=pque2.top();
pque2.pop();
}
ll ans=-INF;
for(i=0; i<=N; i++) {
ans=max(ans, sm[0][i]-sm[1][i]);
}
prin(ans);
} | a.cc: In function 'int main()':
a.cc:46:34: error: no type named 'value_type' in 'struct std::greater<long long int>'
46 | priority_queue<ll, greater<ll>> pque1;
| ^~
a.cc:46:34: error: template argument 3 is invalid
a.cc:49:15: error: request for member 'push' in 'pque1', which is of non-class type 'int'
49 | pque1.push(a[i]);
| ^~~~
a.cc:54:27: error: request for member 'top' in 'pque1', which is of non-class type 'int'
54 | sm[0][i+1]-=pque1.top();
| ^~~
a.cc:55:15: error: request for member 'pop' in 'pque1', which is of non-class type 'int'
55 | pque1.pop();
| ^~~
|
s399363591 | p03716 | C++ | #include <bits/stdc++.h>
#include <windows.h>
#define change_read() freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin)
#define change_write() freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout)
#define creat_read() freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout)
using namespace std;
const int maxm = 1e5+10;
int num[maxm];
long long sum[maxm];
long long les[maxm];
long long bet[maxm];
priority_queue<int>que2;
priority_queue<int,vector<int>,greater<int> >que1;
int main() {
// change_read();
cin.tie(0);
ios::sync_with_stdio(false);
int len;
cin>>len;
len = (len+1)<<1;
int x = len/3;
for(int i = 1;i<=len;i++){
cin>>num[i];
sum[i] = sum[i-1]+num[i];
if(i<=x) que1.push(num[i]);
else if(i>=(x<<1)) que2.push(num[i]);
}
bet[x] = sum[x];
for(int i = 1;i<=x;i++){
que1.push(num[i+x]);
bet[i+x] = bet[i+x-1]+num[i+x]-que1.top();
que1.pop();
}
les[x<<1] = sum[len]-sum[x<<1];
for(int i = 1;i<=x;i++){
que2.push(num[len-x-i]);
les[len-x-i] = les[len-x-i+1]-que2.top()+num[len-x-i+1];
que2.pop();
}
long long ans = -1e18;
for(int i = x;i<(x<<1);i++){
ans = max(ans,bet[i]-les[i]);
}
cout<<ans<<endl;
return 0;
}
//3 1 4 1 5 9
//3 4 7 7 9 14
//2 2 5 6 14 9
| a.cc:2:10: fatal error: windows.h: No such file or directory
2 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s252800703 | p03716 | C++ | #include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
int main(){
long long i,n,x,ans=0,j,k;
priority_queue <long long> front,last;
cin >> n;
long long a[n],b[n];
for(i=0;i<n;i++){
cin >> x;
ans += x;
front.push(-x);
}
for(i=0;i<n;i++){
cin >> x;
a[i] = x;
b[n-1-i] = x;
}
for(i=0;i<n;i++){
cin >> x;
ans -= x;
last.push(x);
}
j = 0;
k = 0;
for(i=0;i<n;i++){
if(front.top()+a[j] > last.top()-b[k]){
ans += front.top()+a[j];
front.pop();
front.push(a[j]);
j++;
}else{
ans += last.top()-b[k];
last.pop();
last.pop(b[k]);
k++;
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:40:33: error: no matching function for call to 'std::priority_queue<long long int>::pop(long long int&)'
40 | last.pop(b[k]);
| ~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/queue:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:771:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = long long int; _Sequence = std::vector<long long int, std::allocator<long long int> >; _Compare = std::less<long long int>]'
771 | pop()
| ^~~
/usr/include/c++/14/bits/stl_queue.h:771:7: note: candidate expects 0 arguments, 1 provided
|
s889957116 | p03716 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool vcmp(int a,int b){
return a>b;
}
int resultUtil(vector<int> &a,int m){
int n=a.size()/3;
vector<int> left(m);
vector<int> right(3*n-m);
int i=0;
for(i=0;i<left.size();i++){
left[i]=a[i];
}
for(int j=0;j<right.size();j++){
right[j]=a[i];
i++;
}
sort(left.begin(),left.end(),vcmp);
sort(right.begin(),right.end());
int sumLeft=0,sumRight=0;
for(int i=0;i<n;i++){
sumLeft+=left[i];
sumRight+=right[i];
}
return sumLeft-sumRight;
}
int result(vector<int> &a){
int fresult=INT_MIN;
int n=a.size()/3;
for(int m=n;m<=2*n;m++){
fresult=max(fresult,resultUtil(a,m));
}
return fresult;
}
int main(){
int n;
cin>>n;
vector<int> a(3*n);
for(int i=0;i<3*n;i++)
cin>>a[i];
cout<<result(a);
} | a.cc: In function 'int result(std::vector<int>&)':
a.cc:34:21: error: 'INT_MIN' was not declared in this scope
34 | int fresult=INT_MIN;
| ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include<algorithm>
+++ |+#include <climits>
4 |
|
s224036898 | p03716 | C++ | #include<bits/stdc++.h>
#define INF 1e9
using ll = long long;
#define int ll
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repr(i,a,b) for(int i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main(){
int n; cin >> n;
vector<int> v(3*n),lv,sv;
rep(i,0,3*n) cin >> v[i];
priority_queue<int,vector<int>,greater<int>>lque;
priority_queue<int,vector<int>>sque;
int ls=0,ss=0;
rep(i,0,n){
lque.push(v[i]);
sque.push(v[2*n+i]);
ls+=v[i];
ss+=v[2*n+i];
}
lv.push_back(ls);
sv.push_back(ss);
int ans=-INF*INF;
ans = max(ans,ls-ss);
rep(i,0,n){
lque.push(v[n+i]);
sque.push(v[2*n-i-1]);
ls+=(v[n+i]-lque.top()); //min change
ss+=(v[2*n-i-1]-sque.top()); //max change
lv.push_back(ls);
sv.push_back(ss);
sque.pop();
lque.pop();
}
rep(i,0,lv.size()) ans = max(ans,lv[i]-sv[n-i]);
cout << ans << endl;
return 0;
} | a.cc:4:13: error: '::main' must return 'int'
4 | #define int ll
| ^~
a.cc:9:1: note: in expansion of macro 'int'
9 | int main(){
| ^~~
|
s143871695 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
ll a[MAX]={};
for(int i=0;i<3*n;i++){
cin>>a[i];
}
priority_queue<ll,vector<ll>,greater<ll>> aq;
ll sum=0;
for(int i=0;i<n;i++){
aq.push(a[i]);
sum+=a[i];
}
ll ansa[MAX];
ansa[n-1]=sum;
for(int i=n;i<2*n;i++){
aq.push(a[i]);
sum+=a[i];
sum-=aq.top();
aq.pop();
ansa[i]=sum;
}
sum=0;
ll ansb[MAX];
priority_queue<ll> bq;
for(int i=3*n-1;i>=2*n;i--){
bq.push(a[i]);
sum+=a[i];
}
ansb[2*n]=sum;
for(int i=2*n-1;i>=n;i--){
bq.push(a[i]);
sum += a[i];
sum -= bq.top();
bq.pop();
ansb[i] = sum;
}
ll ans =- INF;
for(int i=n-1;i<2*n;i++){
ans=max(ans,ansa[i]-ansb[i+1]);
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:46:5: error: 'll' was not declared in this scope; did you mean 'LL'?
46 | ll a[MAX]={};
| ^~
| LL
a.cc:49:14: error: 'a' was not declared in this scope
49 | cin>>a[i];
| ^
a.cc:51:32: error: template argument 2 is invalid
51 | priority_queue<ll,vector<ll>,greater<ll>> aq;
| ^
a.cc:51:44: error: template argument 2 is invalid
51 | priority_queue<ll,vector<ll>,greater<ll>> aq;
| ^~
a.cc:51:44: error: template argument 3 is invalid
a.cc:53:7: error: expected ';' before 'sum'
53 | ll sum=0;
| ^~~~
| ;
a.cc:56:12: error: request for member 'push' in 'aq', which is of non-class type 'int'
56 | aq.push(a[i]);
| ^~~~
a.cc:56:17: error: 'a' was not declared in this scope
56 | aq.push(a[i]);
| ^
a.cc:57:9: error: 'sum' was not declared in this scope
57 | sum+=a[i];
| ^~~
a.cc:60:7: error: expected ';' before 'ansa'
60 | ll ansa[MAX];
| ^~~~~
| ;
a.cc:61:5: error: 'ansa' was not declared in this scope
61 | ansa[n-1]=sum;
| ^~~~
a.cc:61:15: error: 'sum' was not declared in this scope
61 | ansa[n-1]=sum;
| ^~~
a.cc:64:12: error: request for member 'push' in 'aq', which is of non-class type 'int'
64 | aq.push(a[i]);
| ^~~~
a.cc:64:17: error: 'a' was not declared in this scope
64 | aq.push(a[i]);
| ^
a.cc:66:17: error: request for member 'top' in 'aq', which is of non-class type 'int'
66 | sum-=aq.top();
| ^~~
a.cc:67:12: error: request for member 'pop' in 'aq', which is of non-class type 'int'
67 | aq.pop();
| ^~~
a.cc:72:7: error: expected ';' before 'ansb'
72 | ll ansb[MAX];
| ^~~~~
| ;
a.cc:73:22: error: template argument 2 is invalid
73 | priority_queue<ll> bq;
| ^
a.cc:73:22: error: template argument 3 is invalid
a.cc:76:12: error: request for member 'push' in 'bq', which is of non-class type 'int'
76 | bq.push(a[i]);
| ^~~~
a.cc:76:17: error: 'a' was not declared in this scope
76 | bq.push(a[i]);
| ^
a.cc:80:5: error: 'ansb' was not declared in this scope
80 | ansb[2*n]=sum;
| ^~~~
a.cc:82:12: error: request for member 'push' in 'bq', which is of non-class type 'int'
82 | bq.push(a[i]);
| ^~~~
a.cc:82:17: error: 'a' was not declared in this scope
82 | bq.push(a[i]);
| ^
a.cc:84:19: error: request for member 'top' in 'bq', which is of non-class type 'int'
84 | sum -= bq.top();
| ^~~
a.cc:85:12: error: request for member 'pop' in 'bq', which is of non-class type 'int'
85 | bq.pop();
| ^~~
a.cc:90:7: error: expected ';' before 'ans'
90 | ll ans =- INF;
| ^~~~
| ;
a.cc:93:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
93 | ans=max(ans,ansa[i]-ansb[i+1]);
| ^~~
| abs
a.cc:96:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
96 | cout<<ans<<endl;
| ^~~
| abs
|
s712794366 | p03716 | C++ | #include <queue>
#include <limits>
using namespace std;
int arr[300005];
long long int prefNSum[300005]; //arr[1] ~ arr[i] 중 가장 큰 N개의 합
long long int suffNSum[300005]; //arr[i] ~ arr[N] 중 가장 작은 N개의 합
priority_queue<int, vector<int>, greater<int> > minHeap;
priority_queue<int> maxHeap;
int main(){
int N, tmp;
scanf("%d", &N);
for(int i=1; i<=3*N; ++i)
scanf("%d", arr+i);
for(int i=1; i<=N; ++i){
minHeap.push(arr[i]);
prefNSum[N] += arr[i];
}
for(int i=N+1; i<=2*N; ++i){
tmp = minHeap.top();
if(arr[i] >= tmp){
prefNSum[i] = prefNSum[i-1] - tmp + arr[i];
minHeap.pop();
minHeap.push(arr[i]);
}else{
prefNSum[i] = prefNSum[i-1];
}
}
for(int i=3*N; i>2*N; --i){
maxHeap.push(arr[i]);
suffNSum[2*N+1] += arr[i];
}
for(int i=2*N; i>N; --i){
tmp = maxHeap.top();
if(arr[i] <= tmp){
suffNSum[i] = suffNSum[i+1] - tmp + arr[i];
maxHeap.pop();
maxHeap.push(arr[i]);
}else{
suffNSum[i] = suffNSum[i+1];
}
}
long long int ans = numeric_limits<long long int>::min();
for(int i=N; i<=2*N; ++i){
ans = max(ans, prefNSum[i] - suffNSum[i+1]);
}
printf("%lld\n", ans);
}
| a.cc: In function 'int main()':
a.cc:12:9: error: 'scanf' was not declared in this scope
12 | scanf("%d", &N);
| ^~~~~
a.cc:48:9: error: 'printf' was not declared in this scope
48 | printf("%lld\n", ans);
| ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
2 | #include <limits>
+++ |+#include <cstdio>
3 | using namespace std;
|
s335285871 | p03716 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> A(3 * N);
for (auto&& a : A) {
cin >> a;
}
vector<ll> dp(N + 1);
dp[0] = accumulate(A.begin(), A.begin() + N, 0LL);
priority_queue<ll, vector<ll>, greater<ll> > que;
for_each(A.begin(), A.begin() + N, [&](ll a) { que.push(a); });
for (ll i = 1; i <= N; i++) {
ll top = que.top();
ll val = A[i + N - 1];
dp[i] = dp[i - 1];
if (top < val) {
dp[i] += val - top;
que.pop();
}
}
vector<ll> dp2(N + 1);
dp2[0] = accumulate(A.rbegin(), A.rbegin() + N, 0LL);
priority_queue<ll> que2;
for_each(A.rbegin(), A.rbegin() + N, [&](ll a) { que2.push(a); });
for (ll i = 1; i <= N; i++) {
ll top = que2.top();
ll val = A[2 * N - i];
ll dp2[i] = dp2[i - 1];
if (top > val) {
dp2[i] += val - top;
que2.pop();
}
}
ll ans = -1e18;
for (ll i = 0; i <= N; i++) {
ans = max(ans, dp[i] - dp2[N - i]);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:52:30: error: array must be initialized with a brace-enclosed initializer
52 | ll dp2[i] = dp2[i - 1];
| ~~~~~~~~~^
|
s994001743 | p03716 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int A[300000];
long long sum[300000];
long long ssum[300000];
PGQ que1;
PQ que2;
int main(){
int N;
cin>>N;
FOR(i,0,3*N){
cin>>A[i];
}
long long x=0,y=0;
FOR(i,0,N){
que1.push(A[i]);
x+=A[i];
}
sum[N-1]=x;
FOR(i,N,2*N){
que1.push(A[i]);
x+=A[i];
x-=que1.top();
que1.pop();
sum[i]=x;
}
FOR(i,2*N,3*N){
que2.push(A[i]);
y+=A[i];
}
ssum[2*N-1]=y;
ROF(i,N,2*N){
que2.push(A[i]);
y+=A[i];
y-=que2.top();
que2.pop();
ssum[i-1]=y;
}
long long M=-1e15;
FOR(i,N-1,2*N){
M=max(M,sum[i]-ssum[i]);
}
cout<<M<<endl;
return 0;
}
| a.cc:54:17: error: extended character is not valid in an identifier
54 | ssum[2*N-1]=y;
| ^
a.cc: In function 'int main()':
a.cc:54:17: error: '\U00003000' was not declared in this scope
54 | ssum[2*N-1]=y;
| ^~
a.cc:55:7: error: 'i' was not declared in this scope
55 | ROF(i,N,2*N){
| ^
a.cc:10:34: note: in definition of macro 'ROF'
10 | #define ROF(i,a,b) for(int i=b-1;i>=a;i--)
| ^
|
s780464345 | p03716 | C++ | #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
int N;
long long A[310000];
typedef long long VAL;
const VAL INF = 1LL<<60;
const int MAX_R = 310000;
int SIZE_R;
struct RMQ {
pair<VAL,int> dat[4*MAX_R];
int AN;
void init(int n = MAX_R, VAL v = INF) {
AN = n;
SIZE_R = 1;
while (SIZE_R < n) SIZE_R *= 2;
for (int i = 0; i < 2*MAX_R-1; ++i) dat[i] = make_pair(v, -1);
}
inline void init_set(int a, VAL x) {
int k = a + SIZE_R-1;
dat[k] = make_pair(x, a);
}
inline void init_tree(int k = 0, int l = 0, int r = SIZE_R) {
if (r - l == 1) {} // leaf
else {
init_tree(k*2+1, l, (l+r)/2);
init_tree(k*2+2, (l+r)/2, r);
dat[k] = min(dat[k*2+1], dat[k*2+2]);
}
}
inline void set(int a, VAL x) {
int k = a + SIZE_R-1;
dat[k] = make_pair(x, a);
while (k > 0) {
k = (k-1)/2;
dat[k] = min(dat[k*2+1], dat[k*2+2]);
}
}
inline pair<VAL,int> get(int a, int b, int k = 0, int l = 0, int r = SIZE_R) {
if (r <= a || b <= l) return make_pair(INF, -1);
if (a <= l && r <= b) return dat[k];
else {
pair<VAL,int> vl = get(a, b, k*2+1, l, (l+r)/2);
pair<VAL,int> vr = get(a, b, k*2+2, (l+r)/2, r);
return min(vl, vr);
}
}
inline VAL operator [] (int a) {
return get(a, a+1).first;
}
void print() {
for (int i = 0; i < r; ++i) {
long long val = (*this)[i];
if (val < INF) cout << val;
else cout << "INF";
if (i != r-1) cout << ",";
}
cout << endl;
}
};
RMQ rmq;
int main() {
while (cin >> N) {
rmq.init(N*3);
for (int i = 0; i < N*3; ++i) cin >> A[i], rmq.init_set(i, A[i]);
rmq.init_tree();
vector<pair<long long,int> > vec;
for (int i = 0; i < N*2; ++i) vec.push_back(make_pair(A[i+N], i+N));
sort(vec.begin(), vec.end());
long long zen = 0, kou = 0;
for (int i = 0; i < N; ++i) {
zen += A[i];
kou += vec[i].first;
rmq.set(vec[i].second, INF);
}
long long res = zen - kou;
/*
COUT("first: ");
rmq.print(N*3);
COUT(zen); COUT(kou); COUT(res);
*/
for (int i = N; i < N*2; ++i) {
pair<long long,int> Min = rmq.get(0, i + 1);
if (Min.first != A[i]) {
zen += A[i] - Min.first;
rmq.set(Min.second, INF);
}
else {
rmq.set(i, INF);
}
if (rmq[i] == INF) {
Min = rmq.get(i, N*3);
kou += Min.first - A[i];
rmq.set(Min.second, INF);
}
/*
cout << "-----------------" << endl;
COUT(i);
rmq.print(N*3);
COUT(zen); COUT(kou); COUT(res);
*/
chmax(res, zen - kou);
}
cout << res << endl;
}
}
| a.cc: In member function 'void RMQ::print()':
a.cc:95:31: error: 'r' was not declared in this scope
95 | for (int i = 0; i < r; ++i) {
| ^
|
s412582832 | p03716 | C++ | const fi='';
fo='';
oo=trunc(1e18);
maxn=trunc(1e5);
var n:longint;
sol:int64;
nheapmin,nheapmax:longint;
heapmax,heapmin:array[0..2*maxn]of longint;
a:array[0..3*maxn]of longint;
l,r:array[0..3*maxn]of int64;
function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
procedure swap(var a,b:Longint);
var temp:longint;
begin
temp:=a;
a:=b;
b:=temp;
end;
procedure upmax(i:longint);
begin
if (i=1)or(heapmax[i div 2]>=heapmax[i]) then exit
else begin
swap(heapmax[i],heapmax[i div 2]);
upmax(i div 2);
end;
end;
procedure upmin(i:longint);
begin
if (i=1)or(heapmin[i div 2]<=heapmin[i]) then exit
else begin
swap(heapmin[i div 2],heapmin[i]);
upmin(i div 2);
end;
end;
procedure downmax(i:longint);
var gt:longint;
begin
gt:=i*2;
if gt>nheapmax then exit;
if (gt+1<=nheapmax)and(heapmax[gt]<heapmax[gt+1]) then inc(gt);
if heapmax[i]>=heapmax[gt] then exit;
begin
swap(heapmax[gt],heapmax[i]);
downmax(gt);
end;
end;
procedure downmin(i:longint);
var gt:longint;
begin
gt:=i*2;
if gt>nheapmin then exit;
if (gt+1<=nheapmin)and(heapmin[gt]>heapmin[gt+1]) then inc(gt);
if heapmin[i]<=heapmin[gt] then exit;
begin
swap(heapmin[gt],heapmin[i]);
downmin(gt);
end;
end;
procedure pushmin(x:longint);
begin
inc(nheapmin);
heapmin[nheapmin]:=x;
upmin(nheapmin);
end;
procedure pushmax(x:longint);
begin
inc(nheapmax);
heapmax[nheapmax]:=x;
upmax(nheapmax);
end;
procedure popmin(x:longint);
begin
heapmin[1]:=x;
downmin(1);
end;
procedure popmax(x:longint);
begin
heapmax[1]:=x;
downmax(1);
end;
procedure inp;
var i:longint;
begin
read(n);
for i:=1 to 3*n do read(a[i]);
end;
procedure main;
var i,j:longint;
res:int64;
nmax,nmin:longint;
begin
res:=0;
for i:=1 to n do
begin
res:=res+a[i];
pushmin(a[i]);
end;
l[n]:=res;
for i:=n+1 to 2*n do
begin
if a[i]>heapmin[1] then
begin
res:=res-heapmin[1]+a[i];
popmin(a[i]);
end;
l[i]:=res;
end;
res:=0;
for i:=3*n downto 2*n+1 do
begin
res:=res+a[i];
pushmax(a[i]);
end;
r[2*n+1]:=res;
for i:=2*n downto n+1 do
begin
if a[i]<heapmax[1] then
begin
res:=res-heapmax[1]+a[i];
popmax(a[i]);
end;
r[i]:=res;
end;
sol:=-oo;
for i:=n to 2*n do sol:=max(sol,l[i]-r[i+1]);
write(sol);
end;
begin
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
inp;
main;
close(output);
end.
| a.cc:1:10: error: empty character constant
1 | const fi='';
| ^~
a.cc:2:10: error: empty character constant
2 | fo='';
| ^~
a.cc:8:29: error: too many decimal points in number
8 | heapmax,heapmin:array[0..2*maxn]of longint;
| ^~~~
a.cc:9:15: error: too many decimal points in number
9 | a:array[0..3*maxn]of longint;
| ^~~~
a.cc:10:17: error: too many decimal points in number
10 | l,r:array[0..3*maxn]of int64;
| ^~~~
a.cc:1:7: error: 'fi' does not name a type
1 | const fi='';
| ^~
a.cc:2:7: error: 'fo' does not name a type
2 | fo='';
| ^~
a.cc:3:7: error: 'oo' does not name a type; did you mean 'bool'?
3 | oo=trunc(1e18);
| ^~
| bool
a.cc:4:7: error: 'maxn' does not name a type
4 | maxn=trunc(1e5);
| ^~~~
a.cc:5:1: error: 'var' does not name a type
5 | var n:longint;
| ^~~
a.cc:6:10: error: found ':' in nested-name-specifier, expected '::'
6 | sol:int64;
| ^
| ::
a.cc:6:7: error: 'sol' does not name a type
6 | sol:int64;
| ^~~
a.cc:7:7: error: 'nheapmin' does not name a type
7 | nheapmin,nheapmax:longint;
| ^~~~~~~~
a.cc:8:7: error: 'heapmax' does not name a type
8 | heapmax,heapmin:array[0..2*maxn]of longint;
| ^~~~~~~
a.cc:9:8: error: found ':' in nested-name-specifier, expected '::'
9 | a:array[0..3*maxn]of longint;
| ^
| ::
a.cc:9:7: error: 'a' does not name a type
9 | a:array[0..3*maxn]of longint;
| ^
a.cc:10:7: error: 'l' does not name a type
10 | l,r:array[0..3*maxn]of int64;
| ^
a.cc:11:1: error: 'function' does not name a type; did you mean 'union'?
11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
| ^~~~~~~~
| union
a.cc:11:32: error: 'begin' does not name a type
11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
| ^~~~~
a.cc:11:63: error: expected constructor, destructor, or type conversion before '(' token
11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
| ^
a.cc:11:68: error: 'end' does not name a type
11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
| ^~~
a.cc:12:1: error: 'function' does not name a type; did you mean 'union'?
12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
| ^~~~~~~~
| union
a.cc:12:32: error: 'begin' does not name a type
12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
| ^~~~~
a.cc:12:63: error: expected constructor, destructor, or type conversion before '(' token
12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
| ^
a.cc:12:68: error: 'end' does not name a type
12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
| ^~~
a.cc:13:1: error: 'procedure' does not name a type
13 | procedure swap(var a,b:Longint);
| ^~~~~~~~~
a.cc:14:1: error: 'var' does not name a type
14 | var temp:longint;
| ^~~
a.cc:15:1: error: 'begin' does not name a type
15 | begin
| ^~~~~
a.cc:17:7: error: 'a' does not name a type
17 | a:=b;
| ^
a.cc:18:7: error: 'b' does not name a type
18 | b:=temp;
| ^
a.cc:19:1: error: 'end' does not name a type
19 | end;
| ^~~
a.cc:20:1: error: 'procedure' does not name a type
20 | procedure upmax(i:longint);
| ^~~~~~~~~
a.cc:21:1: error: 'begin' does not name a type
21 | begin
| ^~~~~
a.cc:25:24: error: expected constructor, destructor, or type conversion before '(' token
25 | upmax(i div 2);
| ^
a.cc:26:12: error: 'end' does not name a type
26 | end;
| ^~~
a.cc:27:1: error: 'end' does not name a type
27 | end;
| ^~~
a.cc:28:1: error: 'procedure' does not name a type
28 | procedure upmin(i:longint);
| ^~~~~~~~~
a.cc:29:1: error: 'begin' does not name a type
29 | begin
| ^~~~~
a.cc:33:24: error: expected constructor, destructor, or type conversion before '(' token
33 | upmin(i div 2);
| ^
a.cc:34:12: error: 'end' does not name a type
34 | end;
| ^~~
a.cc:35:1: error: 'end' does not name a type
35 | end;
| ^~~
a.cc:36:1: error: 'procedure' does not name a type
36 | procedure downmax(i:longint);
| ^~~~~~~~~
a.cc:37:1: error: 'var' does not name a type
37 | var gt:longint;
| ^~~
a.cc:38:1: error: 'begin' does not name a type
38 | begin
| ^~~~~
a.cc:40:7: error: expected unqualified-id before 'if'
40 | if gt>nheapmax then exit;
| ^~
a.cc:41:7: error: expected unqualified-id before 'if'
41 | if (gt+1<=nheapmax)and(heapmax[gt]<heapmax[gt+1]) then inc(gt);
| ^~
a.cc:42:7: error: expected unqualified-id before 'if'
42 | if heapmax[i]>=heapmax[gt] then exit;
| ^~
a.cc:43:7: error: 'begin' does not name a type
43 | begin
| ^~~~~
a.cc:45:28: error: expected constructor, destructor, or type conversion before '(' token
45 | downmax(gt);
| ^
a.cc:46:7: error: 'end' does not name a type
46 | end;
| ^~~
a.cc:47:1: error: 'end' does not name a type
47 | end;
| ^~~
a.cc:48:1: error: 'procedure' does not name a type
48 | procedure downmin(i:longint);
| ^~~~~~~~~
a.cc:49:1: error: 'var' does not name a type
49 | var gt:longint;
| ^~~
a.cc:50:1: error: 'begin' does not name a type
50 | begin
| ^~~~~
a.cc:52:7: error: expected unqualified-id before 'if'
52 | if gt>nheapmin then exit;
| ^~
a.cc:53:7: error: expected unqualified-id before 'if'
53 | if (gt+1<=nheapmin)and(heapmin[gt]>heapmin[gt+1]) then inc(gt);
| ^~
a.cc:54:7: error: expected unqualified-id before 'if'
54 | if heapmin[i]<=heapmin[gt] then exit;
| ^~
a.cc:55:7: error: 'begin' does not name a type
55 | begin
| ^~~~~
a.cc:57:26: error: expected constructor, destructor, or type conversion before '(' token
57 | downmin(gt);
| ^
a.cc:58:7: error: 'end' does not name a type
58 | end;
| ^~~
a.cc:59:1: error: 'end' does not name a type
59 | end;
| ^~~
a.cc:60:1: error: 'procedure' does not name a type
60 | procedure pushmin(x:longint);
| ^~~~~~~~~
a.cc:61:1: error: 'begin' does not name a type
61 | begin
| ^~~~~
a.cc:63:8: error: 'heapmin' does not name a type
63 | heapmin[nheapmin]:=x;
| ^~~~~~~
a.cc:64:13: error: expected constructor, destructor, or type conversion before '(' token
64 | upmin(nheapmin);
| ^
a.cc:65:1: error: 'end' does not name a type
65 | end;
| ^~~
a.cc:66:1: error: 'procedure' does not name a type
66 | procedure pushmax(x:longint);
| ^~~~~~~~~
a.cc:67:1: error: 'begin' does not name a type
67 | begin
| ^~~~~
a.cc:69:7: error: 'heapmax' does not name a type
69 | heapmax[nheapmax]:=x;
| ^~~~~~~
a.cc:70:12: error: expected constructor, destructor, or type conversion before '(' token
70 | upmax(nheapmax);
| ^
a.cc:71:1: error: 'end' does not name a type
71 | end;
| ^~~
a.cc:72:1: error: 'procedure' does not name a type
72 | procedure popmin(x:longint);
| ^~~~~~~~~
a.cc:73:1: error: 'begin' does not name a type
73 | begin
| ^~~~~
a.cc:75:14: error: expected constructor, destructor, or type conversion before '(' token
75 | downmin(1);
| ^
a.cc:76:1: error: 'end' does not name a type
76 | end;
| ^~~
a.cc:77:1: error: 'procedure' does not name a type
77 | procedure popmax(x:longint);
| ^~~~~~~~~
a.cc:78:1: error: 'begin' does not name a type
78 | begin
| ^~~~~
a.cc:80:15: error: expected constructor, destructor, or type conversion before '(' token
80 | downmax(1);
| ^
a.cc:81:1: error: 'end' does not name a type
81 | end;
| ^~~
a.cc:82:1: error: 'procedure' does not name a type
82 | procedure inp;
| ^~~~~~~~~
a.cc:83:1: error: 'var' does not name a type
83 | var i:longint;
| ^~~
a.cc:84:1: error: 'begin' does not name a type
84 | begin
| ^~~~~
a.cc:86:7: error: expected unqualified-id before 'for'
86 | for i:=1 to 3*n do read(a[i]);
| ^~~
a.cc:87:1: error: 'end' does not name a type
87 | end;
| ^~~
a.cc:88:1: error: 'procedure' does not name a type
88 | procedure main;
| ^~~~~~~~~
a.cc:89:1: error: 'var' does not name a type
89 | var i,j:longint;
| ^~~
a.cc:90:8: error: found ':' in nested-name-specifier, expected '::'
90 | res:int64;
| ^
| ::
a.cc:90:5: error: 'res' does not name a type
90 | res:int64;
| ^~~
a.cc:91:5: error: 'nmax' does not name a type
91 | nmax,nmin:longint;
| ^~~~
a.cc:92:1: error: 'begin' does not name a type
92 | begin
| ^~~~~
a.cc:94:7: error: expected unqualified-id before 'for'
94 | for i:=1 to n do
| ^~~
a.cc:97:18: error: expected constructor, destructor, or type conversion before '(' token
97 | pushmin(a[i]);
| ^
a.cc:98:7: error: 'end' does not name a type
98 | end;
| ^~~
a.cc:99:7: error: 'l' does not name a type
99 | l[n]:=res |
s650842474 | p03716 | C | #include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
const int MAXN = 1e5+10;
int n , a[MAXN];
long long ans = -1e18 , f[MAXN] , r[MAXN];
int main()
{
//freopen("B.inp" , "r" , stdin);
//freopen("B.out" , "w" , stdout);
scanf("%d",&n);
for(int i = 1 ; i<=3*n ; i++)
scanf("%d",&a[i]);
priority_queue<int , vector<int> , greater<int> > q;
for(int i = 1 ; i<=n ; i++)
{
q.push(a[i]);
f[n] += a[i];
}
for(int i = n+1 ; i<=2*n ; i++)
{
if(a[i] <= q.top()) f[i] = f[i-1];
else
{
f[i]= f[i-1] + a[i] - q.top();
q.pop();
q.push(a[i]);
}
}
priority_queue<int> qq;
for(int i = 3*n ; i>=2*n+1 ; i--)
{
r[2*n+1] += a[i];
qq.push(a[i]);
}
for(int i = 2*n ; i>=n+1 ; i--)
{
if(a[i] >= qq.top()) r[i] = r[i+1];
else
{
r[i] = r[i+1] + a[i] - qq.top();
qq.pop();
qq.push(a[i]);
}
}
for(int i = n ; i <= 2*n ; i++)
ans = max(ans , f[i] - r[i+1]);
printf("%lld",ans);
return 0;
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s239364447 | p03716 | C | #include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
int n , a[MAXN];
long long ans = -1e18 , f[MAXN] , r[MAXN];
int main()
{
scanf("%d",&n);
for(int i = 1 ; i<=3*n ; i++)
scanf("%d",&a[i]);
priority_queue<int , vector<int> , greater<int> > q;
for(int i = 1 ; i<=n ; i++)
{
q.push(a[i]);
f[n] += a[i];
}
for(int i = n+1 ; i<=2*n ; i++)
{
if(a[i] <= q.top()) f[i] = f[i-1];
else
{
f[i]= f[i-1] + a[i] - q.top();
q.pop();
q.push(a[i]);
}
}
priority_queue<int> qq;
for(int i = 3*n ; i>=2*n+1 ; i--)
{
r[2*n+1] += a[i];
qq.push(a[i]);
}
for(int i = 2*n ; i>=n+1 ; i--)
{
if(a[i] >= qq.top()) r[i] = r[i+1];
else
{
r[i] = r[i+1] + a[i] - qq.top();
qq.pop();
qq.push(a[i]);
}
}
for(int i = n ; i <= 2*n ; i++)
ans = max(ans , f[i] - r[i+1]);
printf("%lld",ans);
return 0;
}
| main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s424720979 | p03716 | C++ | #include <bits/stdc++.h>
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define all(x) (x).begin(), (x).end()
using namespace std;
const int inf = 1 << 28;
const int N = 100010;
const double pi=acos(-1.0);
int n;
int num[N * 3];
ll Ml[N], Mr[N];
int main()
{
int a, b;
n = read();
rep(i, 0, n * 3 - 1) num[i] = read();
priority_queue<int, vector<int>, greater<int> > Q1;
priority_queue<int> Q2;
rep(i, 0, n - 1)
{
Ml[0] += num[i];
Q1.push(num[i]);
Mr[n + 1] += num[n * 3 - 1 - i];
Q2.push(num[n * 3 - 1 - i]);
}
rep(i, 1, n)
{
Q1.push(num[n + i - 1]);
Ml[i] = Ml[i - 1] + num[n + i - 1] - Q1.top();
Q1.pop();
Q2.push(num[n * 2 - i]);
Mr[n + 1 - i] = Mr[n + 1 - i + 1] + num[n * 2 - i] - Q2.top();
Q2.pop();
}
ll ans;
rep(i, 0, n)
if(!i) ans = Ml[i] - Mr[i + 1];
else ans = max(ans, Ml[i] - Mr[i + 1]);
printf("%lld\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:28:13: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
28 | n = read();
| ~~~~^~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/c++/14/csignal:42,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
from a.cc:1:
/usr/include/unistd.h:371:16: note: declared here
371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
| ^~~~
a.cc:29:39: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
29 | rep(i, 0, n * 3 - 1) num[i] = read();
| ~~~~^~
/usr/include/unistd.h:371:16: note: declared here
371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
| ^~~~
|
s490529214 | p03716 | Java |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ArrayReconstruction {
/**
* @param args
* @throws IOException
*/
static int[] zeroes;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
String input = scan.readLine();
int changes = Integer.parseInt(input);
//conChanges = changes;
input = scan.readLine();
String[] array = input.split(" ");
zeroes = new int[changes];
set(changes);
System.out.println(max(0, changes, array));
}
public static int max(int index, int changes, String[] array) {
if (changes == 0) {
return cal(array);
}
if (index >= array.length && changes != 0 || (changes < 0)) {
return (int) -10e9;
}
int choice1 = (int) -10e9;
int choice2 = (int) -10e9;
choice1 = max(index+1, changes, array);
if (changes > 0) {
zeroes[changes - 1] = index;
choice2 = max(index+1, changes - 1, array);
}
return Math.max(choice1, choice2);
}
public static int cal(String[] array) {
int number = (((array.length)- zeroes.length)/2);
int taken = 0;
int sum1 = 0;
int sum2 = 0;
int i = 0;
for (i = 0; taken < number; i++) {
if (!include(i)) {
sum1 += Integer.parseInt(array[i]);
taken++;
}
}
int start = i;
for (i = start; i <array.length; i++) {
if (!include(i)) {
sum2 += Integer.parseInt(array[i]);
}
}
return sum1 - sum2;
}
public static boolean include(int number) {
for (int i = 0; i < zeroes.length; i++) {
if (number == zeroes[i]) {
return true;
}
}
return false;
}
public static void set(int changes) {
for (int i = 0; i <changes; i++) {
zeroes[i] = -1;
}
}
}
| Main.java:6: error: class ArrayReconstruction is public, should be declared in a file named ArrayReconstruction.java
public class ArrayReconstruction {
^
1 error
|
s370699459 | p03716 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Personal
*
*/
public class ArrayReconstruction {
/**
* @param args
* @throws IOException
*/
//static int conChanges;
static int[] zeroes;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
String input = scan.readLine();
int changes = Integer.parseInt(input);
//conChanges = changes;
input = scan.readLine();
String[] array = input.split(" ");
zeroes = new int[changes];
set(changes);
System.out.println(max(0, changes, array));
}
public static int max(int index, int changes, String[] array) {
if (changes == 0) {
return cal(array);
}
if (index >= array.length && changes != 0 || (changes < 0)) {
return (int) -10e9;
}
int choice1 = (int) -10e9;
int choice2 = (int) -10e9;
choice1 = max(index+1, changes, array);
if (changes > 0) {
zeroes[changes - 1] = index;
choice2 = max(index+1, changes - 1, array);
}
return Math.max(choice1, choice2);
}
public static int cal(String[] array) {
int number = (((array.length)- zeroes.length)/2);
int taken = 0;
int sum1 = 0;
int sum2 = 0;
int i = 0;
for (i = 0; taken < number; i++) {
if (!include(i)) {
sum1 += Integer.parseInt(array[i]);
taken++;
}
}
int start = i;
for (i = start; i <array.length; i++) {
if (!include(i)) {
sum2 += Integer.parseInt(array[i]);
}
}
return sum1 - sum2;
}
public static boolean include(int number) {
for (int i = 0; i < zeroes.length; i++) {
if (number == zeroes[i]) {
return true;
}
}
return false;
}
public static void set(int changes) {
for (int i = 0; i <changes; i++) {
zeroes[i] = -1;
}
}
}
| Main.java:9: error: class ArrayReconstruction is public, should be declared in a file named ArrayReconstruction.java
public class ArrayReconstruction {
^
1 error
|
s598070705 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fill(x,y) memset(x,y,sizeof(x))
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pb push_back
#define smp(x,y,z) mp(x,mp(y,z))
#define reads(x) scanf("%s",&x)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
typedef long long ll;
typedef string s;
typedef pair<ll,ll> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vector<int> > matrix;
const ll oo = 1e16;
const int maxSize = 100100;
const int mod = 1e9+7;
const double EPS = (1e-9);
int dcmp(double x, double y){return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;}
int arr[4*100000]={0};
ll fron[4*100000],bac[4*100000] ;
int main(){
int n ; cin >> n ;
for(int i=0 ;i<n*3 ;i++){
cin>> arr[i] ;
}
int i=0 ;
ll sum=0 ;
priority_queue<int> seq;
for(;i<n;i++){
sum+=arr[i];
seq.push(-1*arr[i]);
}
fron[n-1] = sum ;
for(;i<2*n;i++){
int out = seq.top() ;
if(arr[i]>-1*out){
seq.pop();
seq.push(-1*arr[i]);
sum -= -1*out-arr[i] ;
}
fron[i] = sum ;
}
i=3*n-1;
sum=0;
priority_queue<int> seq2;
for(;i>=2*n;i--){
sum+=arr[i];
seq2.push(arr[i]);
}
bac[i+1] = sum ;
for(;i>=n;i--){
int out = seq2.top() ;
if(arr[i]<out){
seq2.pop();
seq2.push(arr[i]);
sum -= out-arr[i] ;
}
bac[i] = sum ;
}
int maxi = -oo;
for(;i<2*n;i++){
maxi=max(maxi,fron[i]-bac[i+1]);
}
cout << maxi ;
}
/*
2
3 1 4 1 5 9*/
| a.cc: In function 'int main()':
a.cc:80:16: warning: overflow in conversion from 'long long int' to 'int' changes value from '-10000000000000000' to '-1874919424' [-Woverflow]
80 | int maxi = -oo;
| ^~~
a.cc:82:17: error: no matching function for call to 'max(int&, ll)'
82 | maxi=max(maxi,fron[i]-bac[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:82:17: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
82 | maxi=max(maxi,fron[i]-bac[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:82:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
82 | maxi=max(maxi,fron[i]-bac[i+1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
|
s796000564 | p03716 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ArrayReconstruction {
/**
* @param args
* @throws IOException
*/
static int[] zeroes;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
String input = scan.readLine();
int changes = Integer.parseInt(input);
//conChanges = changes;
input = scan.readLine();
String[] array = input.split(" ");
zeroes = new int[changes];
set(changes);
System.out.println(max(0, changes, array));
}
public static int max(int index, int changes, String[] array) {
if (changes == 0) {
return cal(array);
}
if (index >= array.length && changes != 0 || (changes < 0)) {
return (int) -10e9;
}
int choice1 = (int) -10e9;
int choice2 = (int) -10e9;
choice1 = max(index+1, changes, array);
if (changes > 0) {
zeroes[changes - 1] = index;
choice2 = max(index+1, changes - 1, array);
}
return Math.max(choice1, choice2);
}
public static int cal(String[] array) {
int number = (((array.length)- zeroes.length)/2);
int taken = 0;
int sum1 = 0;
int sum2 = 0;
int i = 0;
for (i = 0; taken < number; i++) {
if (!include(i)) {
sum1 += Integer.parseInt(array[i]);
taken++;
}
}
int start = i;
for (i = start; i <array.length; i++) {
if (!include(i)) {
sum2 += Integer.parseInt(array[i]);
}
}
return sum1 - sum2;
}
public static boolean include(int number) {
for (int i = 0; i < zeroes.length; i++) {
if (number == zeroes[i]) {
return true;
}
}
return false;
}
public static void set(int changes) {
for (int i = 0; i <changes; i++) {
zeroes[i] = -1;
}
}
} | Main.java:5: error: class ArrayReconstruction is public, should be declared in a file named ArrayReconstruction.java
public class ArrayReconstruction {
^
1 error
|
s289630542 | p03716 | Java |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ArrayReconstruction {
/**
* @param args
* @throws IOException
*/
static int[] zeroes;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
String input = scan.readLine();
int changes = Integer.parseInt(input);
//conChanges = changes;
input = scan.readLine();
String[] array = input.split(" ");
zeroes = new int[changes];
set(changes);
System.out.println(max(0, changes, array));
}
public static int max(int index, int changes, String[] array) {
if (changes == 0) {
return cal(array);
}
if (index >= array.length && changes != 0 || (changes < 0)) {
return (int) -10e9;
}
int choice1 = (int) -10e9;
int choice2 = (int) -10e9;
choice1 = max(index+1, changes, array);
if (changes > 0) {
zeroes[changes - 1] = index;
choice2 = max(index+1, changes - 1, array);
}
return Math.max(choice1, choice2);
}
public static int cal(String[] array) {
int number = (((array.length)- zeroes.length)/2);
int taken = 0;
int sum1 = 0;
int sum2 = 0;
int i = 0;
for (i = 0; taken < number; i++) {
if (!include(i)) {
sum1 += Integer.parseInt(array[i]);
taken++;
}
}
int start = i;
for (i = start; i <array.length; i++) {
if (!include(i)) {
sum2 += Integer.parseInt(array[i]);
}
}
return sum1 - sum2;
}
public static boolean include(int number) {
for (int i = 0; i < zeroes.length; i++) {
if (number == zeroes[i]) {
return true;
}
}
return false;
}
public static void set(int changes) {
for (int i = 0; i <changes; i++) {
zeroes[i] = -1;
}
}
}
| Main.java:6: error: class ArrayReconstruction is public, should be declared in a file named ArrayReconstruction.java
public class ArrayReconstruction {
^
1 error
|
s981050336 | p03716 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ArrayReconstruction {
static int[] zeroes;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
String input = scan.readLine();
int changes = Integer.parseInt(input);
//conChanges = changes;
input = scan.readLine();
String[] array = input.split(" ");
zeroes = new int[changes];
set(changes);
System.out.println(max(0, changes, array));
}
public static int max(int index, int changes, String[] array) {
if (changes == 0) {
return cal(array);
}
if (index >= array.length && changes != 0 || (changes < 0)) {
return (int) -10e9;
}
int choice1 = (int) -10e9;
int choice2 = (int) -10e9;
choice1 = max(index+1, changes, array);
if (changes > 0) {
zeroes[changes - 1] = index;
choice2 = max(index+1, changes - 1, array);
}
return Math.max(choice1, choice2);
}
public static int cal(String[] array) {
int number = (((array.length)- zeroes.length)/2);
int taken = 0;
int sum1 = 0;
int sum2 = 0;
int i = 0;
for (i = 0; taken < number; i++) {
if (!include(i)) {
sum1 += Integer.parseInt(array[i]);
taken++;
}
}
int start = i;
for (i = start; i <array.length; i++) {
if (!include(i)) {
sum2 += Integer.parseInt(array[i]);
}
}
return sum1 - sum2;
}
public static boolean include(int number) {
for (int i = 0; i < zeroes.length; i++) {
if (number == zeroes[i]) {
return true;
}
}
return false;
}
public static void set(int changes) {
for (int i = 0; i <changes; i++) {
zeroes[i] = -1;
}
}
} | Main.java:6: error: class ArrayReconstruction is public, should be declared in a file named ArrayReconstruction.java
public class ArrayReconstruction {
^
1 error
|
s453914381 | p03716 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
// greaterが通らないので定義
template<class _Ty>
struct greater
: public binary_function<_Ty, _Ty, bool>
{ // functor for operator<
bool operator()(const _Ty& _Left, const _Ty& _Right) const
{ // apply operator< to operands
return (_Left > _Right);
}
};
int a[100001];
long long b[100001];
long long s[100001];
int main()
{
int N;
cin >> N;
priority_queue <int> big_que;
priority_queue <int, vector<int>, greater<int> > small_que; // 小さい順で取り出す
for (int i = 1; i <= N; i++) {
int a;
cin >> a;
b[0] += a;
small_que.push(a);
}
for (int i = 1; i <= N; i++) {
cin >> a[i];
}
for (int i = 1; i <= N; i++) {
int a;
cin >> a;
s[N+1] += a;
big_que.push(a);
}
for (int pos = 1; pos <= N; pos++) {
small_que.push(a[pos]);
int s = small_que.top();
small_que.pop();
b[pos] = b[pos-1] + a[pos] - s;
}
for (int pos = N; pos > 0; pos--) {
big_que.push(a[pos]);
int b = big_que.top();
big_que.pop();
s[pos] = s[pos+1] + a[pos] - b;
}
long long max_dif = b[0] - s[N];
for (int pos = 0; pos <= N; pos++) { // どこで分割するか?
max_dif = std::max(max_dif, b[pos]-s[pos+1]);
}
cout << max_dif << endl;
return 0;
}
| a.cc:10:26: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
10 | : public binary_function<_Ty, _Ty, bool>
| ^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49,
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_function.h:131:12: note: declared here
131 | struct binary_function
| ^~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:28:56: error: template argument 3 is invalid
28 | priority_queue <int, vector<int>, greater<int> > small_que; // 小さい順で取り出す
| ^
a.cc:35:27: error: request for member 'push' in 'small_que', which is of non-class type 'int'
35 | small_que.push(a);
| ^~~~
a.cc:48:27: error: request for member 'push' in 'small_que', which is of non-class type 'int'
48 | small_que.push(a[pos]);
| ^~~~
a.cc:49:35: error: request for member 'top' in 'small_que', which is of non-class type 'int'
49 | int s = small_que.top();
| ^~~
a.cc:50:27: error: request for member 'pop' in 'small_que', which is of non-class type 'int'
50 | small_que.pop();
| ^~~
|
s164977361 | p03716 | C++ | #include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
ll tmp[1005];
ll tmp1[1005];
ll ans_l[1005];
ll ans_r[1005];
void clear(int n,ll tmp[]){
for(int t = 1; t <= 2*n; t++){
tmp[t] = 0;
}
}
void array_copy_right(int A[], ll tmp[], int end, int n){
for(int i = 3*n; i > end; i--){
tmp[3*n-i+1] = A[i];
}
}
void array_copy(ll A[], ll tmp[], int n){
for(int i = 1; i <=n; i++){
tmp[i] = A[i];
}
}
//交换两个数
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}
void heapify(ll nums[], int n, int i)
{
//递归结束条件i比左右孩子都大或者i是叶子结点
int largest = i;
int l = 2 * i; //左孩子
int r = 2 * i + 1; //右孩子
//如果左右孩子有一个比父结点i大,那么就把孩子结点赋给largest
if (l < n && nums[l] > nums[largest])
largest = l;
if (r < n && nums[r] > nums[largest])
largest = r;
//largest不等于i说明左右孩子至少有一个比i大或者i是叶子结点
if (largest != i)
{
swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
heapify(nums, n, largest); //继续向下沉
}
}
//堆排序
void heap_sort(ll nums[], int n)
{
//把原始数组建成一个大顶堆(从最后一个非叶子结点开始堆化操作)
int i;
for (i = n / 2 ; i >= 1; i--)
heapify(nums, n, i);
//把最大得数(堆顶)交换到数组最后,
//再把交换之后的堆顶进行堆化操作,
//然后把堆的大小减1(数组实际大小没变)
for (i = n ; i > 0; i--)
{
swap(&nums[1], &nums[i]);
heapify(nums, i, 1);
}
}
int main(){
/*1-index*/
//int A[]= {0,8,2,2,7,4,6,5,3,8};
//int n = 3;
ll A[1005];
int n;
cin >> n;
for(int i = 1; i <= 3*n; i++){
cin >> A[i];
}
long long max = -10000000000;
for(int i = 0; i <= n; i++){
if(i == 0){
array_copy(A,tmp,n+i);
array_copy_right(A,tmp1,2*n-i,n);
}
else{
tmp[n+i] = A[n+i];
tmp1[n+i] = A[2*n+1-i];
}
heap_sort(tmp,n+i);
heap_sort(tmp1,n+i);
ll left = 0;
ll right = 0;
for(int t = 0; t < n; t++){
left += tmp[n+i-t];
right += tmp1[1+t];
}
ans_l[i+1] = left;
ans_r[n+1-i] = right;
//clear(n,tmp1);
}
for(int i = 0; i <= n+1; i++){
if((ans_l[i] - ans_r[i]) > max ) max = ans_l[i] - ans_r[i];
}
cout << max <<endl;
//heap_sort(A,3*n);
//
}
/*
for(int i = 1; i <= n+1; i++){
array_copy(A, tmp, i+n-1);
heap_sort(tmp, n+i-1);
for(int i = 1; i <= 2*n; i++){
cout << tmp[i] << " ";
}
cout << endl;
int result_left = tmp[n+i-1] + tmp[n+i-2] + tmp[n+i-3];
for(int t = 0; t < 10; t++) tmp1[t] = 0;
array_copy_right(A,tmp1,n-1+i,n);
heap_sort(tmp1,2*n-i+1);
for(int i = 1; i <= 2*n; i++){
cout << tmp1[i] << " ";
}
cout << endl;
int result_right = tmp1[1] + tmp1[2] + tmp1[3];
if(result_left-result_right > max) max = result_left-result_right;
}
cout << max <<endl;
*/ | a.cc: In function 'void heapify(long long int*, int, int)':
a.cc:54:21: error: no matching function for call to 'swap(long long int*, long long int*)'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = long long int*; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match)
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
/usr/include/c++/14/bits/move.h:226:5: note: conversion of argument 2 would be ill-formed:
a.cc:54:32: error: cannot bind non-const lvalue reference of type 'long long int*&' to an rvalue of type 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'long long int*' to 'std::__exception_ptr::exception_ptr&'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
| ^~~~
/usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed:
a.cc:54:21: note: mismatched types '_Tp [_Nm]' and 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
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:
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed:
a.cc:54:21: note: mismatched types 'std::pair<_T1, _T2>' and 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed:
a.cc:54:21: note: mismatched types 'std::pair<_T1, _T2>' and 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed:
a.cc:54:21: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
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:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
| ^~~~
/usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed:
a.cc:54:21: note: mismatched types 'std::tuple<_UTypes ...>' and 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
| ^~~~
/usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed:
a.cc:54:21: note: mismatched types 'std::tuple<_UTypes ...>' and 'long long int*'
54 | swap(&nums[i], &nums[largest]); //交换父结点i和大的那个孩子结点
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:6: note: candidate: 'void swap(int*, int*)'
30 | void swap(int *x, int *y)
| ^~~~
a.cc:30:16: note: no known conversion for argument 1 from 'long long int*' to 'int*'
30 | void swap(int *x, int *y)
| ~~~~~^
a.cc: In function 'void heap_sort(long long int*, int)':
a.cc:72:21: error: no matching function for call to 'swap(long long int*, long long int*)'
72 | swap(&nums[1], &nums[i]);
| ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = long long int*; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match)
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
/usr/include/c++/14/bits/move.h:226:5: note: conversion of argument 2 would be ill-formed:
a.cc:72:32: error: cannot bind non-const lvalue reference of type 'long long int*&' to an rvalue of type 'long long int*'
72 | swap(&nums[1], &nums[i]);
| ^~~~~~~~
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'long long int*' to 'std::__exception_ptr::exception_ptr&'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
| ^~~~
/usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed:
a.cc:72:21: note: mismatched types '_Tp [_Nm]' and 'long long int*'
72 | swap(&nums[1], &nums[i]);
| ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed:
a.cc:72:21: note: mismatched types 'std::pair<_T1, _T2>' and 'long long int*'
72 | swap(&nums[1], &nums[i]);
| ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed:
a.cc:72:21: note: mismatched types 'std::pair<_T1, _T2>' and 'long long int*'
72 | swap(&nums[1], &nums[i]);
| ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed:
a.cc:72:21: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int*'
72 | swap(&nums[1], &nums[i]);
|
s187465790 | p03716 | C++ | #include <bits/stdc++.h>
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define sd(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define sortv(a) sort(a.begin(),a.end())
#define test() int t; cin>>t; while(t--)
#define fi first
#define se second
#define el "\n"
#define ll long long
#define ull unsigned ll
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define TRACE
#ifndef ONLINE_JUDGE
//FILE *fin = freopen("input.txt","r",stdin);
//FILE *fout = freopen("output.txt","w",stdout);
#endif
#ifdef TRACE
#define trace1(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector< PII > VPII;
#define MAXN 100005
ll a[MAXN],lval[MAXN],rval[MAXN];
priority_queue<ll,vector<ll> ,greater<ll> > left;
priority_queue<ll,vector<ll> > right;
int main()
{
int n;
cin>>n;
n = 3*n;
rep(i,n)
cin>>a[i+1];
ll sum = 0;
for(int i = 1;i<=n;i++)
{
if(i<=n/3)
{
sum+=a[i];
left.push(a[i]);
}
else
{
ll top = left.top();
if(top<a[i])
{
left.pop();
left.push(a[i]);
sum+=(a[i]-top);
}
}
lval[i] = sum;
}
sum = 0;
for(int i = n;i>=1;i--)
{
if(i>(2*n)/3)
{
sum+=a[i];
right.push(a[i]);
}
else
{
ll top = right.top();
if(top>a[i])
{
right.pop();
right.push(a[i]);
sum+=(a[i]-top);
}
}
rval[i] = sum;
}
ll ans = LONG_LONG_MIN;
/*rep(i,n+1)
cout<<lval[i]<<" ";
cout<<endl;
rep(i,n+1)
cout<<rval[i]<<" ";
cout<<endl;
*/
for(int i = n/3;i<(2*n)/3;i++)
ans = max(ans,lval[i]-rval[i+1]);
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:73:25: error: reference to 'left' is ambiguous
73 | left.push(a[i]);
| ^~~~
In file included from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:57:45: note: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> > left'
57 | priority_queue<ll,vector<ll> ,greater<ll> > left;
| ^~~~
a.cc:77:34: error: reference to 'left' is ambiguous
77 | ll top = left.top();
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:57:45: note: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> > left'
57 | priority_queue<ll,vector<ll> ,greater<ll> > left;
| ^~~~
a.cc:80:33: error: reference to 'left' is ambiguous
80 | left.pop();
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:57:45: note: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> > left'
57 | priority_queue<ll,vector<ll> ,greater<ll> > left;
| ^~~~
a.cc:81:33: error: reference to 'left' is ambiguous
81 | left.push(a[i]);
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:57:45: note: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> > left'
57 | priority_queue<ll,vector<ll> ,greater<ll> > left;
| ^~~~
a.cc:93:25: error: reference to 'right' is ambiguous
93 | right.push(a[i]);
| ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
1070 | right(ios_base& __base)
| ^~~~~
a.cc:58:32: note: 'std::priority_queue<long long int, std::vector<long long int> > right'
58 | priority_queue<ll,vector<ll> > right;
| ^~~~~
a.cc:97:34: error: reference to 'right' is ambiguous
97 | ll top = right.top();
| ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
1070 | right(ios_base& __base)
| ^~~~~
a.cc:58:32: note: 'std::priority_queue<long long int, std::vector<long long int> > right'
58 | priority_queue<ll,vector<ll> > right;
| ^~~~~
a.cc:100:33: error: reference to 'right' is ambiguous
100 | right.pop();
| ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
1070 | right(ios_base& __base)
| ^~~~~
a.cc:58:32: note: 'std::priority_queue<long long int, std::vector<long long int> > right'
58 | priority_queue<ll,vector<ll> > right;
| ^~~~~
a.cc:101:33: error: reference to 'right' is ambiguous
101 | right.push(a[i]);
| ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
1070 | right(ios_base& __base)
| ^~~~~
a.cc:58:32: note: 'std::priority_queue<long long int, std::vector<long long int> > right'
58 | priority_queue<ll,vector<ll> > right;
| ^~~~~
|
s258003041 | p03716 | C++ | #include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)
#define inf INT_MAX/3
#define INF INT_MAX/3
#define llinf LLONG_MAX/3
#define LLINF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PLL pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VLL vector<long long>
#define VULL vector<unsigned long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SCD second
using namespace std;
const LL ANS_MAX = 1000000007;
struct Greater
{
bool operator()(const LL& a, const LL& b)
{
return a > b;
}
};
static bool greater(const LL& a, const LL& b)
{
return a > b;
}
// ARC074C
int main()
{
LL ret = - LLINF;
LL N;
cin >> N;
VLL a(3 * N);
for (size_t i = 0; i < 3 * N; i++) {
cin >> a[i];
}
VLL sum0, sum1;
//priority_queue<LL, vector<LL>, Greater> a0;
//priority_queue<LL> a1;
//for (size_t i = 0; i < N; i++) {
// a0.push(a[i]);
//}
//for (size_t i = N; i < 3 * N; i++) {
// a1.push(a[i]);
//}
//LL t = a0.top();
//LL s = a1.top();
//make_heap(a0.begin(), a0.end(), greater);
//pop_heap(a0.begin(), a0.end(), greater);
//push_heap(a0.begin(), a0.end(), greater);
for (size_t j = 0; j < N; j++) {
VLL a0(N + j);
for (size_t i = 0; i < N + j; i++) {
a0[i] = a[i];
}
sort(a0.begin(), a0.end(), greater);
VLL a1(N + N - j);
for (size_t i = 0; i < N + N - j; i++) {
a1[i] = a[N + j + i];
}
sort(a1.begin(), a1.end());
LL sum0 = 0;
for (size_t i = 0; i < N; i++) {
sum0 += a0[i];
}
LL sum1 = 0;
for (size_t i = 0; i < N; i++) {
sum1 += a1[i];
}
ret = MAX(ret, sum0 - sum1);
}
cout << ret << endl;
#if _DEBUG
cin >> ret;
#endif
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:15: error: 'LLONG_MAX' was not declared in this scope
25 | #define LLINF LLONG_MAX/3
| ^~~~~~~~~
a.cc:79:20: note: in expansion of macro 'LLINF'
79 | LL ret = - LLINF;
| ^~~~~
a.cc:15:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
14 | #include <iterator>
+++ |+#include <climits>
15 | #include <sstream>
a.cc:111:44: error: reference to 'greater' is ambiguous
111 | sort(a0.begin(), a0.end(), greater);
| ^~~~~~~
In file included from /usr/include/c++/14/bits/refwrap.h:39,
from /usr/include/c++/14/vector:68,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:353:12: note: candidates are: 'template<class _Tp> struct std::greater'
353 | struct greater;
| ^~~~~~~
a.cc:70:13: note: 'bool greater(const long long int&, const long long int&)'
70 | static bool greater(const LL& a, const LL& b)
| ^~~~~~~
|
s823056071 | p03716 | C++ | #include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
ll num[300001],l[300001],r[300001],ans=LLONG_MIN;
priority_queue<int,vector<int>,greater<int>/**/> le;
priority_queue<ll> ri;
int n,i,j;
int main()
{
cin>>n;
for (i=1;i<=n;i++)
{
cin>>num[i];
l[n]+=num[i];
le.push(num[i]);
}
for (i=n+1;i<=n*2;i++)
{
cin>>num[i];
}
for (i=n*2+1;i<=n*3;i++)
{
cin>>num[i];
r[2*n+1]+=num[i];
ri.push(num[i]);
}
for (i=n+1;i<=n*2;i++)
{
if (le.top()<num[i])
{
l[i]=l[i-1]+num[i]-le.top();
le.push(num[i]);
le.pop();
}
else
{
l[i]=l[i-1];
}
}
for (i=2*n;i>n;i--)
{
if (ri.top()>num[i])
{
r[i]=r[i+1]+num[i]-ri.top();
ri.push(num[i]);
ri.pop();
}
else
{
r[i]=r[i+1];
}
}
for (i=n;i<=2*n;i++)
{
if (ans<l[i]-r[i+1]) ans=l[i]-r[i+1];
}
cout<<ans<<endl;
return 0;
} | a.cc:23:40: error: 'LLONG_MIN' was not declared in this scope
23 | ll num[300001],l[300001],r[300001],ans=LLONG_MIN;
| ^~~~~~~~~
a.cc:20:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
19 | #include<iomanip>
+++ |+#include <climits>
20 | #define sqr(x) (x)*(x)
|
s051840088 | p03716 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[M];
struct cmp1
{
int x;
cmp1(int x):x(x) {}
bool operator < (const cmp1 &a) const
{
return x > a.x;
}
};
struct cmp2
{
int x;
cmp2(int x):x(x) {}
bool operator < (const cmp2 &a) const
{
return x < a.x;
}
};
ll dpf[1000001] , dpe[1000001];
int main()
{
int n;
cin>>n;
for(int i = 1 ; i <= 3 * n ; i++)
{
cin>>a[i];
}
priority_queue<cmp1> st;
memset(dpf , 0 , sizeof(dpf));
memset(dpe , 0 , sizeof(dpe));
for(int i = 1 ; i <= n ; i++)
{
st.push(cmp1(a[i]));
dpf[n] += (ll)a[i];
}
for(int i = n + 1 ; i <= 2 * n ; i++)
{
int gg = st.top().x;
if(gg < a[i])
{
st.pop();
st.push(cmp1(a[i]));
dpf[i] = dpf[i - 1] - (ll)gg + (ll)a[i];
}
else dpf[i] = dpf[i - 1];
}
priority_queue<cmp2> ed;
for(int i = 2 * n + 1 ; i <= 3 * n ; i++)
{
ed.push(cmp2(a[i]));
dpe[2 * n + 1] += (ll)a[i];
}
for(int i = 2 * n ; i >= n ; i--)
{
int gg = ed.top().x;
if(gg > a[i])
{
ed.pop();
ed.push(cmp2(a[i]));
dpe[i] = dpe[i + 1] - (ll)gg + (ll)a[i];
}
else dpe[i] = dpe[i + 1];
}
ll ans =LONG_LONG_MIN;
for(int i = n ; i <= 2 * n ; i++)
{
ans = max(ans , dpf[i] - dpe[i + 1]);
}
cout<<ans;
}
| a.cc:4:7: error: 'M' was not declared in this scope
4 | int a[M];
| ^
a.cc: In function 'int main()':
a.cc:30:14: error: 'a' was not declared in this scope
30 | cin>>a[i];
| ^
a.cc:37:22: error: 'a' was not declared in this scope
37 | st.push(cmp1(a[i]));
| ^
a.cc:43:17: error: 'a' was not declared in this scope
43 | if(gg < a[i])
| ^
a.cc:54:22: error: 'a' was not declared in this scope
54 | ed.push(cmp2(a[i]));
| ^
a.cc:60:17: error: 'a' was not declared in this scope
60 | if(gg > a[i])
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.