submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s745022903
p03713
C
#include <stdio.h> #include<math.h> int main() { int i,H,h,W,w,s,sa,sb,sc,max=0; long int smin,min,t; scanf("%d %d",&H,&W); smin = H*W; min =H*W; for(i=1;i<H;i++){sa = i*W; max=sa; min=sa; w = W/2; sb = w *(H-i); sc = (H-i)*(W-w); if(max<=sb){max=sb;} if(max<=sc){max=sc;} if(min>=sb){min = sb;} if(min>=sc){min = sc;} t = max -min; if(t<=smin){smin =t;} h = (H-i)/2; sb = h *W; sc = W*(H-h); if(max<=sb){max=sb;} if(max<=sc){max=sc;} if(min>=sb){min = sb;} if(min>=sc){min = sc;} t = max -min; if(t<=smin){smin =t;} } for(i=1;i<W;i++){sa = i*H; h = H/2; sb = h *(W-i); sc = (H-h)*(W-i); if(max<=sb){max=sb;} if(max<=sc){max=sc;} if(min>=sb){min = sb;} if(min>=sc){min = sc;} t = max -min; if(t<=smin){smin =t;} w = (W-i)/2; sb = w *H; sc = (W-w)*H; if(max<=sb){max=sb;} if(max<=sc){max=sc;} if(min>=sb){min = sb;} if(min>=sc){min = sc;} t = max -min; if(t<=smin){smin =t;} } printf("%d\n",smin); return 0; }
main.c: In function 'main': main.c:7:16: error: stray '\343' in program 7 | smin = H*W;<U+3000>min =H*W; | ^~~~~~~~
s536338130
p03713
C++
#include <stdio.h> #include<math.h> int abs(int); int main() { int i,H,W,sa,sb,sc,min=0,t; scanf("%d %d",&H,&W); for(i=1;i<H;i++){sa = i*W; sb = W/2 *(H-i); sc = W*H - sa-sb; t = abs(sa-sb); if(abs(sb-sc)<t){t=abs(sb-sc);} if(abs(sc-sa)<t){t=abs(sc-sa);} if(min>=t){min = t;} sb = (H-i)/2 *W; sc = W*H - sa-sb; t = abs(sa-sb); if(abs(sb-sc)<t){t=abs(sb-sc);} if(abs(sc-sa)<t){t=abs(sc-sa);} if(min>=t){min = t;} } for(i=1;i<W;i++){sa = i*H; sb = H/2 *(W-i); sc = W*H - sa-sb; t = abs(sa-sb); if(abs(sb-sc)<t){t=abs(sb-sc);} if(abs(sc-sa)<t){t=abs(sc-sa);} if(min>=t){min = t;} sb = (W-i)/2 *H; sc = W*H - sa-sb; t = abs(sa-sb); if(abs(sb-sc)<t){t=abs(sb-sc);} if(abs(sc-sa)<t){t=abs(sc-sa);} if(min>=t){min = t;} } printf("%d\n",min); return 0;
a.cc: In function 'int main()': a.cc:40:14: error: expected '}' at end of input 40 | return 0; | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s866156226
p03713
C++
#include <iostream> #include <cmath> using namespace std; typedef long long ll; #define INF 999999999 int main(){ ll H,W; cin >> H >> W; ll rec1, rec2, rec3; ll temp1 = INF; ll temp2 = INF; ll cand; for(int i=1;i<W-1;i++){ rec1 = H*i; rec2 = (W-i)*floor(H/2); rec3 = (W-i)*(H-floor(H/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp1 = min(cand, temp1); rec2 = H*(floor((W-i)/2)); rec3 = H*((W-i)-floor((W-i)/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp2 = min(cand, temp2); } ll temp3 = INF; ll temp4 = INF; for(int i=1;i<H-1;i++){ rec1 = W*i; rec2 = (H-i)*floor(W/2); rec3 = (H-i)*(W-floor(W/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp3 = min(cand, temp3); rec2 = W*(floor((H-i)/2)); rec3 = W*((H-i)-floor((H-i)/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp4 = min(cand, temp4); } cout << min({temp1,temp2,temp3,temp4}) << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:19: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 21 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:21:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 21 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided a.cc:26:19: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 26 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:26:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 26 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided a.cc:36:19: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 36 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:36:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 36 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided a.cc:41:19: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 41 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:41:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 41 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided a.cc:45:16: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 45 | cout << min({temp1,temp2,temp3,temp4}) << endl; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided
s387733174
p03713
C++
#include <iostream> #include <cmath> using namespace std; typedef long long ll; #define INF 999999999 int main(){ ll H,W; cin >> H >> W; ll rec1, rec2, rec3; ll temp1 = INF; ll temp2 = INF; ll cand; for(int i=1;i<W-1;i++){ rec1 = H*i; rec2 = (W-i)*floor(H/2); rec3 = (W-i)*(H-floor(H/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp1 = min(cand, temp1); rec2 = H*(floor((W-i)/2)); rec3 = H*((W-i)-floor((W-i)/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp2 = min(cand, temp2); } ll temp3 = INF; ll temp4 = INF; for(int i=1;i<H-1;i++){ rec1 = W*i; rec2 = (H-i)*floor(W/2); rec3 = (H-i)*(W-floor(W/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp3 = min(cand, temp3); rec2 = W*(floor((H-i)/2)); rec3 = W*((H-i)-floor((H-i)/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp4 = min(cand, temp4); } cout << min({temp1,temp2,temp3,temp4}) << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:19: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 21 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:21:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 21 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided a.cc:26:19: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 26 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:26:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 26 | cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided a.cc:34:427: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 34 | rec2 = (H-i)*floor(W/2); rec3 = (H-i)*(W-floor(W/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp3 = min(cand, temp3); rec2 = W*(floor((H-i)/2)); rec3 = W*((H-i)-floor((H-i)/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp4 = min(cand, temp4); } cout << min({temp1,temp2,temp3,temp4}) << endl; return 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: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided a.cc:34:451: error: no matching function for call to 'min(<brace-enclosed initializer list>)' 34 | rec2 = (H-i)*floor(W/2); rec3 = (H-i)*(W-floor(W/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp3 = min(cand, temp3); rec2 = W*(floor((H-i)/2)); rec3 = W*((H-i)-floor((H-i)/2)); cand = max({rec1,rec2,rec3}) - min({rec1,rec2,rec3}); temp4 = min(cand, temp4); } cout << min({temp1,temp2,temp3,temp4}) << endl;
s511202625
p03713
Java
import java.util.*; public class Main { private int[] trarray = new int[3]; private int minDiv; public static void main(String []args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int n = sc.nextInt(); Main soln = new Main(); soln.minDiv = m*n; int[] temp = new int[3]; for(int i=1; i<=m/2; i++) { temp[0] = i*n; soln.digR(temp, m-i, n); soln.digC(temp, m-i, n); } for(int i=1; i<=n/2; i++) { temp[0] = i*m; soln.digR(temp, m, n-i); soln.digC(temp, m, n-i); } System.out.println(soln.minDiv); } private void digR(int[] temp, int m, int n) { int div; int j = m/2; temp[1] = j*n; temp[2] = (m-j)*n; this.trarray = Arrays.copyOf(temp, temp.length); Arrays.sort(this.trarray); div = this.trarray[2] - this.trarray[0]; this.minDiv = (div<this.minDiv)? div:minDiv; } private void digC(int[] temp, int m, int n) { int div; int j = n/2 temp[1] = j*m; temp[2] = (n-j)*m; this.trarray = Arrays.copyOf(temp, temp.length); Arrays.sort(this.trarray); div = this.trarray[2] - this.trarray[0]; this.minDiv = (div<this.minDiv)? div:minDiv; } }
Main.java:41: error: ';' expected int j = n/2 ^ 1 error
s483743979
p03713
C++
#include <iostream> #include <algorithm> #define ll long long int using namespace std; ll H,W; ll maxfun(int a, int b , int c){ ll result; a>b? (result = a):(result =b); (result >c)? (result):(result = c); return result; } ll minfun(int a, int b , int c){ ll result; a<b? (result = a):(result =b); result <c? (result):(result = c); return result; } int main(){ ll s1,s2,s3; ll result=100000; ll min, max; cin >> H >> W; if((H%3)*(W%3)==0){ cout << "0" << endl; return 0; } else{ result = std::min(H,W); } for(int i =H/3; i< H/2+1;i++){ for(int j = W/3; j< W/2+1; j++){ s1 = i*W; s2 = j*(H-i); s3 = (H-i)*(W-j); min = minfun(s1,s2,s3); max = maxfun(s1,s2,s3); if(result> (max-min)) result = max-min;
a.cc: In function 'int main()': a.cc:41:46: error: expected '}' at end of input 41 | if(result> (max-min)) result = max-min; | ^ a.cc:35:36: note: to match this '{' 35 | for(int j = W/3; j< W/2+1; j++){ | ^ a.cc:41:46: error: expected '}' at end of input 41 | if(result> (max-min)) result = max-min; | ^ a.cc:34:32: note: to match this '{' 34 | for(int i =H/3; i< H/2+1;i++){ | ^ a.cc:41:46: error: expected '}' at end of input 41 | if(result> (max-min)) result = max-min; | ^ a.cc:20:11: note: to match this '{' 20 | int main(){ | ^
s775292251
p03713
C
#include<stdio.h> int main(void) { int h, w; //0:height,1:width scanf("%d%d", &h, &w); switch ((h % 6)*(w * 3 + 7)) { case 0: //h%3 == 0 || w%3 == 0 case 7: case 14: case 16: case 21: case 28: case 30: case 32: case 35: case 39: case 48: case 57: case 64: case 66: case 80: printf("0"); break; case 13: //w%2 == 0 || h%2 != 0 case 19: case 65: case 95: printf("%d", w / 2); break; case 20: //w%2 != 0 && h%2 == 0 case 40: case 44: case 88: printf("%d", h / 2); break; case 26: //w%2 == 0 && h%2 == 0 case 38: case 52: case 76: printf("%d", min(h, w) / 2); break; case 10: case 22: case 50: case 110: if (h > w) printf("%d", max(w + h / 3 + h % 3 - 1, (h / 3) * 2 + 1)); else printf("%d", max(h + w / 3 + w % 3 - 1, (w / 3) * 2 + 1)); break; default: break; } return 0; }
main.c: In function 'main': main.c:40:30: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration] 40 | printf("%d", min(h, w) / 2); | ^~~ | main main.c:46:41: error: implicit declaration of function 'max' [-Wimplicit-function-declaration] 46 | if (h > w) printf("%d", max(w + h / 3 + h % 3 - 1, (h / 3) * 2 + 1)); | ^~~
s839987791
p03713
C++
#include <iostream> #include <complex> #include <limits> int solution1(int h, int w) { int firstLine = h / 3, secondLine = (h + firstLine) / 2; int s1 = firstLine * w, s2 = (secondLine - firstLine) * w, s3 = (h - secondLine) * w; int max = 0; if (abs(s1 - s2) > max) max = abs(s1 - s2); if (abs(s2 - s3) > max) max = abs(s2 - s3); if (abs(s1 - s3) > max) max = abs(s1 - s3); return max; } int solution2(int h, int w) { int horizontalLine; if (h % 3 == 2) horizontalLine = (h / 3) + 1; else horizontalLine = h / 3; int s1 = horizontalLine * w; int verticalLine = w / 2; int s3, max = 0; int s2 = (w - verticalLine) * (h - horizontalLine); if (w * 2 == verticalLine) s3 = (w - verticalLine) * (h - horizontalLine); else { s3 = (w - (w - verticalLine)) * (h - horizontalLine); } if (abs(s1 - s2) > max) max = abs(s1 - s2); if (abs(s2 - s3) > max) max = abs(s2 - s3); if (abs(s1 - s3) > max) max = abs(s1 - s3); return max; } int main() { int h, w; std::cin >> h >> w; int max = INT_MAX; if (!solution1(h, w)) { std::cout << 0; return 0; } else if (solution1(h, w) < max) max = (solution1(h, w)); if (!solution1(w, h)) { std::cout << 0; return 0; } else if (solution1(w, h) < max) max = (solution1(w, h)); if (!solution2(h, w)) { std::cout << 0; return 0; } else if (solution2(h, w) < max) max = (solution2(h, w)); if (!solution2(w, h)) { std::cout << 0; return 0; } else if (solution2(w, h) < max) max = (solution2(w, h)); std::cout << max; }
a.cc: In function 'int main()': a.cc:66:19: error: 'INT_MAX' was not declared in this scope 66 | int max = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <complex> +++ |+#include <climits> 3 | #include <limits>
s479962932
p03713
C++
#include <iostream> #include <complex> int solution1(int h, int w) { int firstLine = h / 3, secondLine = (h + firstLine) / 2; int s1 = firstLine * w, s2 = (secondLine - firstLine) * w, s3 = (h - secondLine) * w; int max = 0; if (abs(s1 - s2) > max) max = abs(s1 - s2); if (abs(s2 - s3) > max) max = abs(s2 - s3); if (abs(s1 - s3) > max) max = abs(s1 - s3); return max; } int solution2(int h, int w) { int horizontalLine; if (h % 3 == 2) horizontalLine = (h / 3) + 1; else horizontalLine = h / 3; int s1 = horizontalLine * w; int verticalLine = w / 2; int s3, max = 0; int s2 = (w - verticalLine) * (h - horizontalLine); if (w * 2 == verticalLine) s3 = (w - verticalLine) * (h - horizontalLine); else { s3 = (w - (w - verticalLine)) * (h - horizontalLine); } if (abs(s1 - s2) > max) max = abs(s1 - s2); if (abs(s2 - s3) > max) max = abs(s2 - s3); if (abs(s1 - s3) > max) max = abs(s1 - s3); return max; } int main() { int h, w; std::cin >> h >> w; int max = INT_MAX; if (!solution1(h, w)) { std::cout << 0; return 0; } else if (solution1(h, w) < max) max = (solution1(h, w)); if (!solution1(w, h)) { std::cout << 0; return 0; } else if (solution1(w, h) < max) max = (solution1(w, h)); if (!solution2(h, w)) { std::cout << 0; return 0; } else if (solution2(h, w) < max) max = (solution2(h, w)); if (!solution2(w, h)) { std::cout << 0; return 0; } else if (solution2(w, h) < max) max = (solution2(w, h)); std::cout << max; }
a.cc: In function 'int main()': a.cc:65:19: error: 'INT_MAX' was not declared in this scope 65 | int max = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <complex> +++ |+#include <climits> 3 |
s039899339
p03713
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); long h = cin.nextLong(); long w = cin.nextLong(); long ans = Math.min(func1(h, w), func2(h, w)); ans = Math.min(ans, func2(w, h)); System.out.println(ans); } long func1(long h, long w){ if(h % 3 == 0 || w % 3 == 0){ return 0; } return Math.min(h, w); } long func2(long h, long w){ long min_dif = h * w; if(w % 2 == 0) { for (long i = 1; i < h; ++i ) { min_dif = Math.min(Math.abs(w * i - w / 2 * (h - i)), min_dif ) } } else { for (long i = 1; i < h; ++i ) { long max_dif = Math.max(Math.abs( (w+1) / 2 * (h - i) - w / 2 * (h - i)) , Math.max(Math.abs(w * i - w / 2 * (h - i)), Math.abs(w * i - (w+1) / 2 * (h - i)))); min_dif = Math.min(max_dif, min_dif); } } return min_dif; } }
Main.java:24: error: ';' expected min_dif = Math.min(Math.abs(w * i - w / 2 * (h - i)), min_dif ) ^ 1 error
s693331550
p03713
C++
#include <iostream> #include <algorithm> using namespace std; int func1(int h, int w){ if(h % 3 == 0|| w % 3 == 0){ return 0; } return min(h, w); } int func2(int h, int w){ int min_dif = h * w; if(w % 2 == 0){ for (int i = 1; i < h; ++i) { min_dif = min(abs(w * i - w / 2 * (h - i)), min_dif); } }else{ for (int i = 1; i < h; ++i) { int max_dif = max(abs( (w+1) / 2 * (h - i) - w / 2 * (h - i)) , max(abs(w * i - w / 2 * (h - i)), abs(w * i - (w+1) / 2 * (h - i)))); min_dif = min(max_dif, min_dif); } } return min(min_dif, func2(w, h)); } int main(){ cin >> h >> w; cout << min(func1(h, w), func2(h, w) ) << endl; }
a.cc: In function 'int main()': a.cc:32:16: error: 'h' was not declared in this scope 32 | cin >> h >> w; | ^ a.cc:32:21: error: 'w' was not declared in this scope 32 | cin >> h >> w; | ^
s106153652
p03713
C++
#include<iostream> #include<string> #include<vector> #include<stdio.h> #include<sstream> #include<list> #include <algorithm> using namespace std; #define INT32_MAX 2147483647 #define ul unsigned long long ul choco(ul w, ul h) { ul dmin1; if (w % 3 == 0) { dmin1 = 0; } else { dmin1 = INT32_MAX; double half = (double)h / 2; ul h2 = (ul)floor(half); ul h3 = (ul)ceil(half); for (ul i = 1; i < w; i++) { initializer_list<ul> s = { i*h, (w - i)*h2, (w - i)*h3 }; ul c = max(s) - min(s); if (c < dmin1) { dmin1 = c; } } } return dmin1; } int main() { ul h, w; cin >> h >> w; ul dmin1 = choco(w, h); ul dmin2 = choco(h, w); ul res = dmin1 < dmin2 ? dmin1 : dmin2; cout << res << endl; return 0; }
a.cc: In function 'long long unsigned int choco(long long unsigned int, long long unsigned int)': a.cc:23:29: error: 'floor' was not declared in this scope 23 | ul h2 = (ul)floor(half); | ^~~~~ a.cc:24:29: error: 'ceil' was not declared in this scope 24 | ul h3 = (ul)ceil(half); | ^~~~
s261727860
p03713
C++
#include<iostream> #include<string> #include<vector> #include<stdio.h> #include<sstream> #include<list> #include <algorithm> using namespace std; #define ul unsigned long long ul choco(ul w, ul h) { ul dmin1; if (w % 3 == 0) { dmin1 = 0; } else { dmin1 = INT_MAX; double half = (double)h / 2; ul h2 = (ul)floor(half); ul h3 = (ul)ceil(half); for (ul i = 1; i < w; i++) { initializer_list<ul> s = { i*h, (w - i)*h2, (w - i)*h3 }; ul c = max(s) - min(s); if (c < dmin1) { dmin1 = c; } } } return dmin1; } int main() { ul h, w; cin >> h >> w; ul dmin1 = choco(w, h); ul dmin2 = choco(h, w); ul res = dmin1 < dmin2 ? dmin1 : dmin2; cout << res << endl; return 0; }
a.cc: In function 'long long unsigned int choco(long long unsigned int, long long unsigned int)': a.cc:20:25: error: 'INT_MAX' was not declared in this scope 20 | dmin1 = INT_MAX; | ^~~~~~~ a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include <algorithm> +++ |+#include <climits> 9 | using namespace std; a.cc:22:29: error: 'floor' was not declared in this scope 22 | ul h2 = (ul)floor(half); | ^~~~~ a.cc:23:29: error: 'ceil' was not declared in this scope 23 | ul h3 = (ul)ceil(half); | ^~~~
s365623802
p03713
C
a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);}
main.c:1:1: warning: data definition has no type or storage class 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] main.c:1:3: error: return type defaults to 'int' [-Wimplicit-int] 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^ main.c: In function 'f': main.c:1:3: error: type of 'H' defaults to 'int' [-Wimplicit-int] main.c:1:3: error: type of 'W' defaults to 'int' [-Wimplicit-int] main.c:1:44: error: expected expression before '?' token 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^ main.c: At top level: main.c:1:98: error: return type defaults to 'int' [-Wimplicit-int] 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^~~~ main.c: In function 'main': main.c:1:98: error: type of 'H' defaults to 'int' [-Wimplicit-int] main.c:1:98: error: type of 'W' defaults to 'int' [-Wimplicit-int] main.c:1:108: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} main.c:1:108: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^~~~~ main.c:1:108: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:128: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^~~~~~ main.c:1:128: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:128: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:128: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:152: error: expected expression before '?' token 1 | a;f(H,W){for(long long i=H,x,y,z,t;i--;a=t<?a)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=x>z?x-y:x<y?z-x:i;}main(H,W){scanf("%d%d",&H,&W);printf("%d\n",H*W%3?a=H<?W,f(H,W),f(W,H),a:0);} | ^
s452797601
p03713
C++
#include <iostream> #include <algorithm> #include <vector> #include <cstdio> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include <functional> #include <numeric> #include <iomanip> #define fi first #define se second #define fcout(n) cout<<fixed<<setprecision((n)) #define cinl(str) getline(cin,(str)) using namespace std; bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;} typedef pair<int,int> pii; typedef long long ll; typedef vector<int> vi; typedef vector<long long > vll; typedef vector< vi > vvi; double pie=acos(-1); int INF=1000000007; int dx[4] = { 0,-1,0,1 }; int dy[4] = { -1,0,1,0 }; int main() { long long H,W; long long s1,s2,s3,ans,sc; ans=10000000; cin>>H>>W; for(long long i=1;i<H;i++){ s1 = W*i; s2 = (H-i)*(W/2); s3 = (H-i)*(W-(W/2)); sc = max(abs(s1-s2),abs(s2-s3)); sc = max(,abs(s1-s3)); ans = min(sc,ans); } for(long long i=1;i<H;i++){ s1 = W*i; s2 = ((H-i)/2)*W; s3 = (H-i-((H-i)/2))*W; sc = max(abs(s1-s2),abs(s2-s3)); sc = max(sc,abs(s1-s3)); ans = min(sc,ans); } for(long long i=1;i<W;i++){ s1 = H*i; s2 = (W-i)*(H/2); s3 = (W-i)*(H-(H/2)); sc = max(abs(s1-s2),abs(s2-s3)); sc = max(sc,abs(s1-s3)); ans = min(sc,ans); } for(long long i=1;i<H;i++){ s1 = H*i; s2 = ((W-i)/2)*H; s3 = (W- i -((W-i)/2))*H; sc = max(abs(s1-s2),abs(s2-s3)); sc = max(sc,abs(s1-s3)); ans = min(sc,ans); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:41:26: error: expected primary-expression before ',' token 41 | sc = max(,abs(s1-s3)); | ^
s018491320
p03713
C++
#include <iostream> #include <stdlib.h> #include <string> using namespace std; long long cal_mem(long long H, long long W){ long long ans_1, ans_2, ans_3; long long tmp_a, tmp_b, tmp_c; tmp_a = (H / 3) * W; tmp_b = (H - (H/3)) * (W / 2)); tmp_c = H * W - (tmp_a + tmp_b); ans_1 = max(max(tmp_a, tmp_b), tmp_c) - min(min(tmp_a, tmp_b), tmp_c); tmp_a = (H / 3 + 1) * W; tmp_b = (H - (H/3 + 1)) * (W / 2); tmp_c = H * W - (tmp_a + tmp_b); ans_2 = max(max(tmp_a, tmp_b), tmp_c) - min(min(tmp_a, tmp_b), tmp_c); ans_3 = W; return min(min(ans_1, ans_2), ans_3); } int main(void){ long long H, W; long long s_max, s_mid, s_min; long long ans_h=0; long long ans_w=0; cin >> H >> W; if(H % 3 == 0 || W % 3 == 0){ cout << 0 << endl; return 0; } else{ ans_h = cal_mem(H, W); ans_w = cal_mem(W, H); cout << min(ans_h, ans_w) << endl; return 0; } }
a.cc: In function 'long long int cal_mem(long long int, long long int)': a.cc:13:34: error: expected ';' before ')' token 13 | tmp_b = (H - (H/3)) * (W / 2)); | ^ | ;
s404336099
p03713
C++
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { int h, w; cin >> h >> w; if (h % 3 == 0 || w % 3 == 0)cout << 0 << endl; else if (h % 2 == 0 && w % 2 == 0)cout << min(h, w) / 2 << endl; else if (h % 2 == 0)cout << h / 2 << endl; else if (w % 2 == 0)cout << w / 2 << endl; else cout << (h - 1) / 2 + (w - 1) / 2 < endl; }
a.cc: In function 'int main()': a.cc:11:48: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:11:50: note: couldn't deduce template parameter '_CharT' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3901 | operator<(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed: a.cc:11:50: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2600 | operator<(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed: a.cc:11:50: note: 'std::basic_ostream<char>' is not derived from 'const std::tuple<_UTypes ...>' 11 | else cout << (h - 1) / 2 + (w - 1) / 2 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/ios_base.h:46: /usr/include/c++/14/system_error:324:3: note: candidate: 'bool std::operator<(const error_code&, const error_code&)' 324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ^~~~~~~~ /usr/include/c++/14/system_error:324:31: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'const std::error_code&' 324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/system_error:507:3: note: candidate: 'bool std::operator<(const error_condition&, const error_condition&)' 507 | operator<(const error_condition& __lhs, | ^~~~~~~~ /usr/include/c++/14/system_error:507:36: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'const std::error_condition&' 507 | operator<(const error_condition& __lhs, | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
s945978698
p03713
Java
import java.util.Scanner; /* * 問題文 * 縦 H ブロック、横 W ブロックの板チョコがあります。 * すぬけ君は、この板チョコをちょうど 3 つのピースに分割しようとしています。 * ただし、各ピースはブロックの境目に沿った長方形でなければなりません。 * すぬけ君は、3 つのピースの面積 (ブロック数) をできるだけ均等にしようとしています。 * 具体的には、3 つのピースの面積の最大値を Smax、最小値を Smin としたとき、Smax−Smin を最小化しようとしています。 * Smax−Smin の最小値を求めてください。 * * 入力は以下の形式で標準入力から与えられる。 * H W */ public class ChocolateBar { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); System.out.println(getMin(rowSplit(h, w), colSplit(h, w), aSplit(h, w), bSplit(h, w))); } private static int getMin(int x, int y, int z) { if(x <= y && x <= z) { return z; } else if(y <= x && y <= z) { return y; } else { return z; } } private static int getMin(int x, int y, int z, int a) { if(x <= y && x <= z && x <= a) { return z; } else if(y <= x && y <= z && y <= a) { return y; } else if (z <= x && z <= y&& z <= a){ return z; } else { return a; } } private static int getMax(int x, int y, int z) { if(x >= y && x >= z) { return z; } else if(y >= x && y >= z) { return y; } else { return z; } } private static int colSplit(int h, int w) { int w1 = w / 3; int w2 = w / 3; int w3 = w / 3; if(w % 3 == 1) { w1 += 1; } else if(w % 3 == 2) { w1 += 1; w2 += 1; } return getMax(w1*h, w2*h, w3*h) - getMin(w1*h, w2*h, w3*h); } private static int rowSplit(int h, int w) { int h1 = w / 3; int h2 = w / 3; int h3 = w / 3; if(h % 3 == 1) { h1 += 1; } else if(h % 3 == 2) { h1 += 1; h2 += 1; } return getMax(h1*w, h2*w, h3*w) - getMin(h1*w, h2*w, h3*w); } private static int aSplit(int h, int w) { int h1 = h / 2; int h2 = h / 2; int w1 = w / 2; int w2 = w / 2; int ansA = h+w; if(h % 2 == 1) { h1 += 1; } if(w % 2 == 1) { w1 += 1; } while(true) { int a = h1 * w1; int b = h1 * w2; int c = h2 * w; if(getMax(a, b, c) - getMin(a, b, c) <= ansA) { ansA = getMax(a, b, c) - getMin(a, b, c); } h1 += 1; h2 -= 1; if(h2 < 1) { break; } } return ansA; } private static int bSplit(int h, int w) { int h1 = h / 2; int h2 = h / 2; int w1 = w / 2; int w2 = w / 2; int ansB = h+w; if(w % 2 == 1) { w1 += 1; } if(h % 2 == 1) { h1 += 1; } while(true) { int a = w1 * h1; int b = w1 * h2; int c = w2 * h; if(getMax(a, b, c) - getMin(a, b, c) <= ansB) { ansB = getMax(a, b, c) - getMin(a, b, c); } h1 += 1; h2 -= 1; if(h2 < 1) { break; } } return ansB; } }
Main.java:16: error: class ChocolateBar is public, should be declared in a file named ChocolateBar.java public class ChocolateBar { ^ 1 error
s669433956
p03713
C++
#include <iostream> #include <algorithm> using namespace std; int calc(int a, int b, int c) { int x = max(a, b, c); int y = min(a, b, c); return abs(x - y); } int main(void) { int H, W; cin >> H >> W; int min = 999999999; int S1, S2, S3, ans; for (int j = 0; j < 2; ++j) { for (int i = 1; i < H; ++i) { S1 = i * W; if ((H - i) % 2 == 0) { S2 = (H - i) / 2 * W; ans = calc(S1, S2, S2); } else { S2 = (H - i) / 2 * W; S3 = ((H - i) / 2 + 1) * W; ans = calc(S1, S2, S3); } if (min > ans) min = ans; if (W % 2 == 0) { S2 = (H - i) * W / 2; ans = calc(S1, S2, S2); } else { S2 = (H - i) * W / 2; S3 = (H - i) * (W / 2 + 1); ans = calc(S1, S2, S3); } if (min > ans) min = ans; } int tmp = H; H = W; W = tmp; } cout << min << endl; return 0; }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]': a.cc:7:13: required from here 7 | int x = max(a, b, c); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]': a.cc:8:13: required from here 8 | int y = min(a, b, c); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s777311654
p03713
C++
#include <iostream> #include <stdlib.h> #include <string> using namespace std; long long cal_mem(long long H, long long W){ long long ans_1, ans_2, ans_3; ans_1 = abs((H / 3) * W - (H - (H/3)) * (W / 2)); ans_2 = abs((H / 3 + 1) * W - (H - (H/3 + 1)) * (W / 2)); ans_3 = (H / 3 + 1) * W - (H / 3) * W; return min(ans_1, ans_2, ans_3); } int main(void){ long long H, W; long long s_max, s_mid, s_min; long long ans_h=0; long long ans_w=0; cin >> H >> W; if(H % 3 == 0 || W % 3 == 0){ cout << 0 << endl; return 0; } else{ ans_h = cal_mem(H, W); ans_w = cal_mem(W, H); cout << min(ans_h, ans_w) << endl; return 0; } }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:13:15: required from here 13 | return min(ans_1, ans_2, ans_3); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s239737355
p03713
C++
#include <iostream> #include <stdlib.h> #include <string> using namespace std; long long cal_mem(long long H, long long W){ long long ans_1, ans_2, ans_3; ans_1 = abs((H / 3) * W - (H - (H/3)) * (W / 2)); ans_2 = abs((H / 3 + 1) * W - (H - (H/3 + 1)) * (W / 2)); ans_3 = (H / 3 + 1) * W - (H / 3) * W return min(ans_1, ans_2, ans_3); } int main(void){ long long H, W; long long s_max, s_mid, s_min; long long ans_h=0; long long ans_w=0; cin >> H >> W; if(H % 3 == 0 || W % 3 == 0){ cout << 0 << endl; return 0; } else{ ans_h = cal_mem(H, W); ans_w = cal_mem(W, H); cout << min(ans_h, ans_w) << endl; return 0; } }
a.cc: In function 'long long int cal_mem(long long int, long long int)': a.cc:12:42: error: expected ';' before 'return' 12 | ans_3 = (H / 3 + 1) * W - (H / 3) * W | ^ | ; 13 | return min(ans_1, ans_2, ans_3); | ~~~~~~ a.cc:15:1: warning: no return statement in function returning non-void [-Wreturn-type] 15 | } | ^
s839997136
p03713
C++
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main(void){ long long H, W; cin >> H >> W; if(H % 3 == 0 || W % 3 == 0){ cout << 0 << endl; } else { long long mini = LLONG_MAX; for(long long i=1; i<H; i++){ long long a = i * W; long long b = (H-i)*(W/2); long long c = H * W - a - b; if(max({a, b, c}) - min({a, b, c}) < mini){ mini = max({a, b, c}) - min({a, b, c}); } long long a = i * W; long long b = (H-i)/2*W; long long c = H * W - a - b; if(max({a, b, c}) - min({a, b, c}) < mini){ mini = max({a, b, c}) - min({a, b, c}); } } for(long long i=1; i<W; i++){ long long a = i * H; long long b = (W-i)*(H/2); long long c = H * W - a - b; if(max({a, b, c}) - min({a, b, c}) < mini){ mini = max({a, b, c}) - min({a, b, c}); } long long a = i * H; long long b = (W-i)/2*H; long long c = H * W - a - b; if(max({a, b, c}) - min({a, b, c}) < mini){ mini = max({a, b, c}) - min({a, b, c}); } } cout << mini << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:26: error: 'LLONG_MAX' was not declared in this scope 12 | long long mini = LLONG_MAX; | ^~~~~~~~~ a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <algorithm> +++ |+#include <climits> 4 | using namespace std; a.cc:21:23: error: redeclaration of 'long long int a' 21 | long long a = i * W; | ^ a.cc:14:23: note: 'long long int a' previously declared here 14 | long long a = i * W; | ^ a.cc:22:23: error: redeclaration of 'long long int b' 22 | long long b = (H-i)/2*W; | ^ a.cc:15:23: note: 'long long int b' previously declared here 15 | long long b = (H-i)*(W/2); | ^ a.cc:23:23: error: redeclaration of 'long long int c' 23 | long long c = H * W - a - b; | ^ a.cc:16:23: note: 'long long int c' previously declared here 16 | long long c = H * W - a - b; | ^ a.cc:38:23: error: redeclaration of 'long long int a' 38 | long long a = i * H; | ^ a.cc:31:23: note: 'long long int a' previously declared here 31 | long long a = i * H; | ^ a.cc:39:23: error: redeclaration of 'long long int b' 39 | long long b = (W-i)/2*H; | ^ a.cc:32:23: note: 'long long int b' previously declared here 32 | long long b = (W-i)*(H/2); | ^ a.cc:40:23: error: redeclaration of 'long long int c' 40 | long long c = H * W - a - b; | ^ a.cc:33:23: note: 'long long int c' previously declared here 33 | long long c = H * W - a - b; | ^
s566023675
p03713
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define MOD 1000000007 using lli = long long int; using ulli = unsigned long long int; #define EVEL 1 #ifndef EVEL #define dbug(X) std::cout << #X << ":" <<X<<" " ; #define dbugf(s) std::cout << s << " "; #define dbugln std::cout<<"\n"; #else #define dbug(X) {} #define dbugf(s) {} #define dbugln {} #endif ulli S, ans = 99999999999, h; lli H, W; int main(){ cin >>H >>W; if(H%3 == 0 || W%3 == 0){ ans = 0; }else{ for(int l = 1; l < H-1; l++){ S = abs(l*W - ((H-l)/2)*W; if(ans > S) ans = S; S = abs(l*W - ((H-l)/2+1)*W; if(ans > S) ans = S; S = abs(l*W - (H-l)*(W/2); if(ans > S) ans = S; } for(int l = 1; l < W-1; l++){ S = abs(l*H - ((W-l)/2)*H; if(ans > S) ans = S; S = abs(l*H - ((W-l)/2+1)*H; if(ans > S) ans = S; S = abs(l*H - (W-l)*(H/2); if(ans > S) ans = S; } /* ans = min(H, W); if(H%2 == 0){ if(W%2 == 0){ S[0] = H*(W/2) - (H/2)*(W/2); S[1] = W*(H/2) - (H/2)*(W/2); if(ans > S[0]) ans = S[0]; dbug(S[0]); if(ans > S[1]) ans = S[1]; dbug(S[1]); }else{ S[0] = H*(W/2) - (H/2)*(W/2+1); S[1] = H*(W/2+1) - (H/2)*(W/2); S[2] = W*(H/2) - (H/2)*(W/2); if(ans > S[0]) ans = S[0]; dbug(S[0]); if(ans > S[1]) ans = S[1]; dbug(S[1]); if(ans > S[2]) ans = S[2]; dbug(S[2]); } }else if(H%2 == 1){ if(W%2 == 0){ S[0] = H*(W/2) - (H/2)*(W/2); S[1] = W*(H/2+1) - (H/2)*(W/2); S[2] = W*(H/2) - (H/2+1)*(W/2); if(ans > S[0]) ans = S[0]; dbug(S[0]); if(ans > S[1]) ans = S[1]; dbug(S[1]); if(ans > S[2]) ans = S[2]; dbug(S[2]); }else{ S[0] = H*(W/2) - (H/2)*(W/2+1); S[1] = H*(W/2+1) - (H/2)*(W/2); S[2] = W*(H/2+1) - (H/2)*(W/2); S[3] = W*(H/2) - (H/2+1)*(W/2); if(ans > S[0]) ans = S[0]; dbug(S[0]); if(ans > S[1]) ans = S[1]; dbug(S[1]); if(ans > S[2]) ans = S[2]; dbug(S[2]); if(ans > S[3]) ans = S[3]; dbug(S[3]); } } dbugln; S[0] = H; S[1] = W; if(ans > S[0]) ans = S[0]; dbug(S[0]); if(ans > S[1]) ans = S[1]; dbug(S[1]); */ } cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:33:50: error: expected ')' before ';' token 33 | S = abs(l*W - ((H-l)/2)*W; | ~ ^ | ) a.cc:35:52: error: expected ')' before ';' token 35 | S = abs(l*W - ((H-l)/2+1)*W; | ~ ^ | ) a.cc:37:50: error: expected ')' before ';' token 37 | S = abs(l*W - (H-l)*(W/2); | ~ ^ | ) a.cc:41:50: error: expected ')' before ';' token 41 | S = abs(l*H - ((W-l)/2)*H; | ~ ^ | ) a.cc:43:52: error: expected ')' before ';' token 43 | S = abs(l*H - ((W-l)/2+1)*H; | ~ ^ | ) a.cc:45:50: error: expected ')' before ';' token 45 | S = abs(l*H - (W-l)*(H/2); | ~ ^ | )
s760064503
p03713
C++
int main() { long long H, W; long long tmpMax, tmpMin; long long x, y, xx, yy; long long result, tmpRes1, tmpRes2, tmpResX, tmpResY; scanf("%lld %lld", &H, &W); //HまたはWが3で割りきれるときは等分割できるので0 if ((H % 3 == 0) || (W % 3 == 0)) { result = 0; printf("%lld\n", result); return 0; } tmpRes1 = 100000; tmpRes2 = 100000; //最初に長さWの長方形を切り出す場合 y = H / 3; if (y % 3 > 0) { y = y + 1; }//切り上げ tmpMax = y * W; //次も長さWの長方形を切り出す場合 if (H > 3) { yy = (H - y) / 2; tmpMin = yy * W; tmpRes1 = tmpMax - tmpMin; } xx = W / 3; tmpMin = xx * (H - y); tmpRes2 = tmpMax - tmpMin; if (tmpRes2 > tmpRes1) { tmpResY = tmpRes1; } else { tmpResY = tmpRes2; } //最初に長さHの長方形を切り出す場合 x = W / 3; tmpMax = x * H; //次も長さHの長方形を切り出す場合 if (W > 3) { xx = (W - x) / 2; tmpMin = xx * H; tmpRes1 = tmpMax - tmpMin; } yy = H / 3; tmpMin = yy * (W - x); tmpRes2 = tmpMax - tmpMin; if (tmpRes2 > tmpRes1) { tmpResX = tmpRes1; } else { tmpResX = tmpRes2; } //結果判断 if (tmpResX > tmpResY) { result = tmpResY; } else { result = tmpResX; } printf("%lld", result); return 0; }
a.cc: In function 'int main()': a.cc:7:9: error: 'scanf' was not declared in this scope 7 | scanf("%lld %lld", &H, &W); | ^~~~~ a.cc:12:17: error: 'printf' was not declared in this scope 12 | printf("%lld\n", result); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main() a.cc:66:9: error: 'printf' was not declared in this scope 66 | printf("%lld", result); | ^~~~~~ a.cc:66:9: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s132905295
p03713
C++
#include <iostream> #include <fstream> #include <string> #include <cmath> #include <algorithm> using namespace std; int main() { long h, w; long x, y; long s1, s2, s3; long ms1, ms2; long p1, p2; long d1,d2; cin >> h >> w; //縦 x = ((h * w) / 3) / h; y = h / 2; s1 = h * x; s2 = (w - x) * y; s3 = (w - x) * (h - y); p1 = s1; if (s2 > p1) p1 = s2; if (s3 > p1) p1 = s3; p2 = s1; if (s2 < p2) p2 = s2; if (s3 < p2) p2 = s3; ms1 = p1 - p2; /////////////////////////////// s1 = h * (x + 1); s2 = (w - (x + 1)) * y; s3 = (w - (x + 1)) * (h - y); p1 = s1; if (s2 > p1) p1 = s2; if (s3 > p1) p1 = s3; p2 = s1; if (s2 < p2) p2 = s2; if (s3 < p2) p2 = s3; if ((p1 - p2) < ms1) ms1 = p1 - p2; //横 y = ((h * w) / 3) / w; x = w / 2; s1 = w * y; s2 = (h - y) * x; s3 = (w - x) * (h - y); p1 = s1; if (s2 > p1) p1 = s2; if (s3 > p1) p1 = s3; p2 = s1; if (s2 < p2) p2 = s2; if (s3 < p2) p2 = s3; ms2 = p1 - p2; s1 = w * (y + 1); s2 = (h - (y + 1)) * x; s3 = (w - x) * (h - (y + 1)); p1 = s1; if (s2 > p1) p1 = s2; if (s3 > p1) p1 = s3; p2 = s1; if (s2 < p2) p2 = s2; if (s3 < p2) p2 = s3; if ((p1 - p2) < ms2) ms2 = p1 - p2; if(h==1){ s1=w/3; s2=w/3; s3=w-(s1+s2); d1=max(s1,s3)-min(s1,s3); } if(w==1){ s1=d/3; s2=d/3; s3=d-(s1+s2); d2=max(s1,s3)-min(s1,s3); } if(min(ms1, ms2)>d1){ if(d1>d2) cout << d2; } else if(min(ms1, ms2)>d2){ if(d2>d1) cout << d1; } else if (h % 3 == 0 || w % 3 == 0) cout << 0; else cout << min(ms1, ms2); //cout << min({ms1,ms2}); };
a.cc: In function 'int main()': a.cc:98:12: error: 'd' was not declared in this scope; did you mean 'd2'? 98 | s1=d/3; | ^ | d2
s703672475
p03713
C++
#include<stdio.h> //みっつの最小値 int hantei(int x,int y, int z){ if(x>=y){ if(x>=z){ if(y>=z){ //x,y,z return x-z; } else{ //x z y return x-y; } } else{ //z x y return z-y; } } else if(y>=z){ if (x>=z){ // y x z return y-z; } else { // y z x return y-x; } } else{ // z y x return z-x; } } int main(){ int h,w; scanf("%d %d",&h,&w); int i,j,k; int S1,S2,S3; int M=h*w; int nokori; int max,min; int temp=M int ima; if(h%3==0 || w%3==0){ printf("0"); return 0; } else { //たてたて for(i=1;i<(h-1)/2+1;i++) { S1=i*w; for(j=i+1;(j-1)/2+1;j++){ S2=(j-i)*w; S3=M-S1-S2; ima=hantei(S1,S2,S3); if(ima<temp){ temp=ima; } } } int tate=temp; printf("%d",tate); //たてよこ //入れ替えて考える } return 0; }
a.cc: In function 'int main()': a.cc:41:9: error: expected ',' or ';' before 'int' 41 | int ima; | ^~~ a.cc:53:33: error: 'ima' was not declared in this scope 53 | ima=hantei(S1,S2,S3); | ^~~
s240957883
p03713
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int S = h * w; int Smax, Smin; int[] gap = new int[2]; int minigap, g = 0; int a, b, s1, s2, s3; if(S % 3 == 0) { minigap = 0; } else { for(a = 1; a < w; a++) { for(b = 1; b < h; b++) { s1 = h * a; s2 = b * (w - a); s3 = (h - b) * (w - a); if(s1 > s2) { if(s1 < s3) { Smax = s1; if(s2 > s3) { Smin = s3; gap[g] = s1 - s3; } else { Smin = s2; gap[g] = s1 - s2; } } else { Smax = s3; Smin = s2; gap[g] = s3 - s2; } } else { if(s2 < s3) { Smax = s3; Smin = s1; gap[g] = s3 - s1; } else { Smax = s2; if(s1 > s3) { Smin = s3; gap[g] = s2 - s3; } else { Smin = s1; gap[g] = s2 - s1; } } } if(a == 1 && b == 1) { minigap = gap[g]; g++; } else { if(minigap > gap[g]) { minigap = gap[g]; g = 0; } else { minigap = minigap; g = 0; } } } } } System.out.println(minigap); } }
Main.java:58: error: variable minigap might not have been initialized if(minigap > gap[g]) { ^ Main.java:70: error: variable minigap might not have been initialized System.out.println(minigap); ^ 2 errors
s019865992
p03713
C++
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <string> using namespace std; int main(void){ long long h, w, maxA_tate, minA_tate,tateS,tateS1,tateS2,yokoS,yokoS1,yokoS2,maxB_yoko,minB_yoko; cin >> h >> w; if( (h*w) % 3 == 0 ){ cout << "0" << endl; return 0; } if(h%2 == 0){ for(int i=1;i<=w-1;i++){ if (2*w-3*i > 0 && ((2*w-3*i)*h) % 2 == 0){ maxA_tate = i; } } for(int i=w-1;i>0;i--){ if(3*i - 2*w > 0 && ((3*i - 2*w)*h) % 2 == 0){ minA_tate = i; } } }else{ for(int i=1;i<=w-1;i++){ if (2*w-3*i > 0 && (h*(2*w-3*i)+i) % 2 == 0){ maxA_tate = i; } } for(int i=w-1;i>0;i--){ if(h*(-2*w+3*i)-i) > 0 && (h*(-2*w+3*i)-i) % 2 == 0){ minA_tate = i; } } } if(h%2 == 0){ tateS1 = h * ((2*w - 3*maxA_tate) / 2); }else{ tateS1 = h * ((2*w - 3*maxA_tate) / 2 ) + maxA_tate/2; } if(h%2 == 0){ tateS2 = h * ((3*minA_tate - 2*w) / 2); }else{ tateS2 = h * ((-2*w + 3*minA_tate) / 2) - minA_tate/2; } if(tateS1 < tateS2){ tateS = tateS1; }else{ tateS = tateS2; } if(h%2 == 0){ for(int i=1;i<=h-1;i++){ if (2*h-3*i > 0 && ((2*h-3*i)*w) % 2 == 0){ maxB_yoko = i; } } for(int i=h-1;i>0;i--){ if(3*i - 2*h > 0 && ((3*i - 2*h)*w) % 2 == 0){ minB_yoko = i; } } }else{ for(int i=1;i<=h-1;i++){ if (2*h-3*i > 0 && (w*(2*h-3*i)+i) % 2 == 0){ maxB_yoko = i; } } for(int i=h-1;i>0;i--){ if((w*(-2*h+3*i)-i) > 0 && (w*(-2*h+3*i)-i) % 2 == 0){ minB_yoko = i; } } } // yokoS = w * (2*h - 3*maxB_yoko) / 2; // if(yokoS > (w * (3*minB_yoko - 2*h) / 2 )){ // yokoS = w * (3*minB_yoko - 2*h) / 2; // } if(h%2 == 0){ yokoS1 = w * ((2*h - 3*maxB_yoko) / 2); }else{ yokoS1 = w * ((2*h - 3*maxB_yoko) / 2) + maxB_yoko/2; } if(h%2 == 0){ yokoS2 = w * (3*minB_yoko - 2*h) / 2; }else{ yokoS2 = w * (( -2*h + 3*minB_yoko) / 2) - minB_yoko/2; } if(yokoS1 < yokoS2){ yokoS = yokoS1; }else{ yokoS = yokoS2; } if(yokoS < tateS){ cout << yokoS << endl; }else{ cout << tateS << endl; } cout << tateS1 << tateS2 << yokoS1 << yokoS2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:32: error: expected primary-expression before '>' token 36 | if(h*(-2*w+3*i)-i) > 0 && (h*(-2*w+3*i)-i) % 2 == 0){ | ^
s003132196
p03713
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; vector<long long> number(3, 0); int dif(long long , long long, long long); int mini; int main() { long long H, W, res; cin >> H >> W; if (H % 3 == 0 || W % 3 == 0) { mini = 0; } else { if (H < W) { long long tmp = H; H = W; W = tmp; } if (W > H) { mini = W; } else { mini = H; } for (long long i = 1; i <= W; i++) { long long tf = H % 2; if (tf == 0) { long long response = dif(i*H, (W - i)*(H / 2), (W - i)*(H / 2)); if (response <= mini) { mini = response; } } else { long long response = dif(i*H, (W - i)*((H / 2) + 1), (W - i)*(H / 2)); if (response <= mini) { mini = response; } } } } cout << mini << endl; } long long dif(long long a, long long b, long long c) { number[0] = a; number[1] = b; number[2] = c; sort(number.begin(), number.end()); long long ans = number[2] - number[0]; return ans; }
a.cc:49:11: error: ambiguating new declaration of 'long long int dif(long long int, long long int, long long int)' 49 | long long dif(long long a, long long b, long long c) { | ^~~ a.cc:7:5: note: old declaration 'int dif(long long int, long long int, long long int)' 7 | int dif(long long , long long, long long); | ^~~
s541930157
p03713
C++
#include<iostream> #include<algorithm> using namespace std; long long n,m; int main() { cin>>n>>m; long long s[3]; if(n%3==0||m%3==0) if(n<2||m<2)break; cout<<0<<endl; else { long long r1=m/2; long long r2=m-r1; long long ans=1e11; for(int i=0;i<=n;i++) { s[0]=r1*(n-i); s[1]=r2*(n-i); s[2]=m*i; sort(s,s+3); ans=min(ans,s[2]-s[0]); } r1=n/2; r2=n-r1; for(int i=0;i<=m;i++) { s[0]=r1*(m-i); s[1]=r2*(m-i); s[2]=n*i; sort(s,s+3); ans=min(ans,s[2]-s[0]); } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:25: error: break statement not within loop or switch 11 | if(n<2||m<2)break; | ^~~~~ a.cc:13:5: error: 'else' without a previous 'if' 13 | else | ^~~~
s962917095
p03713
C++
#include<cstdio> int main(){ int h,w; int a = 0; scanf("%d %d", &h,&w); if(w>h){ int tmp=h; h=w; w=tmp; } if(!(h%3==0||w%3==0)){ if(h%2==0||w%2==0){ // if(w%2==1){ // int tmp=h; // h=w; // w=tmp; // } int s=(h+1)/3; int ss=s*w-(h-s)*(w/2); a = (ss>0) ? ss : -ss; }else { int s=(h+1)/3; int sk=s*w; int ss=(h-s)*(w/2); int se=(h-s)*(w/2+1); if(ss>sk){ a=se-sk; }else{ if(se>sk){ a=se-ss; }else{ a=sk-ss; } } } } printf("%d\n",a); return 0; }  
a.cc:45:1: error: extended character   is not valid in an identifier 45 |   | ^ a.cc:45:1: error: '\U00003000' does not name a type 45 |   | ^~
s002580612
p03713
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <utility> #include <sys/time.h> using namespace std; void solve(long long h, long long w) { vector<long long> differs; long long min_of_3; long long max_of_3; if (h%3 == 0 || w%3 == 0) { std::cout << 0 << std::endl; } else { if (h%3 == 1) { min_of_3 = w * (h/3); if (w%2 == 0) { differs.push_back((h-(h/3))/2*w - min_of_3); } else { if (w < h-(h/3)) { differs.push_back(w); } else { differs.push_back(((h-(h/3))/2 +1)*w - min_of_3); } } } else { max_of_3 = w * ((h/3)+1); if (w%2 == 0) { differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2)); } else { if (w < h-((h/3)+1)) { differs.push_back(w); } else { differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2+1)); } } } long long tmp = w; w = h; h = tmp; if (h%3 == 1) { min_of_3 = w * (h/3); if (w%2 == 0) { differs.push_back((h-(h/3))*(w/2) - min_of_3); } else { if (w < h-(h/3)) { differs.push_back(w); } else { differs.push_back((h-(h/3))*(w/2+1) - min_of_3); } } } else { max_of_3 = w * ((h/3)+1); if (w%2 == 0) { differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2)); } else { if (w < h-((h/3)+1)) { differs.push_back(w); } else { differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2+1)); } } } std::cout << *min_element(differs.begin(), differs.end()) << std::endl; } } long long main() { struct timeval start,end; long long span; long long h,w; gettimeofday(&start,NULL); std::cin >> h >> w; solve(h, w); gettimeofday(&end,NULL); span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec); std::cerr << "--Total Time: " << span/1000 << "ms" << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s365864504
p03713
C++
#include <iostream> using namespace std; int main(void) { int H, W; cin >> H >> W; if (H % 3 == 0 || W % 3 == 0) { cout << "0" << endl; return 0; } long long min, max; if (H > W) { if (H % 3 == 2) { max = (H / 3 + 1)*W; H -= H / 3 + 1; if (W % 2 != 0 && H > W) { min = (H / 2)*W; } else { min = (W / 2)*H; } } else { max = (H / 3)*W; H -= H / 3; if (W % 2 != 0 && H > W) { min = round(H / 2.0)*W; } else { min = round(W / 2.0)*H; } } } else if (W > H) { if (W % 3 == 2) { max = (W / 3 + 1)*H; W -= W / 3 + 1; if (W % 2 != 0 && H > W) { min = (H / 2)*W; } else { min = (W / 2)*H; } } else { max = (W / 3)*H; W -= W / 3; if (W % 2 != 0 && H > W) { min = round(H / 2.0)*W; } else { min = round(W / 2.0)*H; } } } else { if (W % 3 == 1) { max = (H / 3)*W; H -= H / 3; min = (W / 2)*H; } else { max = (H / 3 + 1)*W; H -= H / 3 + 1; min = (W / 2)*H; } } cout << abs(max - min) << endl; return 0; }
a.cc: In function 'int main()': a.cc:29:39: error: 'round' was not declared in this scope 29 | min = round(H / 2.0)*W; | ^~~~~ a.cc:32:39: error: 'round' was not declared in this scope 32 | min = round(W / 2.0)*H; | ^~~~~ a.cc:49:39: error: 'round' was not declared in this scope 49 | min = round(H / 2.0)*W; | ^~~~~ a.cc:52:39: error: 'round' was not declared in this scope 52 | min = round(W / 2.0)*H; | ^~~~~
s900519957
p03713
C++
#include <vector> #include <algorithm> #include <iostream> #include <chrono> #include<bitset> #include<deque> #include <map> #define vint vector<int> #define vint2 vector<vint> #define vchar vector<char> #define vchar2 vector<vchar> #define vchar3 vector<vchar2> #define pr pair<int,int> #define vpr vector<pr> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define int long int using namespace std; int H, W; int h, w; int mymin(int a, int b, int c){ int mi = a, ma = a; if (mi > b)mi = b; if (mi > c)mi = c; if (ma < b)ma = b; if (ma < c)ma = c; return ma - mi; } int f(int a, int b, int c){ int mi = a; if (mi > b)mi = b; if (mi > c)mi = c; return mi; } int A(int y){ int a = y*W; int b = (H - y)*(W / 2); int c = (H - y)*(W - W / 2); return mymin(a, b, c); } int B(int y){ int a = y*W; int b = (H - y)/2*(W ); int c = (H - y-(H-y)/2)*(W ); return mymin(a, b, c); } int Y(int y){ int a = A(y); int b = B(y); return (a < b ? a : b); } int C(int x){ int a = x*H; int b = (W - x)*(H / 2); int c = (W - x)*(H - H / 2); return mymin(a, b, c); } int D(int x){ int a = x*H; int b = (W - x) / 2 * (H); int c = (W - x - (W - x) / 2)*(H); return mymin(a, b, c); } int X(int x){ int a = C(x); int b = D(x); return (a < b ? a : b); } int main(){ cin >> H >> W; int h = H % 3; int w = W % 3; if (h == 0 || w == 0){ cout << 0 << endl; return 0; } int a, b, c; a = Y(H / 3); b = Y(H / 3 + 1); c = Y(H / 3 + 2); int xmin = f(a, b, c); a = X(H / 3); b = X(H / 3 + 1); c = X(H / 3 + 2); int ymin = f(a, b, c); cout << (xmin < ymin ? xmin : ymin) << endl; //cerr << "mijissou" << endl; return 0; } //int mainB(){ // int H, W; // cin >> H >> W; // // REP(j, W + 2)cout << "#"; cout << endl; // REP(i, H){ // cout << "#"; // REP(j, W){ char c; cin >> c; cout << c; } // cout << "#"; cout << endl; // // } // REP(j, W + 2)cout << "#"; cout << endl; // // return 0; //} //int mainA(){ // int a[] = { 1, 3, 5, 7, 8, 10, 12 }; // int b[] = { 4, 6, 9, 11 }; // int c[] = { 2 }; // // int x, y; // cin >> x >> y; // int xx = -1, yy = -1; // // REP(i, 7){ // if (x == a[i])xx = 0; // if (y == a[i])yy = 0; // } // REP(i, 4){ // if (x == b[i])xx = 1; // if (y == b[i])yy = 1; // } // // if (x == 2)xx = 2; // if (y == 2)yy = 2; // cout << ((xx == yy) ? "Yes" : "No") << endl; // // // return 0; //}
a.cc:18:18: error: '::main' must return 'int' 18 | #define int long int | ^~~ a.cc:75:1: note: in expansion of macro 'int' 75 | int main(){ | ^~~
s830426849
p03713
C++
#include<iostream> #include<algorithm> using namespace std; long long n,m; int main() { while(cin>>n>>m) { long long s[3]; if(n%3==0||m%3==0) cout<<0<<endl; else { long long r1=m/2; long long r2=m-r1; long long mind=INT_MAX,maxd=INT_MIN; long long ans=INT_MAX; for(int i=1;i<=n;i++) { s[0]=r1*(n-i); s[1]=r2*(n-i); s[2]=m*i; sort(s,s+3); ans=min(ans,s[2]-s[0]); } r1=n/2; r2=n-r1; mind=INT_MAX,maxd=INT_MIN; for(int i=1;i<=m;i++) { s[0]=r1*(m-i); s[1]=r2*(m-i); s[2]=n*i; sort(s,s+3); ans=min(ans,s[2]-s[0]); } cout<<ans<<endl; } } }
a.cc: In function 'int main()': a.cc:17:24: error: 'INT_MAX' was not declared in this scope 17 | long long mind=INT_MAX,maxd=INT_MIN; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include<algorithm> +++ |+#include <climits> 3 | using namespace std; a.cc:29:22: error: 'maxd' was not declared in this scope 29 | mind=INT_MAX,maxd=INT_MIN; | ^~~~ a.cc:29:27: error: 'INT_MIN' was not declared in this scope 29 | mind=INT_MAX,maxd=INT_MIN; | ^~~~~~~ a.cc:29:27: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s926169501
p03713
C++
#include <iostream> #include <map> #include <set> #include <vector> #include <stack> #include <queue> #include <deque> #include <stdio.h> #include <cmath> #include <sstream> #include <algorithm> #include <iomanip> #include <cassert> #define ll long long #define mp make_pair #define pb push_back #define f first #define s second #define vi vector<int> #define vl vector<long long> #define sz size() #define x first #define y second #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ll n, m; ll ans = (ll)1e18; int main() { cin >> n >> m; ans = min(h, w); if(n % 3 == 0 || m % 3 == 0) { cout << 0; return 0; } for(ll i = 1; i <= m; i++) { { ll part1 = n * i; ll left = n * (m - i); ll part2, part3; part2 = (m - i) / 2 * n; part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } { ll part1 = n * i; ll left = n * (m - i); ll part2, part3; part2 = n/2 * (m - i); part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } } for(ll i = 1; i <= n; i++) { { ll part1 = m * i; ll left = m * (n - i); ll part2, part3; part2 = (n - i) / 2 * m; part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } { ll part1 = m * i; ll left = m * (n - i); ll part2, part3; part2 = m/2 * (n - i); part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } } //cout << ans << endl; cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:37:19: error: 'h' was not declared in this scope 37 | ans = min(h, w); | ^ a.cc:37:22: error: 'w' was not declared in this scope 37 | ans = min(h, w); | ^
s043224032
p03713
C++
#if 1 #include <iostream> #include <fstream> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <queue> #include <stack> #include <array> #include <deque> #include <algorithm> #include <utility> #include <cstdint> #include <functional> #include <iomanip> #include <numeric> #include <assert.h> auto& in = std::cin; auto& out = std::cout; int64_t H,W; int main() { using std::endl; in.sync_with_stdio(false); out.sync_with_stdio(false); in >> H>>W; int64_t min_diff = H*W; for (size_t w = 1; w < W; w++) { //h=H auto a = H*w,b=(H*(W-w)/2), c= ((H*(W - w)+1) / 2); min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); } for (size_t h = 1; h < H; h++) { //h=H auto a = h*W, b = ((H-h)*W / 2), c = (((H - h)*W + 1) / 2); min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); } std::cout << min_diff << std::endl; return 0; } #endif
a.cc: In function 'int main()': a.cc:40:36: error: no matching function for call to 'min(int64_t&, long unsigned int)' 40 | min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:40:36: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long unsigned int') 40 | min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:15: /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:40:36: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 40 | min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:46:36: error: no matching function for call to 'min(int64_t&, long unsigned int)' 46 | min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:46:36: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long unsigned int') 46 | min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:46:36: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 46 | min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c })); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s641374105
p03713
C++
#include<iostream> using namespace std; #include<vector> #include<map> #include<set> #include<algorithm> int main(){ long long int h,w; cin>>h>>w; if(h%3==0||w%3==0){ cout<<0<<endl; return 0; } long long int ans = h*w; for(int i = 1;i<h;i++){ vector<long long int> x(3); x[0]=i*w; long long int w2=w/2; x[1]=w2*(h-i); x[2]=(w-w2)*(h-i); sort(x.begin(),x.end()); long long int ans2 = x[2]-x[0]; ans=min(ans,ans2); } for(int i = 1;i<w;i++){ vector<long long int> x(3); x[0]=i*h; long long int w2=h/2; x[1]=w2*(w-i); x[2]=(h-w2)*(w-i); sort(x.begin(),x.end()); long long int ans2 = x[2]-x[0]; ans=min(ans,ans2); } long long int ans2 = (h*w/3)-(h*(w-(w/3))); min(ans,ans2); long long int ans2 = (w*h/3)-(w*(h-(h/3))); min(ans,ans2); cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:43:6: warning: ignoring return value of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = long long int]', declared with attribute 'nodiscard' [-Wunused-result] 43 | min(ans,ans2); | ~~~^~~~~~~~~~ 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: declared here 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:44:17: error: redeclaration of 'long long int ans2' 44 | long long int ans2 = (w*h/3)-(w*(h-(h/3))); | ^~~~ a.cc:42:17: note: 'long long int ans2' previously declared here 42 | long long int ans2 = (h*w/3)-(h*(w-(w/3))); | ^~~~ a.cc:45:6: warning: ignoring return value of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = long long int]', declared with attribute 'nodiscard' [-Wunused-result] 45 | min(ans,ans2); | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: declared here 233 | min(const _Tp& __a, const _Tp& __b) | ^~~
s067961141
p03713
C++
#include <iostream> #include <map> #include <set> #include <vector> #include <stack> #include <queue> #include <deque> #include <stdio.h> #include <cmath> #include <sstream> #include <algorithm> #include <iomanip> #define ll long long #define mp make_pair #define pb push_back #define f first #define s second #define vi vector<int> #define vl vector<long long> #define sz size() #define x first #define y second #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ll n, m; ll ans = (int)1e6; int main() { cin >> n >> m; for(int i = 1; i <= m; i++) { { ll part1 = n * i; ll left = n * (m - i); ll part2, part3; part2 = (m - i) / 2 * n; part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } { ll part1 = n * i; ll left = n * (m - i); ll part2, part3; part2 = n/2 * (m - i); part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } } for(int i = 1; i <= n; i++) { { ll part1 = m * i; ll left = m * (n - i); ll part2, part3; part2 = (n - i) / 2 * m; part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } { ll part1 = m * i; ll left = m * (n - i); ll part2, part3; part2 = m/2 * (n - i); part3 = n * m - part1 - part2; if(part1 == 0 || part2 == 0 || part3 == 0) continue; assert(part1 + part2 + part3 == n * m); ans = min(ans, max(abs(part1 - part2), max(abs(part1 - part3), abs(part3 - part2)))); } } //cout << ans << endl; cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:44:25: error: 'assert' was not declared in this scope 44 | assert(part1 + part2 + part3 == n * m); | ^~~~~~ a.cc:13:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 12 | #include <iomanip> +++ |+#include <cassert> 13 | a.cc:55:25: error: 'assert' was not declared in this scope 55 | assert(part1 + part2 + part3 == n * m); | ^~~~~~ a.cc:55:25: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' a.cc:69:25: error: 'assert' was not declared in this scope 69 | assert(part1 + part2 + part3 == n * m); | ^~~~~~ a.cc:69:25: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' a.cc:80:25: error: 'assert' was not declared in this scope 80 | assert(part1 + part2 + part3 == n * m); | ^~~~~~ a.cc:80:25: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
s272200984
p03713
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> #include <string> #include <queue> #include <cmath> #include <set> using namespace std; typedef long long ll; ll res=LLONG_MAX; void check(int x,int y) { for(int i=1;i<x;i++) { ll s1=(ll)i*y; ll s2,s3; ll tx=x-i,ty=y; for(int j=0;j<2;j++) { if(j) { s2=(ll)(tx/2)*ty; s3=(ll)(tx-tx/2)*ty; ll mi=min(s1,min(s2,s3)); ll ma=max(s1,max(s2,s3)); if(abs(ma-mi)<res) res=abs(ma-mi); } else { swap(tx,ty); s2=(ll)(tx/2)*ty; s3=(ll)(tx-tx/2)*ty; ll mi=min(s1,min(s2,s3)); ll ma=max(s1,max(s2,s3)); if(abs(ma-mi)<res) res=abs(ma-mi); } } } } int main() { int n,m; scanf("%d%d",&n,&m); if(n%3==0||m%3==0) { cout<<"0"<<endl; return 0; } check(n,m); check(m,n); cout<<res<<endl; return 0; }
a.cc:17:8: error: 'LLONG_MAX' was not declared in this scope 17 | ll res=LLONG_MAX; | ^~~~~~~~~ a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 9 | #include <set> +++ |+#include <climits> 10 |
s975079177
p03713
C
#include<stdio.h> int main(){ int a.b; printf("%d\n",a*b%3); }
main.c: In function 'main': main.c:3:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 3 | int a.b; | ^ main.c:3:14: error: expected expression before '.' token main.c:4:23: error: 'a' undeclared (first use in this function) 4 | printf("%d\n",a*b%3); | ^ main.c:4:23: note: each undeclared identifier is reported only once for each function it appears in main.c:4:25: error: 'b' undeclared (first use in this function) 4 | printf("%d\n",a*b%3); | ^
s060765426
p03714
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <map> #include <set> #include <stack> #include <tuple> #include <deque> #include <numeric> #include <bitset> #include <iomanip> #include <cassert> #include <chrono> #include <random> #include <limits> #include <iterator> #include <functional> #include <sstream> #include <complex> using namespace std; using ll = long long; using ull = uint64_t; using P = pair<int, int>; constexpr double EPS = 1e-9; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template<class T> inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template<class T> inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int N = n * 3; vector<int> a(N); for(int i = 0; i < N; ++i) cin >> a[i]; ll S1 = 0, S2 = 0; priority_queue<int, vector<int>, greater<int>> Q1; for(int i = 0; i < n; ++i){ S1 += a[i]; Q1.push(a[i]); } multiset<int> st, st2; for(int i = n; i < N; ++i){ S2 += a[i]; st.insert(a[i]); } int c = n; while(c-- > 0){ int val = *(st.rbegin()); st.erase(st.rbegin()); S2 -= val; st2.insert(val); } ll ans = S1 - S2; for(int i = n; i < N - n; ++i){ if(a[i] > Q1.top()){ S1 -= Q1.top(); Q1.pop(); Q1.push(a[i]); S1 += a[i]; } auto it = st.find(a[i]); if(it != st.end()){ S2 -= a[i]; st.erase(it); int val = *(st2.begin()); S2 += val; st2.erase(st2.begin()); st.insert(val); } else{ st2.erase(st2.find(a[i])); } chmax(ans, S1 - S2); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:73:17: error: no matching function for call to 'std::multiset<int>::erase(std::multiset<int>::reverse_iterator)' 73 | st.erase(st.rbegin()); | ~~~~~~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/set:64, from a.cc:8: /usr/include/c++/14/bits/stl_multiset.h:641:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(const_iterator) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator]' 641 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/14/bits/stl_multiset.h:641:28: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::multiset<int>::const_iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} 641 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_multiset.h:671:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::size_type std::multiset<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; size_type = long unsigned int; key_type = int]' 671 | erase(const key_type& __x) | ^~~~~ /usr/include/c++/14/bits/stl_multiset.h:671:29: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::multiset<int>::key_type&' {aka 'const int&'} 671 | erase(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_multiset.h:693:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(const_iterator, const_iterator) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator]' 693 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/14/bits/stl_multiset.h:693:7: note: candidate expects 2 arguments, 1 provided
s415868323
p03714
C++
import sys import heapq def main(): N = int(input()) a = list(map(int, input().split())) left = a[0 : N] right = a[N*2 : N*3] for i in range(N): right[i] *= -1 left_sum = 0 right_sum = 0 heap_left = [] heap_right = [] for i in range(N): left_sum += left[i] heapq.heappush(heap_left, left[i]) right_sum += right[i] heapq.heappush(heap_right, right[i]) temp1 = [0] * (N + 1) temp2 = [0] * (N + 1) temp1[0] = left_sum temp2[N] = right_sum for i in range(0, N): left_sum += a[N+i] heapq.heappush(heap_left, a[N+i]) left_sum -= heapq.heappop(heap_left) temp1[i+1] = left_sum for i in range(0, N): right_sum -= a[N*2-1-i] heapq.heappush(heap_right, -a[N*2-1-i]) right_sum -= heapq.heappop(heap_right) temp2[N - 1 - i] = right_sum ans = -1000000000 for i in range(0, N + 1): x = temp1[i] + temp2[i] if(ans < x): ans = x print(ans) main()
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s573078192
p03714
C++
N = int(input()) a = list(map(int, input().split())) left = a[0 : N] right = a[N*2 : N*3] for i in range(N): right[i] *= -1 left_sum = 0 right_sum = 0 heap_left = [] heap_right = [] for i in range(N): left_sum += left[i] heapq.heappush(heap_left, left[i]) right_sum += right[i] heapq.heappush(heap_right, right[i]) temp1 = [0] * (N + 1) temp2 = [0] * (N + 1) temp1[0] = left_sum temp2[N] = right_sum for i in range(0, N): left_sum += a[N+i] heapq.heappush(heap_left, a[N+i]) left_sum -= heapq.heappop(heap_left) temp1[i+1] = left_sum for i in range(0, N): right_sum -= a[N*2-1-i] heapq.heappush(heap_right, -a[N*2-1-i]) right_sum -= heapq.heappop(heap_right) temp2[N - 1 - i] = right_sum ans = -1000000000 for i in range(0, N + 1): x = temp1[i] + temp2[i] if(ans < x): ans = x print(ans)
a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s364993452
p03714
C++
def main(): N = int(input()) a = list(map(int, input().split())) left = a[0 : N] right = a[N*2 : N*3] for i in range(N): right[i] *= -1 left_sum = 0 right_sum = 0 heap_left = [] heap_right = [] for i in range(N): left_sum += left[i] heapq.heappush(heap_left, left[i]) right_sum += right[i] heapq.heappush(heap_right, right[i]) temp1 = [0] * (N + 1) temp2 = [0] * (N + 1) temp1[0] = left_sum temp2[N] = right_sum for i in range(0, N): left_sum += a[N+i] heapq.heappush(heap_left, a[N+i]) left_sum -= heapq.heappop(heap_left) temp1[i+1] = left_sum for i in range(0, N): right_sum -= a[N*2-1-i] heapq.heappush(heap_right, -a[N*2-1-i]) right_sum -= heapq.heappop(heap_right) temp2[N - 1 - i] = right_sum ans = -1000000000 for i in range(0, N + 1): x = temp1[i] + temp2[i] if(ans < x): ans = x print(ans) main()
a.cc:1:1: error: 'def' does not name a type 1 | def main(): | ^~~
s153179283
p03714
C++
import sys import heapq def main(): N = int(input()) a = list(map(int, input().split())) left = a[0 : N] right = a[N*2 : N*3] for i in range(N): right[i] *= -1 left_sum = 0 right_sum = 0 heap_left = [] heap_right = [] for i in range(N): left_sum += left[i] heapq.heappush(heap_left, left[i]) right_sum += right[i] heapq.heappush(heap_right, right[i]) temp1 = [0] * (N + 1) temp2 = [0] * (N + 1) temp1[0] = left_sum temp2[N] = right_sum for i in range(0, N): left_sum += a[N+i] heapq.heappush(heap_left, a[N+i]) left_sum -= heapq.heappop(heap_left) temp1[i+1] = left_sum for i in range(0, N): right_sum -= a[N*2-1-i] heapq.heappush(heap_right, -a[N*2-1-i]) right_sum -= heapq.heappop(heap_right) temp2[N - 1 - i] = right_sum ans = -1000000000 for i in range(0, N + 1): x = temp1[i] + temp2[i] if(ans < x): ans = x print(ans) main()
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s532807753
p03714
C++
import sys import heapq def main(): N = int(input()) a = list(map(int, input().split())) left = a[0 : N] right = a[N*2 : N*3] for i in range(N): right[i] *= -1 left_sum = 0 right_sum = 0 heap_left = [] heap_right = [] for i in range(N): left_sum += left[i] heapq.heappush(heap_left, left[i]) right_sum += right[i] heapq.heappush(heap_right, right[i]) temp1 = [0] * (N + 1) temp2 = [0] * (N + 1) temp1[0] = left_sum temp2[N] = right_sum for i in range(0, N): left_sum += a[N+i] heapq.heappush(heap_left, a[N+i]) left_sum -= heapq.heappop(heap_left) temp1[i+1] = left_sum for i in range(0, N): right_sum -= a[N*2-1-i] heapq.heappush(heap_right, -a[N*2-1-i]) right_sum -= heapq.heappop(heap_right) temp2[N - 1 - i] = right_sum ans = -1000000000; for i in range(0, N + 1): x = temp1[i] + temp2[i] if(ans < x): ans = x print(ans) main()
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:45:9: error: expected unqualified-id before 'for' 45 | for i in range(0, N + 1): | ^~~
s787834274
p03714
C++
#include <iostream> #include <vector> 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]; } //左の消す個数をkこと固定しておく。それの最大をかんがえるので 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:14:5: error: 'priority_queue' was not declared in this scope 14 | priority_queue<long long, vector<long long>, greater<long long> > que1; | ^~~~~~~~~~~~~~ a.cc:3:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>' 2 | #include <vector> +++ |+#include <queue> 3 | a.cc:14:20: error: expected primary-expression before 'long' 14 | priority_queue<long long, vector<long long>, greater<long long> > que1; | ^~~~ a.cc:17:9: error: 'que1' was not declared in this scope 17 | que1.push(a[i]); | ^~~~ a.cc:20:24: error: 'que1' was not declared in this scope 20 | long long mi = que1.top(); | ^~~~ a.cc:31:20: error: expected primary-expression before 'long' 31 | priority_queue<long long> que2; | ^~~~ a.cc:34:9: error: 'que2' was not declared in this scope 34 | que2.push(a[N*3-1 - i]); | ^~~~ a.cc:37:24: error: 'que2' was not declared in this scope 37 | long long ma = que2.top(); | ^~~~
s976344375
p03714
C++
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; int main() { int n; cin >> n; vector<long long> v(n); for (int& i: v) cin >> i; vector<long long> ans(n + 1); long long left(0), right(0); priority_queue<long long> min_q; priority_queue<long long, vector<long long>, greater<long long>> max_q; for (int i = 0; i < n; ++i) { max_q.push(v[i]); min_q.push(v[i + 2 * n]); left += v[i]; right += v[i + 2 * n]; }; ans[0] = left; ans.back() = -right; for (int i = n; i < 2 * n; ++i) { max_q.push(v[i]); left += v[i] - max_q.top(); max_q.pop(); ans[i-n+1] += left; min_q.push(v[3 * n - 1 - i]); right += v[3 * n - i - 1] - min_q.top(); min_q.pop(); ans[2 * n - i - 1] -= right; } long long res(-1e14); for (const long long& i: ans) res = max(res, i); cout << res; return 0; };
a.cc: In function 'int main()': a.cc:12:22: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int' 12 | for (int& i: v) cin >> i; | ^
s114896514
p03714
C++
#include<bits/stdc++.h> using namespace std; ll ara[100005]; ll A[100005],B[100005]; void prll(multiset<ll>st) { for(auto it=st.begin();it!=st.end();it++) cout<<*it<<" "; cout<<endl; } #define inf -1000000000000000 int main() { ll n;cin>>n; for(ll i=0;i<3*n;i++)cin>>ara[i]; multiset<ll>st; multiset<ll,greater<ll>>ss; multiset<ll,greater<ll>>::iterator ii; multiset<ll>::iterator it; ll sum=0; for(ll i=0;i<n;i++) { sum+=ara[i]; st.insert(ara[i]); } A[n-1]=sum; for(ll i=n;i<2*n;i++) { it=st.begin(); if(*it<ara[i]){ // cout<<"eraseing "<<endl; sum=sum+ara[i]-*it; st.erase(it); st.insert(ara[i]); // prll(st); } A[i]=sum; } // for(ll i=n-1;i<=2*n;i++)cout<<A[i]<<" ";cout<<endl; sum=0; for(ll i=3*n-1;i>=2*n;i--) { sum+=ara[i]; ss.insert(ara[i]); } B[2*n]=sum; for(ll i=2*n-1;i>=n;i--) { ii=ss.begin(); if(*ii>ara[i]) { // cout<<"i = "<<i<< sum=sum+ara[i]-*ii; ss.erase(ii); ss.insert(ara[i]); } B[i]=sum; } ll ans=inf; for(ll i=n-1;i<2*n;i++) { ll temp=A[i]-B[i+1]; ans=max(ans,temp); } cout<<ans<<endl; }
a.cc:4:1: error: 'll' does not name a type 4 | ll ara[100005]; | ^~ a.cc:5:1: error: 'll' does not name a type 5 | ll A[100005],B[100005]; | ^~ a.cc:6:20: error: 'll' was not declared in this scope 6 | void prll(multiset<ll>st) | ^~ a.cc:6:22: error: template argument 1 is invalid 6 | void prll(multiset<ll>st) | ^ a.cc:6:22: error: template argument 2 is invalid a.cc:6:22: error: template argument 3 is invalid a.cc: In function 'void prll(int)': a.cc:8:20: error: request for member 'begin' in 'st', which is of non-class type 'int' 8 | for(auto it=st.begin();it!=st.end();it++) | ^~~~~ a.cc:8:35: error: request for member 'end' in 'st', which is of non-class type 'int' 8 | for(auto it=st.begin();it!=st.end();it++) | ^~~ a.cc: In function 'int main()': a.cc:15:5: error: 'll' was not declared in this scope 15 | ll n;cin>>n; | ^~ a.cc:15:15: error: 'n' was not declared in this scope; did you mean 'yn'? 15 | ll n;cin>>n; | ^ | yn a.cc:16:11: error: expected ';' before 'i' 16 | for(ll i=0;i<3*n;i++)cin>>ara[i]; | ^~ | ; a.cc:16:16: error: 'i' was not declared in this scope 16 | for(ll i=0;i<3*n;i++)cin>>ara[i]; | ^ a.cc:16:31: error: 'ara' was not declared in this scope 16 | for(ll i=0;i<3*n;i++)cin>>ara[i]; | ^~~ a.cc:17:16: error: template argument 2 is invalid 17 | multiset<ll>st; | ^ a.cc:17:16: error: template argument 3 is invalid a.cc:18:27: error: template argument 2 is invalid 18 | multiset<ll,greater<ll>>ss; | ^~ a.cc:18:27: error: template argument 3 is invalid a.cc:19:27: error: template argument 2 is invalid 19 | multiset<ll,greater<ll>>::iterator ii; | ^~ a.cc:19:27: error: template argument 3 is invalid a.cc:19:40: error: expected initializer before 'ii' 19 | multiset<ll,greater<ll>>::iterator ii; | ^~ a.cc:20:16: error: template argument 2 is invalid 20 | multiset<ll>::iterator it; | ^ a.cc:20:16: error: template argument 3 is invalid a.cc:20:28: error: expected initializer before 'it' 20 | multiset<ll>::iterator it; | ^~ a.cc:21:7: error: expected ';' before 'sum' 21 | ll sum=0; | ^~~~ | ; a.cc:22:11: error: expected ';' before 'i' 22 | for(ll i=0;i<n;i++) | ^~ | ; a.cc:22:16: error: 'i' was not declared in this scope 22 | for(ll i=0;i<n;i++) | ^ a.cc:24:9: error: 'sum' was not declared in this scope 24 | sum+=ara[i]; | ^~~ a.cc:24:14: error: 'ara' was not declared in this scope 24 | sum+=ara[i]; | ^~~ a.cc:25:12: error: request for member 'insert' in 'st', which is of non-class type 'int' 25 | st.insert(ara[i]); | ^~~~~~ a.cc:27:5: error: 'A' was not declared in this scope 27 | A[n-1]=sum; | ^ a.cc:27:12: error: 'sum' was not declared in this scope 27 | A[n-1]=sum; | ^~~ a.cc:28:11: error: expected ';' before 'i' 28 | for(ll i=n;i<2*n;i++) | ^~ | ; a.cc:28:16: error: 'i' was not declared in this scope 28 | for(ll i=n;i<2*n;i++) | ^ a.cc:30:9: error: 'it' was not declared in this scope; did you mean 'st'? 30 | it=st.begin(); | ^~ | st a.cc:30:15: error: request for member 'begin' in 'st', which is of non-class type 'int' 30 | it=st.begin(); | ^~~~~ a.cc:31:16: error: 'ara' was not declared in this scope 31 | if(*it<ara[i]){ | ^~~ a.cc:35:16: error: request for member 'erase' in 'st', which is of non-class type 'int' 35 | st.erase(it); | ^~~~~ a.cc:36:16: error: request for member 'insert' in 'st', which is of non-class type 'int' 36 | st.insert(ara[i]); | ^~~~~~ a.cc:43:11: error: expected ';' before 'i' 43 | for(ll i=3*n-1;i>=2*n;i--) | ^~ | ; a.cc:43:20: error: 'i' was not declared in this scope 43 | for(ll i=3*n-1;i>=2*n;i--) | ^ a.cc:45:14: error: 'ara' was not declared in this scope 45 | sum+=ara[i]; | ^~~ a.cc:46:12: error: request for member 'insert' in 'ss', which is of non-class type 'int' 46 | ss.insert(ara[i]); | ^~~~~~ a.cc:48:5: error: 'B' was not declared in this scope 48 | B[2*n]=sum; | ^ a.cc:49:11: error: expected ';' before 'i' 49 | for(ll i=2*n-1;i>=n;i--) | ^~ | ; a.cc:49:20: error: 'i' was not declared in this scope 49 | for(ll i=2*n-1;i>=n;i--) | ^ a.cc:51:9: error: 'ii' was not declared in this scope 51 | ii=ss.begin(); | ^~ a.cc:51:15: error: request for member 'begin' in 'ss', which is of non-class type 'int' 51 | ii=ss.begin(); | ^~~~~ a.cc:52:16: error: 'ara' was not declared in this scope 52 | if(*ii>ara[i]) | ^~~ a.cc:56:16: error: request for member 'erase' in 'ss', which is of non-class type 'int' 56 | ss.erase(ii); | ^~~~~ a.cc:57:16: error: request for member 'insert' in 'ss', which is of non-class type 'int' 57 | ss.insert(ara[i]); | ^~~~~~ a.cc:61:7: error: expected ';' before 'ans' 61 | ll ans=inf; | ^~~~ | ; a.cc:62:11: error: expected ';' before 'i' 62 | for(ll i=n-1;i<2*n;i++) | ^~ | ; a.cc:62:18: error: 'i' was not declared in this scope 62 | for(ll i=n-1;i<2*n;i++) | ^ a.cc:64:11: error: expected ';' before 'temp' 64 | ll temp=A[i]-B[i+1]; | ^~~~~ | ; a.cc:65:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 65 | ans=max(ans,temp); | ^~~ | abs a.cc:65:21: error: 'temp' was not declared in this scope; did you mean 'tm'? 65 | ans=max(ans,temp); | ^~~~ | tm a.cc:67:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 67 | cout<<ans<<endl; | ^~~ | abs
s510678042
p03714
C++
#include <bits/stdc++.h> #define SIZE 300005 #define MOD 1000000007LL #define EPS 1e-10 #define INF 1<<29 #define LLINF 1LL<<60 #define REP(i,n) for(int i=0;i<n;i++) #define FOR(i,a,b) for(int i=a;i<=b;i++) #define DOWN(i,b,a) for(int i=b;i>=a;i--) #define SET(a,c) memset(a,c,sizeof a) #define BIT(i,j) ((i)>>(j))&1 #define ALL(o) (o).begin(), (o).end() #define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end()) #define SQ(x) ((x)*(x)) using namespace std; typedef long long ll; typedef pair<ll,ll> Pll; typedef pair<int, int> Pii; typedef pair<double, double> Pdd; typedef complex<double> dcomplex; template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}} ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);} ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);} ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;} ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;} ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;} ac ll N; int main() { cin >> N; vector<ll> A(3*N); REP(i, 3*N) cin >> A[i]; priority_queue<ll> Pl, Pr; ll sl = 0, sr = 0; FOR(i, 0, N-1) { sl += A[i]; Pl.push(-A[i]); sr += A[2*N+i]; Pr.push(A[2*N+i]); } vector<ll> left(N+1), right(N+1); left[0] = sl; right[N] = sr; FOR(i, 0, N-1) { Pl.push(-A[N+i]); sl = sl + A[N+i] + Pl.top(); left[i+1] = sl; Pl.pop(); } DOWN(i, N-1, 0) { Pr.push(A[N+i]); sr = sr + A[N+i] - Pr.top(); right[i] = sr; Pr.pop(); } ll ans = -LLINF; FOR(i, 0, N) ans = max(ans, left[i] - right[i]); cout << ans << endl; return 0; }
a.cc:27:1: error: 'ac' does not name a type 27 | ac | ^~ a.cc: In function 'int main()': a.cc:31:12: error: 'N' was not declared in this scope 31 | cin >> N; | ^
s883633345
p03714
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define ll long long using namespace std; int main(){ ll n;cin>>n; ll a[n]; ll lsums[100001]; ll rsums[100001]; lsums[0]=0, rsums[n]=0; rep(i,3*n)cin>>a[i]; priority_queue<int, vector<int>, greater<int>> lq; priority_queue<int> rq; rep(i,n){ lq.push(a[i]); lsums[0]+=a[i]; rq.push(a[3*n-1-i]); rsums[n]+=a[3*n-1-i]; } rep(i,n){ lq.push(a[i+n]); lsums[i+1]=(lsums[i]+a[i+n]-lq.top()); lq.pop(); rq.push(a[2*n-1-i]); rsums[n-1-i]=(rsums[n-i]+a[2*n-1-i]-rq.top()); rq.pop(); } //cout<<lsums[0]<<' '<<rsums[0]<<endl; int result = lsums[0]-rsums[0]; rep(i,n){ result=max(result, lsums[i+1]-rsums[i+1]); } cout<<result; return 0; }
a.cc: In function 'int main()': a.cc:42:15: error: no matching function for call to 'max(int&, long long int)' 42 | result=max(result, lsums[i+1]-rsums[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:42:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 42 | result=max(result, lsums[i+1]-rsums[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:42:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | result=max(result, lsums[i+1]-rsums[i+1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s636579683
p03714
C++
#include<bits/stdc++.h> #include<algorithm> #include<math.h> #include<iostream> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const long long INF = 1LL << 60; using ll = long long; /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n; cin>>n; ll sum=0; ll resum=0; vector<ll> A(3*n); priority_queue<ll> front; priority_queue<ll> back; for(int i=0;i<3*n;++i){ cin>>A[i]; if(i<n){ front.push(-A[i]); sum+=A[i]; } if(2*n-1<i){ back.push(A[i]); resum+=A[i]; } } vector<pair<ll,ll>> ans(n+1); ans[0].first=sum; ans[n].second=resum; for(int i=n;i<2*n;i++){ front.push(-A[i]); sum+=A[i]; ll a=front.top(); sum+=a; front.pop(); ans[i-n+1].first=sum; } for(int i=(2*n-1);n<=i;i--){ back.push(A[i]); resum+=A[i]; ll a=back.top(); resum-=a; back.pop(); ans[i-n].second=resum; } ll Ans=-INF; FOR(i,0,n+1){ ll now=ans[i].first-ans[i].second; chmax(Ans,now); } cout<<Ans<<endl; }
a.cc: In function 'int main()': a.cc:74:7: error: 'i' was not declared in this scope 74 | FOR(i,0,n+1){ | ^ a.cc:74:3: error: 'FOR' was not declared in this scope 74 | FOR(i,0,n+1){ | ^~~
s319844959
p03714
C++
#include<bits/stdc++.h> #include<algorithm> #include<math.h> #include<iostream> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const long long INF = 1LL << 60; using ll = long long; /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n; cin>>n; ll sum=0; ll resum=0; vector<ll> A(3*n); priority_queue<ll> front; priority_queue<ll> back; FOR(i,0,3*n){ cin>>A[i]; if(i<n){ front.push(-A[i]); sum+=A[i]; } if(2*n-1<i){ back.push(A[i]); resum+=A[i]; } } vector<pair<ll,ll>> ans(n+1); ans[0].first=sum; ans[n].second=resum; for(int i=n;i<2*n;i++){ front.push(-A[i]); sum+=A[i]; ll a=front.top(); sum+=a; front.pop(); ans[i-n+1].first=sum; } for(int i=(2*n-1);n<=i;i--){ back.push(A[i]); resum+=A[i]; ll a=back.top(); resum-=a; back.pop(); ans[i-n].second=resum; } ll Ans=-INF; FOR(i,0,n+1){ ll now=ans[i].first-ans[i].second; chmax(Ans,now); } cout<<Ans<<endl; }
a.cc: In function 'int main()': a.cc:36:7: error: 'i' was not declared in this scope 36 | FOR(i,0,3*n){ | ^ a.cc:36:3: error: 'FOR' was not declared in this scope 36 | FOR(i,0,3*n){ | ^~~
s750206450
p03714
C++
#include<bits/stdc++.h> #include<algorithm> #include<math.h> #include<iostream> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const long long INF = 1LL << 60; using ll = long long; /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n; cin>>n; ll sum=0; ll resum=0; vector<ll> A(3*n); priority_queue<ll> front; priority_queue<ll> back; FOR(i,0,3*n){ cin>>A[i]; if(i<n){ front.push(-A[i]); sum+=A[i]; } if(2*n-1<i){ back.push(A[i]); resum+=A[i]; } } vector<pair<ll,ll>> ans(n+1); ans[0].first=sum; ans[n].second=resum; for(int i=n;i<2*n;i++){ front.push(-A[i]); sum+=A[i]; ll a=front.top(); sum+=a; front.pop(); ans[i-n+1].first=sum; } for(int i=(2*n-1);n<=i;i--){ back.push(A[i]); resum+=A[i]; ll a=back.top(); resum-=a; back.pop(); ans[i-n].second=resum; } ll Ans=-INF; FOR(i,0,n+1){ ll now=ans[i].first-ans[i].second; chmax(Ans,now); } co(Ans) }
a.cc: In function 'int main()': a.cc:36:7: error: 'i' was not declared in this scope 36 | FOR(i,0,3*n){ | ^ a.cc:36:3: error: 'FOR' was not declared in this scope 36 | FOR(i,0,3*n){ | ^~~ a.cc:78:3: error: 'co' was not declared in this scope; did you mean 'cos'? 78 | co(Ans) | ^~ | cos
s006586164
p03714
C++
#include <iostream> #include <tuple> #include <vector> #include <queue> #include <algorithm> int main(){ int N; std::cin >> N; std::vector<int> a_arr(3*N); for(int i = 0; i < 3*N; i++) std::cin >> a_arr[i]; std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); for(int i = 0; i < N; i++) left.push(i); std::vector<int> right_index(2*N); std::vector<int> remove_arr(3*N); for(int i = N; i < 3*N; i++) right_index[i-N] = i; std::sort(right_index.begin(), right_index.end(), [&](int l, int r){return a_arr[l]>a_arr[r];}); for(int i = 0; i < N; i++){ right.push(right_index[i]); remove_arr[right_index[i]] = 1; } long long sum_left = 0, sum_right = 0; for(int i = 0; i < N; i++) sum_left += a_arr[i]; for(int i = N; i < 2*N; i++) sum_right += a_arr[right_index[i]]; long long max_sum_diff = sum_left-sum_right; for(int th = N; th < 2*N; th++){ if(remove_arr[th] == 0){ int ri; while(true){ ri = right.top(); right.pop(); if(ri > th) break; } remove_arr[ri] = 0; sum_right += a_arr[ri] - a_arr[th]; } left.push(th); int li = left.top(); left.pop(); sum_left += a_arr[th] - a_arr[li]; max_sum_diff = std::max(max_sum_diff, sum_left-sum_right); } std::cout << max_sum_diff << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:14:51: error: 'function' is not a member of 'std' 14 | std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); | ^~~~~~~~ a.cc:6:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 5 | #include <algorithm> +++ |+#include <functional> 6 | a.cc:14:72: error: expression list treated as compound expression in functional cast [-fpermissive] 14 | std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); | ^ a.cc:14:73: error: template argument 3 is invalid 14 | std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); | ^~ a.cc:14:81: error: cannot convert 'main()::<lambda(int, int)>' to 'int' in initialization 14 | std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | main()::<lambda(int, int)> a.cc:14:134: error: cannot convert 'main()::<lambda(int, int)>' to 'int' in initialization 14 | std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | main()::<lambda(int, int)> a.cc:15:35: error: request for member 'push' in 'left', which is of non-class type 'int' 15 | for(int i = 0; i < N; i++) left.push(i); | ^~~~ a.cc:22:11: error: request for member 'push' in 'right', which is of non-class type 'int' 22 | right.push(right_index[i]); | ^~~~ a.cc:34:20: error: request for member 'top' in 'right', which is of non-class type 'int' 34 | ri = right.top(); | ^~~ a.cc:35:15: error: request for member 'pop' in 'right', which is of non-class type 'int' 35 | right.pop(); | ^~~ a.cc:41:10: error: request for member 'push' in 'left', which is of non-class type 'int' 41 | left.push(th); | ^~~~ a.cc:42:19: error: request for member 'top' in 'left', which is of non-class type 'int' 42 | int li = left.top(); | ^~~ a.cc:43:10: error: request for member 'pop' in 'left', which is of non-class type 'int' 43 | left.pop(); | ^~~
s508022058
p03714
C++
#include <iostream> #include <tuple> #include <vector> #include <queue> #include <functional> int main(){ int N; std::cin >> N; std::vector<int> a_arr(3*N); for(int i = 0; i < 3*N; i++) std::cin >> a_arr[i]; std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];}); for(int i = 0; i < N; i++) left.push(i); std::vector<int> right_index(2*N); std::vector<int> remove_arr(3*N); for(int i = N; i < 3*N; i++) right_index[i-N] = i; std::sort(right_index.begin(), right_index.end(), [&](int l, int r){return a_arr[l]>a_arr[r];}); for(int i = 0; i < N; i++){ right.push(right_index[i]); remove_arr[right_index[i]] = 1; } long long sum_left = 0, sum_right = 0; for(int i = 0; i < N; i++) sum_left += a_arr[i]; for(int i = N; i < 2*N; i++) sum_right += a_arr[right_index[i]]; long long max_sum_diff = sum_left-sum_right; for(int th = N; th < 2*N; th++){ if(remove_arr[th] == 0){ int ri; while(true){ ri = right.top(); right.pop(); if(ri > th) break; } remove_arr[ri] = 0; sum_right += a_arr[ri] - a_arr[th]; } left.push(th); int li = left.top(); left.pop(); sum_left += a_arr[th] - a_arr[li]; max_sum_diff = std::max(max_sum_diff, sum_left-sum_right); } std::cout << max_sum_diff << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:20:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 20 | std::sort(right_index.begin(), right_index.end(), [&](int l, int r){return a_arr[l]>a_arr[r];}); | ^~~~ | qsort
s966251063
p03714
C++
#ifdef _DEBUG #include "MyLib.h" #else #define main_D main #include "bits/stdc++.h" #include <regex> #define _USE_MATH_DEFINES #include <math.h> #define FOR(i,s,e) for (int i = int(s); i < int(e); ++i) #define REP(i,e) FOR(i,0,e) #define INF (INT_MAX/2) #define EPS (1.0e-8) #define LINF (LONGLONG_MAX/2) const int MGN = 8; const int ARY_SZ_MAX = 10000000; using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>; // functions template <typename T> using priority_queue_lo = priority_queue<T, vector<T>, greater<T>>; #endif int main_D() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vl A(N*3); REP(i, N*3) cin >> A[i]; priority_queue_lo<ll> pql; ll sum1 = 0; REP(i, N) { pql.push(A[i]); sum1 += A[i]; } priority_queue<ll> pq; ll sum2 = 0; FOR(i, N*2, N*3) { pq.push(A[i]); sum2 += A[i]; } vl sumL(N+1,0); sumL[0] = sum1; FOR(k,N,2*N) { pql.push(A[k]); sum1 += A[k]; sum1 -= pql.top(); sumL[k-N+1] = sum1; pql.pop(); } vl sumR(N+1,0); sumR[N] = sum2; for (int k = 2 * N - 1; k >= N; k--) { pq.push(A[k]); sum2 += A[k]; sum2 -= pq.top(); sumR[k-N] = sum2; pq.pop(); } ll ans = -LINF; REP(i,N) { ans = max(ans, sumL[i] - sumR[i]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:15: error: 'LONGLONG_MAX' was not declared in this scope; did you mean 'LONG_LONG_MAX'? 13 | #define LINF (LONGLONG_MAX/2) | ^~~~~~~~~~~~ a.cc:71:15: note: in expansion of macro 'LINF' 71 | ll ans = -LINF; | ^~~~
s558060428
p03714
C++
#include<bits/stdc++.h> using namespace std; #define int long long #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif signed main(){ int n; cin >> n; n *= 3; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } priority_queue<int,vector<int>,greater<int>> q1; priority_queue<int> q2; vector<int> dp1(n),dp2(n); for(int i = 0; i < n*2/3; i++){ if(i < n/3){ q1.push(a[i]); dp1[i] = a[i] + (i == 0 ? 0 : dp1[i-1]); } else { q1.push(a[i]); dp1[i] = dp1[i-1] + a[i] - q1.top(); q1.pop(); } } for(int i = n-1; i >= n/3; i--){ if(n*2/3 <= i){ q2.push(a[i]); dp2[i] = a[i] + (i == n-1 ? 0 : dp2[i+1]); } else { q2.push(a[i]); dp2[i] = dp2[i+1] + a[i] - q2.top(); q2.pop(); } } cout << dp1 << endl; cout << dp2 << endl; int ans = -(1 << 30); for(int i = n/3-1; i < n*2/3; i++){ ans = max(ans,dp1[i] - dp2[i+1]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:8: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<long long int>') 41 | cout << dp1 << endl; | ~~~~ ^~ ~~~ | | | | | std::vector<long long int> | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | operator<<(nullptr_t) | ^~~~~~~~ /usr/includ
s236021919
p03714
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) typedef long long ll; const ll INF = 1e15; int main(){ int n; cin >> n; ll a[3*n]; rep(i, 3*n) cin >> a[i]; ll suml[n+1], sumr[n+1]; suml[0] = 0, sumr[0] = 0; priority_queue<ll, greater<ll>> sl; priority_queue<ll> sr; rep(i, n){ sl.push(a[i]); suml += a[i]; sr.push(a[3*n-1-i]); sumr += a[3*n-i-1]; rep(i, n){ sl.push(a[n+i]); suml[i+1] = snml[i] + a[n+i] - sl.front(); sl.pop(); sr.push(a[2*n-1-i]); suml[i+1] = snml[i] + a[2*n-1-i] - sr.front(); sr.pop(); } ll ans = -INF; rep(i, n+1) ans = max(ans, suml[i]-sr[n-i]); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:32: error: no type named 'value_type' in 'struct std::greater<long long int>' 14 | priority_queue<ll, greater<ll>> sl; | ^~ a.cc:14:32: error: template argument 3 is invalid a.cc:17:8: error: request for member 'push' in 'sl', which is of non-class type 'int' 17 | sl.push(a[i]); suml += a[i]; | ^~~~ a.cc:17:25: error: incompatible types in assignment of 'll' {aka 'long long int'} to 'll [(n + 1)]' {aka 'long long int [(n + 1)]'} 17 | sl.push(a[i]); suml += a[i]; | ~~~~~^~~~~~~ a.cc:18:31: error: incompatible types in assignment of 'll' {aka 'long long int'} to 'll [(n + 1)]' {aka 'long long int [(n + 1)]'} 18 | sr.push(a[3*n-1-i]); sumr += a[3*n-i-1]; | ~~~~~^~~~~~~~~~~~~ a.cc:20:8: error: request for member 'push' in 'sl', which is of non-class type 'int' 20 | sl.push(a[n+i]); | ^~~~ a.cc:21:17: error: 'snml' was not declared in this scope; did you mean 'suml'? 21 | suml[i+1] = snml[i] + a[n+i] - sl.front(); | ^~~~ | suml a.cc:21:39: error: request for member 'front' in 'sl', which is of non-class type 'int' 21 | suml[i+1] = snml[i] + a[n+i] - sl.front(); | ^~~~~ a.cc:22:8: error: request for member 'pop' in 'sl', which is of non-class type 'int' 22 | sl.pop(); | ^~~ a.cc:24:43: error: 'class std::priority_queue<long long int>' has no member named 'front' 24 | suml[i+1] = snml[i] + a[2*n-1-i] - sr.front(); | ^~~~~ a.cc:28:40: error: no match for 'operator[]' (operand types are 'std::priority_queue<long long int>' and 'int') 28 | rep(i, n+1) ans = max(ans, suml[i]-sr[n-i]); | ^ a.cc:31:2: error: expected '}' at end of input 31 | } | ^ a.cc:7:11: note: to match this '{' 7 | int main(){ | ^
s284723914
p03714
C++
from heapq import* n,*a=map(int,open(0).read().split()) #print(a) ans=-float("inf") for i in range(n,2*n+1): score=0 tmp=a[:i] heapify(tmp) # print(tmp) for j in range(i-n): heappop(tmp) score+=sum(tmp) tmp=a[i:] heapify(tmp) # print(tmp) score-=sum(heappop(tmp)for r in range(n)) ans=max(score,ans) print(ans)
a.cc:3:2: error: invalid preprocessing directive #print 3 | #print(a) | ^~~~~ a.cc:9:6: error: invalid preprocessing directive #print 9 | # print(tmp) | ^~~~~ a.cc:15:6: error: invalid preprocessing directive #print 15 | # print(tmp) | ^~~~~ a.cc:1:1: error: 'from' does not name a type 1 | from heapq import* | ^~~~
s735024444
p03714
C++
#include <bits/stdc++.h> using namespace std; using ll = long long int; const int MAX = (int)(1e5 + 5); const ll INF = (ll)(1e10 + 5); int n; ll a[3 * MAX_N]; priority_queue<ll, vector<ll>, greater<ll>> leftpq; priority_queue<ll> rightpq; ll l, r; ll scorel[3 * MAX_N]; ll scorer[3 * MAX_N]; ll ans; int main(void){ // Here your code ! scanf("%d", &n); for (int i = 0; i < 3 * n; ++i) { scanf("%lld", &a[i]); } for (int i = 0; i < n; ++i) { leftpq.push(a[i]); l += a[i]; } scorel[n] = l; for (int i = 3 * n - 1; i >= 2 * n; --i) { rightpq.push(a[i]); r += a[i]; } scorer[2 * n] = r; for (int i = n; i < 2 * n; ++i) { leftpq.push(a[i]); l += a[i]; l -= leftpq.top(); leftpq.pop(); scorel[i + 1] = l; } for (int i = 2 * n - 1; i >= n; --i) { rightpq.push(a[i]); r += a[i]; r -= rightpq.top(); rightpq.pop(); scorer[i] = r; } ans = scorel[n] - scorer[n]; for (int i = n; i <= 2 * n; ++i) { ans = max(ans, scorel[i] - scorer[i]); } printf("%lld\n", ans); return 0; }
a.cc:10:10: error: 'MAX_N' was not declared in this scope; did you mean 'MAX'? 10 | ll a[3 * MAX_N]; | ^~~~~ | MAX a.cc:16:15: error: 'MAX_N' was not declared in this scope; did you mean 'MAX'? 16 | ll scorel[3 * MAX_N]; | ^~~~~ | MAX a.cc:17:15: error: 'MAX_N' was not declared in this scope; did you mean 'MAX'? 17 | ll scorer[3 * MAX_N]; | ^~~~~ | MAX a.cc: In function 'int main()': a.cc:24:22: error: 'a' was not declared in this scope 24 | scanf("%lld", &a[i]); | ^ a.cc:28:19: error: 'a' was not declared in this scope 28 | leftpq.push(a[i]); | ^ a.cc:31:5: error: 'scorel' was not declared in this scope 31 | scorel[n] = l; | ^~~~~~ a.cc:34:20: error: 'a' was not declared in this scope 34 | rightpq.push(a[i]); | ^ a.cc:37:5: error: 'scorer' was not declared in this scope 37 | scorer[2 * n] = r; | ^~~~~~ a.cc:40:19: error: 'a' was not declared in this scope 40 | leftpq.push(a[i]); | ^ a.cc:48:20: error: 'a' was not declared in this scope 48 | rightpq.push(a[i]); | ^
s534001951
p03714
C++
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0;i < n;i++) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()) #define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート #define ll long long #define pb(a) push_back(a) #define INF 1000000000 #define MOD 1000000007 #define int ll using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; typedef vector<unsigned int>vec; typedef vector<vec> mat; typedef tuple<ll, ll, ll> T; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n;cin>>n; vector<int> v(3*n); REP(i,3*n) cin>>v[i]; priority_queue<int, vector<int>,greater<int>> lque; priority_queue<int, vector<int>> sque; int ls=0,ss=0; vector<int> lv; vector<int> sv; REP(i,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,n){ lque.push(v[n+i]); sque.push(v[2*n-i-1]); ls += v[n+i] - lque.top(); ss += v[2*n - i - 1] - sque.top(); lv.push_back(ls); sv.push_back(ss); sque.pop(); lque.pop(); } REP(i,lv.size()) ans=max(ans,lv[i]-sv[n-i]); cout<<ans<<endl; }
cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:43:19: warning: integer overflow in expression of type 'int' results in '1486618624' [-Woverflow] 43 | int ans = -INF*INF; | ^
s920819761
p03714
C++
#define debug_interval ',' #define dump_interval ' ' #define debug_toggle 1 //{ #include<bits/stdc++.h> using namespace std; #define int long long #define INT_MAX LLONG_MAX #define INT_MIN LLONG_MIN #define rep(i,n) for(int i=0;i<(n);i++) #define rep1(i,n) for(int i=1;i<=(n);i++) #define pb push_back #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define fi first #define se second #define mp make_pair #define rev reverse #define dans dump(ans) #define MOD 1000000007 #define amp(v,n) (v).count(n)?v[n]++:v[n]=1; #define cni cin //{ 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();} template<class...A> inline void dump(){cout<<endl;} template<class...A> inline void dump_rest() {cout<<endl;} template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);} template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);} template<class...A> inline void debug(){cerr<<endl;} template<class...A> inline void debug_rest() {cerr<<endl;} template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);} template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);} //} typedef vector<int>vint; typedef pair<int,int>pint; typedef vector<pint>vpint; template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;} template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;} template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}}; //} int n,l,r,ans=INT_MIN; map<pint> li,ri; priority_queue<pint,vector<pint>,greater<pint> > le; priority_queue<int> re; vector<pint> gomi; main(){ cin>>n; int a[3*n]; rep(i,3*n)cin>>a[i]; int rui[3*n+1]; rep(i,3*n)rui[i+1]=a[i]; rep(i,n){ li.insert(mp(i,a[i])); le.push_back(mp(a[i],i)); } for(int i=n;i<3*n;i++){ ri.insert(mp(i,a[i])); re.push_back(mp(a[i],i)); } l=rui[n]-rui[0]; r=rui[3*n+1]-rui[n]; for(int i=0;i<n;i++){ } }
a.cc:8:9: warning: "INT_MAX" redefined 8 | #define INT_MAX LLONG_MAX | ^~~~~~~ In file included from /usr/include/c++/14/climits:42, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:38, from a.cc:5: /usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:120:9: note: this is the location of the previous definition 120 | #define INT_MAX __INT_MAX__ | ^~~~~~~ a.cc:9:9: warning: "INT_MIN" redefined 9 | #define INT_MIN LLONG_MIN | ^~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:118:9: note: this is the location of the previous definition 118 | #define INT_MIN (-INT_MAX - 1) | ^~~~~~~ a.cc:48:9: error: wrong number of template arguments (1, should be at least 2) 48 | map<pint> li,ri; | ^ In file included from /usr/include/c++/14/map:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152: /usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 53 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:60:12: error: request for member 'insert' in 'li', which is of non-class type 'int' 60 | li.insert(mp(i,a[i])); | ^~~~~~ a.cc:61:12: error: 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' has no member named 'push_back' 61 | le.push_back(mp(a[i],i)); | ^~~~~~~~~ a.cc:64:12: error: request for member 'insert' in 'ri', which is of non-class type 'int' 64 | ri.insert(mp(i,a[i])); | ^~~~~~ a.cc:65:12: error: 'class std::priority_queue<long long int>' has no member named 'push_back' 65 | re.push_back(mp(a[i],i)); | ^~~~~~~~~
s901519593
p03714
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int> a(n),b(n),c(n); int amin=1000000001,cmax=0; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n;i++){ cin>>b[i]; } for(int i=0;i<n;i++){ cin>>c[i]; } sort(a.begin(),a.end()); sort(c.begin(),c.end()); int aa=0,cc=b.size()-1; for(int i=0;i<n;i++){ if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ if(a.front-b[aa]>b[cc]-c.end()) aa++; else cc--; }else if(a.front()-b[aa]<b[cc]-c.back()){ a.front()=b[aa]; sort(a.begin(),a.end()); aa++; }else{ c.back()=b[cc]; sort(c.begin(),c.end()); cc--; } } long long aaa=0,ccc=0; for(int i=0;i<n;i++){ aaa+=a[i]; ccc+=c[i]; } cout<<aaa-ccc; }
a.cc: In function 'int main()': a.cc:21:15: error: invalid operands of types '<unresolved overloaded function type>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to binary 'operator-' 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ a.cc:21:31: error: no match for 'operator-' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::iterator') 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ 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:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::reverse_iterator<_Iterator>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::move_iterator<_IteratorL>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::complex<_Tp>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::complex<_Tp>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:21:38: note: 'std::vector<int>::iterator' is not derived from 'const std::complex<_Tp>' 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:21:38: note: 'std::vector<int>::iterator' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:21:38: note: 'std::vector<int>::iterator' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::valarray<_Tp>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:21:38: note: mismatched types 'const std::valarray<_Tp>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 21 | if(a.front-b[aa]>=0&&b[cc]-c.end()>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DE
s073447336
p03714
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int> a(n),b(n),c(n); int amin=1000000001,cmax=0; for(int i=0;i<n;i++){ cin>>a[i]; amin=min(amin,a[i]); } for(int i=0;i<n;i++){ cin>>b[i]; } for(int i=0;i<n;i++){ cin>>c[i]; cmax=max(cmax,c[i]); }
a.cc: In function 'int main()': a.cc:18:4: error: expected '}' at end of input 18 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s668790413
p03714
C++
#include<bits/stdc++.h> #define rep(i,n) for (int i=0;i<(int)(n);i++) #define INF (1<<30) #define ll long long using namespace std; ll f(vector<int> a,vector<ll>s,int t){ int e=a.size(); int n=e/3; sort(&a[0],&a[t]); sort(&a[t],&a[e],greater<int>()); //rep(i,7)cout<<s[i]<<endl; ll ret=s[t]; //cout<<ret<<endl; rep(i,t-n)ret-=a[i]; //cout<<ret<<endl; ret-=s[3*n]-s[t]; //cout<<ret<<endl; rep(i,2*n-t)ret+=a[t+i]; //cout<<ret<<endl; return ret; } int main(){ int n; cin>>n; vector<int> a vector<ll>s; s.push_back(0); rep(i,3*n){int t; cin>>t; a.push_back(t);s.push_back(s.back()+t);} ll ans=-INF;//f(a,s,3); for (int i=n;i<=2*n;i++) ans=max(ans,f(a,s,i)); cout<<ans<<endl;; return 0; }
a.cc: In function 'int main()': a.cc:30:3: error: expected initializer before 'vector' 30 | vector<ll>s; | ^~~~~~ a.cc:31:3: error: 's' was not declared in this scope 31 | s.push_back(0); | ^ a.cc:32:29: error: 'a' was not declared in this scope 32 | rep(i,3*n){int t; cin>>t; a.push_back(t);s.push_back(s.back()+t);} | ^ a.cc:34:42: error: 'a' was not declared in this scope 34 | for (int i=n;i<=2*n;i++) ans=max(ans,f(a,s,i)); | ^
s644561614
p03714
C++
#include<bits/stdc++.h> #define rep(i,n) for (int i=0;i<(int)(n);i++) #define INF (1<<30) #define ll long long using namespace std; ll f(vector<int> a,vector<ll>s,int t){ int e=a.size(); int n=e/3; sort(&a[0],&a[t]); sort(&a[t],&a[e],greater<int>()); //rep(i,7)cout<<s[i]<<endl; ll ret=s[t]; //cout<<ret<<endl; rep(i,t-n)ret-=a[i]; //cout<<ret<<endl; ret-=s[3*n]-s[t]; //cout<<ret<<endl; rep(i,2*n-t)ret+=a[t+i]; //cout<<ret<<endl; return ret; } int main(){ int n; cin>>n; vector<int> a vecotr<ll>s; s.push_back(0); rep(i,3*n){int t; cin>>t; a.push_back(t);s.push_back(s.back()+t);} ll ans=-INF;//f(a,s,3); for (int i=n;i<=2*n;i++) ans=max(ans,f(a,s,i)); cout<<ans<<endl;; return 0; }
a.cc: In function 'int main()': a.cc:30:3: error: expected initializer before 'vecotr' 30 | vecotr<ll>s; | ^~~~~~ a.cc:31:3: error: 's' was not declared in this scope 31 | s.push_back(0); | ^ a.cc:32:29: error: 'a' was not declared in this scope 32 | rep(i,3*n){int t; cin>>t; a.push_back(t);s.push_back(s.back()+t);} | ^ a.cc:34:42: error: 'a' was not declared in this scope 34 | for (int i=n;i<=2*n;i++) ans=max(ans,f(a,s,i)); | ^
s160630549
p03714
C
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <queue> #include <stack> #include <map> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const ll Inf = 1 << 30; const int maxx = 1e3 + 8; priority_queue <ll> qua; priority_queue <ll, vector<ll>, greater<ll> > que; int n; ll a[maxx * 3]; ll suml[maxx / 2], sumr[maxx / 2]; ll s1, s2; map <ll, bool> vis; int main() { /*ll ss[6] = {0, 2, 4, 5, 3, 1}; for(int i = 1; i <= 5; i++) que.push(ss[i]); while(!que.empty()) { cout << que.top() << endl; que.pop(); //1 2 3 4 5 //qua.pop(); //5 4 3 2 1 }*/ vis.clear(); scanf("%d", &n); for(int i = 1; i <= n * 3; i++) { scanf("%I64d", &a[i]); if(i <= n) { s1 += a[i]; que.push(a[i]); } else if(i >= 2 * n + 1) { s2 += a[i]; qua.push(a[i]); } } int L = n, R = 2 * n + 1; suml[L] = s1, sumr[R] = s2; for(int i = n + 1; i <= n * 2; i++) { if(a[i] > que.top()) { vis[a[i]] = 1; s1 -= que.top(); s1 += a[i]; que.pop(); que.push(a[i]); suml[i] = s1; } } int tmpsum = s2; for(int i = n * 2; i >= n + 1; i--) { if(a[i] < qua.top()) { if(vis[a[i]]) { sumr[i] = tmpsum; continue; } s2 -= qua.top(); s2 += a[i]; qua.pop(); qua.push(a[i]); sumr[i] = s2; } } ll ans = -Inf; /*for(int i = n + 1; i <= n * 2; i++) { cout << suml[i] << " " << sumr[i] << endl; }*/ for(int i = n + 1; i <= n * 2; i++) ans = max(ans, suml[i] - sumr[i]); cout << ans << endl; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s043042896
p03714
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<string> #include<iomanip> #include<map> #include<vector> #include<set> #include<queue> #include<stack> #define FAST ios::sync_with_stdio(false) #define lowbit(x) x&(-x) typedef long long ll; const int inf = 0x3f3f3f3f; const int mod = (int)1e9 + 7; const int maxn = (int)1e5 + 5; using namespace std; priority_queue <ll, vector<ll>, greater<ll> > q1;//小的在前 priority_queue <ll> q2;//大的在前 ll a[maxn * 3]; ll l[maxn * 3], r[maxn * 3];//维护l最大,r最小 int main() { int n; scanf("%d", &n); for(int i = 1; i <= 3 * n; i++){ scanf("%lld", &a[i]); } ll sum = 0; for(int i = 1; i <= 3 * n; i++){ q1.push(a[i]); sum += a[i], l[i] = sum; if(q1.size() > n){ sum -= q1.top(); q1.pop(); l[i] = sum; } } //--------------------------------------- sum = 0; for(int i = 3 * n; i >= 1; i--){ q2.push(a[i]); sum += a[i], r[i] = sum; if(q2.size() > n){ sum -= q2.top(); q2.pop(); r[i] = sum; } } ll ans = -inf; for(int i = n; i <= 2 * n; i++){ ans = max(ans, l[i] - r[i+1]);//left - right } printf("%lld\n", ans); return 0; } /*int sum(int x){ int ret = 0; for( ; x > 0; ret += c[x], x -= lowbit(x)); return ret; } void update(int x, int val){ for ( ; x <= n; c[x] += val, x += lowbit(x)); }
a.cc:63:1: error: unterminated comment 63 | /*int sum(int x){ | ^
s303810780
p03714
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<string> #include<iomanip> #include<map> #include<vector> #include<set> #include<queue> #include<stack> #define FAST ios::sync_with_stdio(false) #define lowbit(x) x&(-x) typedef long long ll; const int inf = 0x3f3f3f3f; const int mod = (int)1e9 + 7; const int maxn = (int)1e5 + 5; using namespace std; priority_queue <int, vector<int>, greater<int> > q1;//小的在前 priority_queue <int> q2;//大的在前 int a[maxn]; ll l[maxn], r[maxn];//维护l最大,r最小 int main() { int n; scanf("%d", &n); for(int i = 1; i <= 3 * n; i++){ scanf("%d", &a[i]); } ll sum = 0; for(int i = 1; i <= 3 * n; i++){ q1.push(a[i]); sum += a[i], l[i] = sum; if(q1.size() > n){ sum -= q1.top(); q1.pop(); l[i] = sum; } } //--------------------------------------- sum = 0; for(int i = 3 * n; i >= 1; i--){ q2.push(a[i]); sum += a[i], r[i] = sum; if(q2.size() > n){ sum -= q2.top(); q2.pop(); r[i] = sum; } } ll ans = -inf; for(int i = n; i <= 2 * n; i++){ ans = max(ans, l[i] - r[i+1]);//left - right } printf("%lld\n", ans); return 0; } /*int sum(int x){ int ret = 0; for( ; x > 0; ret += c[x], x -= lowbit(x)); return ret; } void update(int x, int val){ for ( ; x <= n; c[x] += val, x += lowbit(x)); }
a.cc:63:1: error: unterminated comment 63 | /*int sum(int x){ | ^
s751157473
p03714
C++
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i) #define REV(i, a) for (int i = (a); i >= 0; --i) #define CLR(a) memset((a), 0, sizeof(a)) #define DUMP(x) cerr << #x << " = " << (x) << endl; #define INF (3e15) using namespace std; int N; int A[3 * 100005]; signed main() { cin >> N; REP(i, N * 3) { cin >> A[i]; } int ans = -INF; FOR(k, N, 2 * N + 1) { priority_queue<int, vector<int>, greater<int>()> fque; int fsum = 0; REP(i, N) { fque.push(A[i]); fsum += A[i]; } FOR(i, N, k) { fsum += A[i]; fque.push(A[i]); int r = fque.top(); fque.pop(); fsum -= r; } priority_queue<int> sque; int ssum = 0; FOR(i, k, k + N) { sque.push(A[i]); ssum += A[i]; } FOR(i, k + N, 3 * N) { ssum += A[i]; sque.push(A[i]); int r = sque.top(); sque.pop(); ssum += r; } ans = max(ans, fsum - ssum); } return 0; }
In file included from /usr/include/c++/14/queue:66, from a.cc:16: /usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>': a.cc:46:58: required from here 46 | priority_queue<int, vector<int>, greater<int>()> fque; | ^~~~ /usr/include/c++/14/bits/stl_queue.h:538:18: error: data member 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::comp' invalidly declared function type 538 | _Compare comp; | ^~~~ a.cc: In function 'int main()': a.cc:46:58: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::priority_queue()' 46 | priority_queue<int, vector<int>, greater<int>()> fque; | ^~~~ /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 691 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 679 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 671 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 663 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 649 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 638 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 629 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 594 | priority_queue(priority_queue&& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 590 | priority_queue(const priority_queue& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 579 | priority_queue(const _Compare& __x, const _Sequence& __c, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 573 | priority_queue(const _Compare& __x, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 569 | priority_queue(const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Requires = _Seq; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 554 | priority_queue() | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:554:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_queue.h:551:43: error: no type named 'type' in 'struct std::enable_if<false, void>' 551 | template<typename _Seq = _Sequence, typename _Requires = typename | ^~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 563 | priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence()) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 558 | priority_queue(const _Compare& __x, const _Sequence& __s) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate expects 2 arguments, 0 provided /usr/
s605212056
p03714
C++
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i) #define REV(i, a) for (int i = (a); i >= 0; --i) #define CLR(a) memset((a), 0, sizeof(a)) #define DUMP(x) cerr << #x << " = " << (x) << endl; #define INF (3e15) using namespace std; int N; int A[3 * 100005]; signed main() { cin >> N; REP(i, N * 3) { cin >> A[i]; } int ans = -INF; FOR(k, N, 2 * N + 1) { priority_queue<int, vector<int>, greater<int>()> fque; int fsum = 0; REP(i, N) { fque.push(A[i]); fsum += A[i]; } FOR(i, N, k) { fsum += A[i]; fque.push(A[i]); int r = fque.top(); fque.pop(); fsum -= r; } priority_queue<int> sque; int ssum = 0; FOR(i, k, k + N) { sque.push(A[i]); ssum += A[i]; } FOR(i, k + N, 3 * N) { ssum += A[i]; sque.push(A[i]); int r = sque.top(); sque.pop(); ssum += r; } ans = max(ans, fsum - ssum); } return 0; }
In file included from /usr/include/c++/14/queue:66, from a.cc:16: /usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>': a.cc:46:58: required from here 46 | priority_queue<int, vector<int>, greater<int>()> fque; | ^~~~ /usr/include/c++/14/bits/stl_queue.h:538:18: error: data member 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::comp' invalidly declared function type 538 | _Compare comp; | ^~~~ a.cc: In function 'int main()': a.cc:46:58: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::priority_queue()' 46 | priority_queue<int, vector<int>, greater<int>()> fque; | ^~~~ /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 691 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 679 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 671 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 663 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 649 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 638 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 629 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 594 | priority_queue(priority_queue&& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 590 | priority_queue(const priority_queue& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 579 | priority_queue(const _Compare& __x, const _Sequence& __c, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 573 | priority_queue(const _Compare& __x, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 569 | priority_queue(const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Requires = _Seq; _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 554 | priority_queue() | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:554:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_queue.h:551:43: error: no type named 'type' in 'struct std::enable_if<false, void>' 551 | template<typename _Seq = _Sequence, typename _Requires = typename | ^~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 563 | priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence()) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]' 558 | priority_queue(const _Compare& __x, const _Sequence& __s) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate expects 2 arguments, 0 provided /usr/
s286173459
p03714
C++
#include <stdio.h> #include <queue> #include <algorithm> using namespace std; #define REP(a, i, n) for (int i = a; i < n; ++i) #define RREP(n, i, a) for (int i = n - 1; i >= a; --i) int main() { int N; scanf("%d", &N); int _3N = 3 * N; int a[_3N]; REP(0, i, _3N) { scanf("%d", &a[i]); } // Red priority_queue<int, vector<int>, greater<int> > red_q; long red_sum = 0; REP(0, i, N) { red_q.push(a[i]); red_sum += a[i]; } long red_sum_v[_3N]; red_sum_v[N - 1] = red_sum; int _2N = 2 * N; REP(N, i, _2N) { long ai = a[i]; long red_t = red_q.top(); if (ai > red_t) { red_q.pop(); red_q.push(ai); red_sum += ai - red_t; } red_sum_v[i] = red_sum; } // Blue priority_queue<int> blue_q; long blue_sum = 0; REP(_2N, i, _3N) { blue_q.push(a[i]); blue_sum += a[i]; } long blue_sum_v[_3N]; blue_sum_v[_2N] = blue_sum; RREP(_2N, i, N) { long ai = a[i]; long blue_t = blue_q.top(); if (ai < blue_t) { blue_q.pop(); blue_q.push(ai); blue_sum += ai - blue_t; } blue_sum_v[i] = blue_sum; } long ans = LONG_MIN; REP(N, i, _2N + 1) { // printf("%ld - %ld = %ld\n", red_sum_v[i - 1], blue_sum_v[i], red_sum_v[i - 1] - blue_sum_v[i]); ans = max(ans, red_sum_v[i - 1] - blue_sum_v[i]); } printf("%ld\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:63:16: error: 'LONG_MIN' was not declared in this scope 63 | long ans = LONG_MIN; | ^~~~~~~~ a.cc:4:1: note: 'LONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <algorithm> +++ |+#include <climits> 4 |
s468673042
p03714
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<string> #include<algorithm> #include<stack> #include<map> #include<deque> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define rrep(i,a,b)for(int i=a;i<b;i++) #define mp make_pair #define pb push_back #define ll __int64 //#define __int64 long long #define P pair<int,int> int n; int a[400000]; ll a1[300000]; ll a2[300000]; priority_queue<ll,vector<ll>,greater<ll> >q1; priority_queue<ll>q2; ll s1,s2; int main(){ cin>>n; rep(i,3*n)cin>>a[i]; rep(i,n){s1+=a[i];q1.push(a[i]);} a1[0]=s1; q1.push(a[n]); s1+=a[n]; rrep(i,2*n,3*n){s2+=a[i];q2.push(a[i]);} a2[n]=s2; q2.push(a[2*n-1]); s2+=a[2*n-1]; for(int i=2*n-2;i>=n-1;i--){ ll tmp=q2.top(); q2.pop(); s2-=tmp; //cout<<i-n+1<<" "<<s2<<endl; a2[i-n+1]=s2; s2+=a[i]; q2.push(a[i]); } rrep(i,n+1,2*n+1){ ll tmp=q1.top(); q1.pop(); s1-=tmp; //cout<<i-n<<" "<<s1<<endl; a1[i-n]=s1; s1+=a[i]; q1.push(a[i]); } ll ans=a1[0]-a2[0]; rep(i,n)ans=max(ans,a1[i]-a2[i]); cout<<ans<<endl; return 0; }
a.cc:17:12: error: '__int64' does not name a type; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:22:1: note: in expansion of macro 'll' 22 | ll a1[300000]; | ^~ a.cc:17:12: error: '__int64' does not name a type; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:23:1: note: in expansion of macro 'll' 23 | ll a2[300000]; | ^~ a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:24:16: note: in expansion of macro 'll' 24 | priority_queue<ll,vector<ll>,greater<ll> >q1; | ^~ a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:24:26: note: in expansion of macro 'll' 24 | priority_queue<ll,vector<ll>,greater<ll> >q1; | ^~ a.cc:24:28: error: template argument 1 is invalid 24 | priority_queue<ll,vector<ll>,greater<ll> >q1; | ^ a.cc:24:28: error: template argument 2 is invalid a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:24:38: note: in expansion of macro 'll' 24 | priority_queue<ll,vector<ll>,greater<ll> >q1; | ^~ a.cc:24:40: error: template argument 1 is invalid 24 | priority_queue<ll,vector<ll>,greater<ll> >q1; | ^ a.cc:24:42: error: template argument 1 is invalid 24 | priority_queue<ll,vector<ll>,greater<ll> >q1; | ^ a.cc:24:42: error: template argument 2 is invalid a.cc:24:42: error: template argument 3 is invalid a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:25:16: note: in expansion of macro 'll' 25 | priority_queue<ll>q2; | ^~ a.cc:25:18: error: template argument 1 is invalid 25 | priority_queue<ll>q2; | ^ a.cc:25:18: error: template argument 2 is invalid a.cc:25:18: error: template argument 3 is invalid a.cc:17:12: error: '__int64' does not name a type; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:26:1: note: in expansion of macro 'll' 26 | ll s1,s2; | ^~ a.cc: In function 'int main()': a.cc:31:18: error: 's1' was not declared in this scope; did you mean 'q1'? 31 | rep(i,n){s1+=a[i];q1.push(a[i]);} | ^~ | q1 a.cc:31:30: error: request for member 'push' in 'q1', which is of non-class type 'int' 31 | rep(i,n){s1+=a[i];q1.push(a[i]);} | ^~~~ a.cc:32:9: error: 'a1' was not declared in this scope; did you mean 'q1'? 32 | a1[0]=s1; | ^~ | q1 a.cc:32:15: error: 's1' was not declared in this scope; did you mean 'q1'? 32 | a1[0]=s1; | ^~ | q1 a.cc:33:12: error: request for member 'push' in 'q1', which is of non-class type 'int' 33 | q1.push(a[n]); | ^~~~ a.cc:36:25: error: 's2' was not declared in this scope; did you mean 'q2'? 36 | rrep(i,2*n,3*n){s2+=a[i];q2.push(a[i]);} | ^~ | q2 a.cc:36:37: error: request for member 'push' in 'q2', which is of non-class type 'int' 36 | rrep(i,2*n,3*n){s2+=a[i];q2.push(a[i]);} | ^~~~ a.cc:37:9: error: 'a2' was not declared in this scope; did you mean 'q2'? 37 | a2[n]=s2; | ^~ | q2 a.cc:37:15: error: 's2' was not declared in this scope; did you mean 'q2'? 37 | a2[n]=s2; | ^~ | q2 a.cc:38:12: error: request for member 'push' in 'q2', which is of non-class type 'int' 38 | q2.push(a[2*n-1]); | ^~~~ a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:42:17: note: in expansion of macro 'll' 42 | ll tmp=q2.top(); | ^~ a.cc:43:20: error: request for member 'pop' in 'q2', which is of non-class type 'int' 43 | q2.pop(); | ^~~ a.cc:44:21: error: 'tmp' was not declared in this scope; did you mean 'tm'? 44 | s2-=tmp; | ^~~ | tm a.cc:48:20: error: request for member 'push' in 'q2', which is of non-class type 'int' 48 | q2.push(a[i]); | ^~~~ a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:53:17: note: in expansion of macro 'll' 53 | ll tmp=q1.top(); | ^~ a.cc:54:20: error: request for member 'pop' in 'q1', which is of non-class type 'int' 54 | q1.pop(); | ^~~ a.cc:55:21: error: 'tmp' was not declared in this scope; did you mean 'tm'? 55 | s1-=tmp; | ^~~ | tm a.cc:59:20: error: request for member 'push' in 'q1', which is of non-class type 'int' 59 | q1.push(a[i]); | ^~~~ a.cc:17:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 17 | #define ll __int64 | ^~~~~~~ a.cc:61:9: note: in expansion of macro 'll' 61 | ll ans=a1[0]-a2[0]; | ^~ a.cc:62:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 62 | rep(i,n)ans=max(ans,a1[i]-a2[i]); | ^~~ | abs a.cc:63:15: error: 'ans' was not declared in this scope; did you mean 'abs'? 63 | cout<<ans<<endl; | ^~~ | abs
s374577397
p03714
C++
#include <iostream> #include <vector> #include <queue> using namespace std; int main(void) { int n; cin >> n; priority_queue<int, vector<int>, greater<int> > gq; priority_queue<int> lq; vector<int> mid(n); vector<ll> sumf(n + 1), sums(n + 1); int sum1 = 0, sum2 = 0; for (int i = 0; i < n; i++) { int a; cin >> a; gq.push(a); sum1 += a; } for (int i = 0; i < n; i++) { cin >> mid[i]; } for (int i = 0; i < n; i++) { int a; cin >> a; lq.push(a); sum2 += a; } sumf[0] = sum1; for (int i = 0; i < n; i++) { gq.push(mid[i]); sumf[i + 1] = sumf[i] + mid[i] - gq.top(); gq.pop(); } sums[n] = sum2; for (int i = n - 1; i >= 0; i--) { lq.push(mid[i]); sums[i] = sums[i + 1] + mid[i] - lq.top(); lq.pop(); } ll answer = sumf[n] - sums[n]; for (int i = 0; i < n; i++) { if (answer < sumf[i] - sums[i]) { answer = sumf[i] - sums[i]; } } cout << answer << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:10: error: 'll' was not declared in this scope; did you mean 'lq'? 11 | vector<ll> sumf(n + 1), sums(n + 1); | ^~ | lq a.cc:11:12: error: template argument 1 is invalid 11 | vector<ll> sumf(n + 1), sums(n + 1); | ^ a.cc:11:12: error: template argument 2 is invalid a.cc:28:7: error: invalid types 'int[int]' for array subscript 28 | sumf[0] = sum1; | ^ a.cc:31:9: error: invalid types 'int[int]' for array subscript 31 | sumf[i + 1] = sumf[i] + mid[i] - gq.top(); | ^ a.cc:31:23: error: invalid types 'int[int]' for array subscript 31 | sumf[i + 1] = sumf[i] + mid[i] - gq.top(); | ^ a.cc:34:7: error: invalid types 'int[int]' for array subscript 34 | sums[n] = sum2; | ^ a.cc:37:9: error: invalid types 'int[int]' for array subscript 37 | sums[i] = sums[i + 1] + mid[i] - lq.top(); | ^ a.cc:37:19: error: invalid types 'int[int]' for array subscript 37 | sums[i] = sums[i + 1] + mid[i] - lq.top(); | ^ a.cc:40:5: error: expected ';' before 'answer' 40 | ll answer = sumf[n] - sums[n]; | ^~~~~~~ | ; a.cc:42:9: error: 'answer' was not declared in this scope 42 | if (answer < sumf[i] - sums[i]) { | ^~~~~~ a.cc:42:22: error: invalid types 'int[int]' for array subscript 42 | if (answer < sumf[i] - sums[i]) { | ^ a.cc:42:32: error: invalid types 'int[int]' for array subscript 42 | if (answer < sumf[i] - sums[i]) { | ^ a.cc:43:20: error: invalid types 'int[int]' for array subscript 43 | answer = sumf[i] - sums[i]; | ^ a.cc:43:30: error: invalid types 'int[int]' for array subscript 43 | answer = sumf[i] - sums[i]; | ^ a.cc:46:11: error: 'answer' was not declared in this scope 46 | cout << answer << endl; | ^~~~~~
s556296417
p03714
C++
#include <iostream> #include <cstdio> #include <cstring> #include <climits> #define N 100000 using namespace std; // int pq[2*N+1] = {}; // int q_max = 0; int parent(int i){return((i-1)/2);} int lchild(int i){return(2*i+1);} int rchild(int i){return(2*i+2);} void display_queue(int *pq, int *q_max){ int j = 0; int b = 0; for (int i=0;i < *q_max;i++) { cout << pq[i] << " "; if (j==0 || j==(1<<b)) { cout << endl; b++; j=0; } j++; } cout << endl; } bool gt(int x, int y){ return(x > y); } bool lt(int x, int y){ return(x < y); } void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ pq[*q_max] = x; int idx = *q_max; (*q_max)++; while (idx > 0) { if (f(pq[idx], pq[parent(idx)])) { int tmp = pq[parent(idx)]; pq[parent(idx)] = pq[idx]; pq[idx] = tmp; idx = parent(idx); } else { return; } } } int pop(int *pq, int *q_max, function<bool(int, int)> f){ if (*q_max < 0) { cerr << "queue is empty." << endl; return 0; } int result = pq[0]; pq[0] = pq[--(*q_max)]; int idx = 0; while (lchild(idx) < *q_max) { if (f(pq[idx], pq[lchild(idx)]) && f(pq[idx], pq[rchild(idx)])) { return(result); } if (f(pq[lchild(idx)], pq[rchild(idx)])) { int tmp = pq[lchild(idx)]; pq[lchild(idx)] = pq[idx]; pq[idx] = tmp; idx = lchild(idx); } else { int tmp = pq[rchild(idx)]; pq[rchild(idx)] = pq[idx]; pq[idx] = tmp; idx = rchild(idx); } } return(result); } int main(){ int n; int a1_pq[N+1], a2[N+1], a3_pq[N+1]; int a1_pq_max = 0; int a3_pq_max = 0; long long a1_max[N+1], a3_min[N+1]; cin >> n; a1_max[0] = 0; a3_min[n] = 0; for (int i=0;i<n;i++) { int a; cin >> a; push(a, a1_pq, &a1_pq_max, lt); a1_max[0] += a; } for (int i=0;i<n;i++) { int a; cin >> a; a2[i] = a; } for (int i=0;i<n;i++) { int a; cin >> a; push(a, a3_pq, &a3_pq_max, gt); a3_min[n] += a; } for (int i=0;i<n;i++) { if (a1_pq[0] < a2[i]) { // cout << i << ":" << a1_pq[0] << "\t" << a2[i] << endl; a1_max[i+1] += a2[i] - a1_pq[0] + a1_max[i]; // cout << a1_max[i+1] << endl; pop(a1_pq, &a1_pq_max, lt); push(a2[i], a1_pq, &a1_pq_max, lt); } else { a1_max[i+1] = a1_max[i]; } } for (int i=n;i>0;i--) { if (a3_pq[0] > a2[i-1]) { // cout << i << ":" << a3_pq[0] << "\t" << a2[i-1] << endl; a3_min[i-1] += a2[i-1] - a3_pq[0] + a3_min[i]; // cout << a3_min[i-1] << endl; pop(a3_pq, &a3_pq_max, gt); push(a2[i], a3_pq, &a3_pq_max, gt); } else { a3_min[i-1] = a3_min[i]; } } long long result = LLONG_MIN; for (int i=0;i<=n;i++) { if (a1_max[i] - a3_min[i] > result) { result = a1_max[i] - a3_min[i]; } } cout << result << endl; /* for (int i=0;i<=n;i++) { cout << a3_min[i] << "\t"; } cout << endl;*/ }
a.cc:40:39: error: 'function' has not been declared 40 | void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:40:47: error: expected ',' or '...' before '<' token 40 | void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ | ^ a.cc: In function 'void push(int, int*, int*, int)': a.cc:45:9: error: 'f' was not declared in this scope 45 | if (f(pq[idx], pq[parent(idx)])) { | ^ a.cc: At global scope: a.cc:56:30: error: 'function' has not been declared 56 | int pop(int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:56:38: error: expected ',' or '...' before '<' token 56 | int pop(int *pq, int *q_max, function<bool(int, int)> f){ | ^ a.cc: In function 'int pop(int*, int*, int)': a.cc:65:9: error: 'f' was not declared in this scope 65 | if (f(pq[idx], pq[lchild(idx)]) && f(pq[idx], pq[rchild(idx)])) { | ^ a.cc:68:9: error: 'f' was not declared in this scope 68 | if (f(pq[lchild(idx)], pq[rchild(idx)])) { | ^ a.cc: In function 'int main()': a.cc:96:32: error: invalid conversion from 'bool (*)(int, int)' to 'int' [-fpermissive] 96 | push(a, a1_pq, &a1_pq_max, lt); | ^~ | | | bool (*)(int, int) a.cc:40:39: note: initializing argument 4 of 'void push(int, int*, int*, int)' 40 | void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:107:32: error: invalid conversion from 'bool (*)(int, int)' to 'int' [-fpermissive] 107 | push(a, a3_pq, &a3_pq_max, gt); | ^~ | | | bool (*)(int, int) a.cc:40:39: note: initializing argument 4 of 'void push(int, int*, int*, int)' 40 | void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:115:30: error: invalid conversion from 'bool (*)(int, int)' to 'int' [-fpermissive] 115 | pop(a1_pq, &a1_pq_max, lt); | ^~ | | | bool (*)(int, int) a.cc:56:30: note: initializing argument 3 of 'int pop(int*, int*, int)' 56 | int pop(int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:116:38: error: invalid conversion from 'bool (*)(int, int)' to 'int' [-fpermissive] 116 | push(a2[i], a1_pq, &a1_pq_max, lt); | ^~ | | | bool (*)(int, int) a.cc:40:39: note: initializing argument 4 of 'void push(int, int*, int*, int)' 40 | void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:126:30: error: invalid conversion from 'bool (*)(int, int)' to 'int' [-fpermissive] 126 | pop(a3_pq, &a3_pq_max, gt); | ^~ | | | bool (*)(int, int) a.cc:56:30: note: initializing argument 3 of 'int pop(int*, int*, int)' 56 | int pop(int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~ a.cc:127:38: error: invalid conversion from 'bool (*)(int, int)' to 'int' [-fpermissive] 127 | push(a2[i], a3_pq, &a3_pq_max, gt); | ^~ | | | bool (*)(int, int) a.cc:40:39: note: initializing argument 4 of 'void push(int, int*, int*, int)' 40 | void push(int x, int *pq, int *q_max, function<bool(int, int)> f){ | ^~~~~~~~
s059128851
p03714
C++
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <map> #include <set> #include <string> #include <cmath> #include <numeric> #include <iostream> using namespace std; #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define RFOR(i, a, b) for(int i = (a); i > (b); i--) #define rep(i, n) for(int i = 0; i < (n); i++) #define all(c) begin(c), end(c) #define rall(c) rbegin(c), rend(c) #define foritr(itr, c) for(auto itr = begin(c); itr != end(c); itr++) #define SZ(a) ((ll) a.size()) typedef long long int ll; typedef long long unsigned int llu; void solve(ll N, vector <ll> a) { ll mae[N + 1] = { }; ll usiro[N + 1] = { }; vector <ll> tmpcopy(3 * N); vector <ll> rev(3 * N); copy(all(a), begin(rev)); reverse(all(rev)); rep(i, N + 1) { copy(all(a), begin(tmpcopy)); sort(begin(tmpcopy), begin(tmpcopy) + N + i, greater <ll>()); mae[i] = accumulate(begin(tmpcopy), begin(tmpcopy) + N, 0); } rep(i, N + 1) { copy(all(rev), begin(tmpcopy)); sort(begin(tmpcopy), begin(tmpcopy) + N + i); usiro[i] = accumulate(begin(tmpcopy), begin(tmpcopy) + N, 0); } ll tmp = LLONG_MIN; rep(i, N + 1) { if(mae[i] - usiro[N - i] > tmp) tmp = mae[i] - usiro[N - i]; } printf("%lld", tmp); } int main() { ll N; scanf("%lld", &N); vector <ll> a(3 * N - 1 + 1); for(int i = 0; i <= 3 * N - 1; i++) { scanf("%lld", &a[i]); } solve(N, a); return 0; }
a.cc: In function 'void solve(ll, std::vector<long long int>)': a.cc:45:18: error: 'LLONG_MIN' was not declared in this scope 45 | ll tmp = LLONG_MIN; | ^~~~~~~~~ a.cc:13:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 12 | #include <iostream> +++ |+#include <climits> 13 |
s646968382
p03714
Java
import java.io.*; import java.util.*; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static void solve() { int n = ni(); int[] a = new int[3*n]; for(int i = 0; i < 3*n; i++){ a[i] = ni(); } long res = 0; long ans = Long.MIN_VALUE; for(int k = 0; k <= n; k++){ int[] b = new int[n+k]; int[] c = new int[2*n-k]; for(int i = 0; i < n + k; i++){ b[i] = a[i]; } Arrays.sort(b); for(int i = 0; i < 2*n-k; i++){ c[i] = a[i+n+k]; } Arrays.sort(c); for(int i = 0; i < n; i++){ res += b[n+k-i-1] - c[i];m } ans = Math.max(ans, res); res = 0; } out.println(ans); } public static void main(String[] args) throws Exception { long S = System.currentTimeMillis(); is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); solve(); out.flush(); long G = System.currentTimeMillis(); tr(G-S+"ms"); } private static boolean eof() { if(lenbuf == -1)return true; int lptr = ptrbuf; while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false; try { is.mark(1000); while(true){ int b = is.read(); if(b == -1){ is.reset(); return true; }else if(!isSpaceChar(b)){ is.reset(); return false; } } } catch (IOException e) { return true; } } private static byte[] inbuf = new byte[1024]; static int lenbuf = 0, ptrbuf = 0; private static int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } // private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); } private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private static double nd() { return Double.parseDouble(ns()); } private static char nc() { return (char)skip(); } private static String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b))){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private static char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private static int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private static int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); } private static int[] nsi(){ char[] s = ns().toCharArray(); int[] a = new int[s.length]; for(int j = 0; j < s.length; j++){ a[j] = s[j] - '0'; } return a; } }
Main.java:30: error: not a statement res += b[n+k-i-1] - c[i];m ^ Main.java:30: error: ';' expected res += b[n+k-i-1] - c[i];m ^ 2 errors
s555600230
p03714
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(void){ ll N; cin >> N; vector<ll> v(3*N); for(auto& it : v) cin >> it; ll ans = -1e20; for(ll t=N; t<=2*N-1;t++){ priority_queue<ll, less> left; priority_queue<ll, greater> right; for(ll i=0;i<t;i++) { left.push(v[i]); } for(ll i=t; i<3*N; i++) { right.push(v[i]); } ll tl=0,tr=0; for(ll i=0;i<N;i++){ tl += left.top(); left.pop(); tr += right.top(); right.pop(); } ans = max(ans, tl - tr); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:14: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '-1.0e+20' to '-9223372036854775808' [-Woverflow] 12 | ll ans = -1e20; | ^~~~~ a.cc:15:32: error: type/value mismatch at argument 2 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue' 15 | priority_queue<ll, less> left; | ^ a.cc:15:32: note: expected a type, got 'less' a.cc:15:32: error: template argument 3 is invalid a.cc:16:35: error: type/value mismatch at argument 2 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue' 16 | priority_queue<ll, greater> right; | ^ a.cc:16:35: note: expected a type, got 'greater' a.cc:16:35: error: template argument 3 is invalid a.cc:19:18: error: request for member 'push' in 'left', which is of non-class type 'int' 19 | left.push(v[i]); | ^~~~ a.cc:22:19: error: request for member 'push' in 'right', which is of non-class type 'int' 22 | right.push(v[i]); | ^~~~ a.cc:28:24: error: request for member 'top' in 'left', which is of non-class type 'int' 28 | tl += left.top(); left.pop(); | ^~~ a.cc:28:36: error: request for member 'pop' in 'left', which is of non-class type 'int' 28 | tl += left.top(); left.pop(); | ^~~ a.cc:29:25: error: request for member 'top' in 'right', which is of non-class type 'int' 29 | tr += right.top(); right.pop(); | ^~~ a.cc:29:38: error: request for member 'pop' in 'right', which is of non-class type 'int' 29 | tr += right.top(); right.pop(); | ^~~
s716305167
p03714
C++
3 8 2 2 7 4 6 5 3 8
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s883875565
p03714
C++
#include <iostream> #include <vector> #include <queue> #include <sstream> #include <algorithm> #include <bitset> #include <limits> #include <map> #include <set> #include <iomanip> #include <cmath> using namespace std; typedef long long int ll; typedef std::numeric_limits<double> dbl; const long long int LL_INF=1LL<<60; vector<string> split(const string& input, char delimiter) { stringstream stream(input); string field; vector<string> result; while (getline(stream, field, delimiter)) { result.push_back(field); } return result; } //#define DEBUG ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S; int main() { cin >> N; vector<ll> nums(3*N); for (auto &n : nums) cin >> n; if (N == 1) { cout << max( nums[0] - min(nums[1], nums[2]), max(nums[0], nums[1]) - nums[2] ) << endl; return 0; } vector<ll> former(nums.begin(), nums.begin()+N); ll fSum = accumulate(former.begin(), former.end(), 0); priority_queue< ll, vector<ll>, greater<ll> > fpq; for (auto l : former) fpq.push(l); ll maxScore = INT64_MIN; vector<ll>::iterator nItr = nums.begin()+N; for (int i = N; i < 2*N; ++i) { ll f = *(nItr); fpq.push(f); fSum += f - fpq.top(); fpq.pop(); cerr << endl << "step" << i << " " << fpq.size() << " " << fpq.top() << endl; cerr << "fsum : " << fSum << endl; vector<ll> latter(nums.rbegin(), nums.rbegin()+2*N-i+1); for (auto l : latter) cerr << " " << l; cerr << "<= latter" << endl; priority_queue<ll> lpq(less<ll>(), latter); ll lSum = accumulate(latter.begin(), latter.begin()+N, 0); auto lItr = latter.begin()+N; for (int j = 0; lItr < latter.end(); ++j) { ll l = *(lItr); lpq.push(l); lSum += l - lpq.top(); cerr << j << " : " << f << " " << l << endl; cerr << "lSum : " << lSum << endl; lpq.pop(); maxScore = max(maxScore, fSum - lSum); lItr++; } maxScore = max(maxScore, fSum-lSum); nItr++; //cerr << endl; } cout << maxScore << endl; return 0; }
a.cc: In function 'int main()': a.cc:50:15: error: 'accumulate' was not declared in this scope 50 | ll fSum = accumulate(former.begin(), former.end(), 0); | ^~~~~~~~~~ a.cc:55:19: error: 'INT64_MIN' was not declared in this scope 55 | ll maxScore = INT64_MIN; | ^~~~~~~~~
s545566674
p03714
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef priority_queue <ll> pq; typedef priority_queue <ll, vector <ll>, greater<ll> > pqr; int main(){ int N; cin>>N; vector <ll> a; pqr frt; pq bak; for(int i=0;i<3*N;i++){ ll aa; cin>>aa; a.push_back(aa); } ll sum1[111111]={0}, sum2[111111]={0}; for(int i=0;i<N;i++){ frt.push(a[i]); sum1[0]+=a[i]; } for(int i=2*N;i<3*N;i++){ bak.push(a[i]); sum2[N]+=a[i]; } for(int i=N;i<2*N;i++){ sum1[i-N+1]=sum1[i-N]; ll e=frt.top(); frt.pop(); sum1[i-N+1]-=e; sum1[i-N+1]+=a[i]; frt.push(a[i]); } for(int i=2*N-1;i>=N;i--){ sum2[i-N]=sum2[i-N+1]; ll e=bak.top(); bak.pop(); sum2[i-N]-=e; sum2[i-N]+=a[i]; bak.push(a[i]); } for(int i=0;i<i=N;i++){ if(sum1[i]>sum1[i+1]){ sum1[i+1]=sum1[i]; } if(sum2[i]>sum2[i+1]){ sum2[i]=sum2[i+1]; } } ll res=-1111111111111111111; for(int i=0;i<=N;i++){ res=max(res, sum1[i]-sum2[i]); } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:45:22: error: lvalue required as left operand of assignment 45 | for(int i=0;i<i=N;i++){ | ~^~
s281679359
p03714
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef priority_queue <ll> pq; typedef priority_queue <ll, vector<ll>, greater<ll> > rpq; int main(){ int N; cin>>N; rpq a1; pq a2; vector <ll> a; for(int i=0;i<3*N;i++){ ll aa; cin>>aa; a.push_back(aa); } ll sum1[100100]={0}, sum2[100100]={0}; for(int i=0;i<N;i++){ a1.push(a[i]); sum1[0]+=a[i]; } for(int i=2*N;i<3*N;i++){ a2.push(a[i]); sum2[N]+=a[i]; } for(int i=N;i<2*N;i++){ sum1[i-N+1]=sum1[i-N]; sum1[i-N+1]-=a1.top(); sum1[i-N+1]+=a[i]; a1.pop(); a1.push(a[i]); } for(int i=2*N-1;i>=N;i--){ sum2[i-N]=sum2[i-N+1]; sum2[i-N]-=a2.top(); sum2[i-N]+=a[i]; a2.pop(); a2.push(a[i]); } ll res=-1111111111111111111; for(int i=0;i<=N;i++){ //cout<<sum1[i]<<":"<<sum2[i]<<endl; res=max(sum1[i]-sum2[j], res); } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:49:38: error: 'j' was not declared in this scope 49 | res=max(sum1[i]-sum2[j], res); | ^
s687340815
p03714
C++
include<bits/stdc++.h> using namespace std; typedef long long ll; typedef priority_queue <ll> pq; typedef priority_queue <ll, vector<ll>, greater<ll> > rpq; int main(){ int N; cin>>N; rpq a1; pq a2; vector <ll> a; for(int i=0;i<3*N;i++){ ll aa; cin>>aa; a.push_back(aa); } ll sum1[10001]={0}, sum2[10001]={0}; for(int i=0;i<N;i++){ a1.push(a[i]); sum1[0]+=a[i]; } for(int i=2*N;i<3*N;i++){ a2.push(a[i]); sum2[N]+=a[i]; } for(int i=N;i<2*N;i++){ sum1[i-N+1]=sum1[i-N]; sum1[i-N+1]-=a1.top(); sum1[i-N+1]+=a[i]; a1.pop(); a1.push(a[i]); } for(int i=2*N-1;i>=N;i--){ sum2[i-N]=sum2[i-N+1]; sum2[i-N]-=a2.top(); sum2[i-N]+=a[i]; a2.pop(); a2.push(a[i]); } ll res=-1; for(int i=1;i<N;i++){ //cout<<sum1[i]<<":"<<sum2[i]<<endl; res=max(sum1[i]-sum2[i], res); } cout<<res<<endl; return 0; } ~
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc:6:9: error: 'priority_queue' does not name a type 6 | typedef priority_queue <ll> pq; | ^~~~~~~~~~~~~~ a.cc:7:9: error: 'priority_queue' does not name a type 7 | typedef priority_queue <ll, vector<ll>, greater<ll> > rpq; | ^~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:11:9: error: 'cin' was not declared in this scope 11 | cin>>N; | ^~~ a.cc:12:9: error: 'rpq' was not declared in this scope 12 | rpq a1; | ^~~ a.cc:13:9: error: 'pq' was not declared in this scope 13 | pq a2; | ^~ a.cc:14:9: error: 'vector' was not declared in this scope 14 | vector <ll> a; | ^~~~~~ a.cc:14:19: error: expected primary-expression before '>' token 14 | vector <ll> a; | ^ a.cc:14:21: error: 'a' was not declared in this scope 14 | vector <ll> a; | ^ a.cc:22:17: error: 'a1' was not declared in this scope 22 | a1.push(a[i]); | ^~ a.cc:26:17: error: 'a2' was not declared in this scope 26 | a2.push(a[i]); | ^~ a.cc:33:30: error: 'a1' was not declared in this scope 33 | sum1[i-N+1]-=a1.top(); | ^~ a.cc:41:28: error: 'a2' was not declared in this scope 41 | sum2[i-N]-=a2.top(); | ^~ a.cc:49:21: error: 'max' was not declared in this scope 49 | res=max(sum1[i]-sum2[i], res); | ^~~ a.cc:51:9: error: 'cout' was not declared in this scope 51 | cout<<res<<endl; | ^~~~ a.cc:51:20: error: 'endl' was not declared in this scope 51 | cout<<res<<endl; | ^~~~ a.cc: At global scope: a.cc:54:2: error: expected class-name at end of input 54 | ~ | ^
s245752399
p03714
C++
AtCoder Beginner Contest 0622017/05/20 21:00:00 ~ 2017/05/20 22:40:00 トップページ 問題 提出 質問 結果 順位表 コードテスト 解説 Submission #1456353 ソースコード #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++) #define rep(i,n) repl(i,0,n-1) #define each(itr,v) for(auto itr:v) #define pb push_back #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define mmax(x,y) (x>y?x:y) #define mmin(x,y) (x<y?x:y) #define maxch(x,y) x=mmax(x,y) #define minch(x,y) x=mmin(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) #define exist(x,y) (find(all(x),y)!=x.end()) #define bcnt __builtin_popcount #define INF INT_MAX/3 int main(){ cin.sync_with_stdio(false); priority_queue<int,vector<int>,greater<int> > qmin; priority_queue<int> qmax; int n; cin >> n; int a[3*n]; int b[n+1]; int c[n+1]; b[0] = 0; c[n] = 0; rep(i,3*n)cin>>a[i]; rep(i,n){ qmax.push(a[3*n-1-i]); qmin.push(a[i]); b[0] += a[i]; c[n] += a[3*n-1-i]; } int tmp; repl(i,n,2*n-1){ qmin.push(a[i]); tmp = qmin.top(); qmin.pop(); b[i-n+1] = b[i-n]+a[i]-tmp; } for(auto i=2*n-1;i>=n;i--){ qmax.push(a[i]); tmp = qmax.top(); qmax.pop(); c[i-n] = c[i-n+1]+a[i]-tmp; } int t= -1000000001; rep(i,n+1){ if(t<b[i]-c[i])t=b[i]-c[i]; } cout << t << endl; } Submission 問題 D - 3N Numbers ユーザ名 getty104 投稿日時 2017/07/28 12:40:28 言語 C++14 (GCC 5.4.1) 状態 WA 得点 0 ソースコード長 1390 Byte ファイル名 実行時間 ms メモリ使用量 - Test case Set Set name 得点 / Max score Cases Sample - 0_00.txt,0_01.txt,0_02.txt Subtask 0 / 300 0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt,1_18.txt,1_19.txt,1_20.txt,1_21.txt,1_22.txt,1_23.txt All 0 / 200 0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt,1_18.txt,1_19.txt,1_20.txt,1_21.txt,1_22.txt,1_23.txt,2_00.txt,2_01.txt,2_02.txt,2_03.txt,2_04.txt,2_05.txt,2_06.txt,2_07.txt,2_08.txt,2_09.txt,2_10.txt,2_11.txt,2_12.txt,2_13.txt,2_14.txt,2_15.txt Test case Case name 状態 実行時間 メモリ使用量 0_00.txt AC 1 ms 256 KB 0_01.txt AC 1 ms 256 KB 0_02.txt AC 1 ms 256 KB 1_00.txt AC 1 ms 256 KB 1_01.txt AC 1 ms 256 KB 1_02.txt AC 1 ms 256 KB 1_03.txt AC 1 ms 256 KB 1_04.txt AC 1 ms 256 KB 1_05.txt AC 1 ms 256 KB 1_06.txt AC 1 ms 256 KB 1_07.txt AC 1 ms 256 KB 1_08.txt AC 1 ms 256 KB 1_09.txt AC 2 ms 256 KB 1_10.txt WA 1_11.txt WA 1_12.txt WA 1_13.txt WA 1_14.txt WA 1_15.txt WA 1_16.txt AC 2 ms 256 KB 1_17.txt AC 2 ms 256 KB 1_18.txt AC 2 ms 256 KB 1_19.txt AC 2 ms 256 KB 1_20.txt WA 1_21.txt WA 1_22.txt WA 1_23.txt WA 2_00.txt AC 27 ms 3188 KB 2_01.txt AC 41 ms 3188 KB 2_02.txt WA 2_03.txt WA 2_04.txt WA 2_05.txt WA 2_06.txt WA 2_07.txt WA 2_08.txt AC 33 ms 3188 KB 2_09.txt AC 32 ms 3188 KB 2_10.txt AC 33 ms 3188 KB 2_11.txt AC 32 ms 3188 KB 2_12.txt WA 2_13.txt WA 2_14.txt WA 2_15.txt WA 利用規約 プライバシーポリシー 個人情報保護方針 チュートリアル ルール 用語集 よくある質問 © 2017 AtCoder Inc. All rights reserved. 2017-07-28 (Fri) 12:41:32 +0900
a.cc:11:12: error: stray '#' in program 11 | Submission #1456353 | ^ a.cc:81:20: error: too many decimal points in number 81 | 言語 C++14 (GCC 5.4.1) | ^~~~~ a.cc:140:1: error: extended character © is not valid in an identifier 140 | © 2017 AtCoder Inc. All rights reserved. | ^ a.cc:143:11: error: invalid digit "9" in octal constant 143 | 12:41:32 +0900 | ^~~~ a.cc:2:1: error: 'AtCoder' does not name a type 2 | AtCoder Beginner Contest 0622017/05/20 21:00:00 ~ 2017/05/20 22:40:00 | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:13: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBC
s522310417
p03714
C++
3#include <cstdio> #include <iostream> using namespace std; int tmp[1005]; int tmp1[1005]; void clear(int n,int tmp[]){ for(int t = 1; t <= 2*n; t++){ tmp[t] = 0; } } void array_copy_right(int A[], int tmp[], int end, int n){ for(int i = 3*n; i > end; i--){ tmp[3*n-i+1] = A[i]; } } void array_copy(int A[], int 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(int 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(int 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; int 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++){ array_copy(A,tmp,n+i); array_copy_right(A,tmp1,n+i,n); heap_sort(tmp,n+i); heap_sort(tmp1,2*n-i); long left = 0; long right = 0; for(int t = 0; t < n; t++){ left += tmp[n+i-t]; right += tmp1[t+1]; }//cout << left <<endl;cout << right << endl; if(left-right > max) max = left-right; clear(n,tmp1); } 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:1:2: error: stray '#' in program 1 | 3#include <cstdio> | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3#include <cstdio> | ^ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:17
s762889336
p03714
C++
#include <iostream> #include<sstream> #include<vector> #include<iterator> #include<queue> #include<climits> using namespace std; int main(void) { int N; cin >> N; vector<long long> a(3*N); for(int i=0; i<3*N; i++) cin >> a[i]; vector<long long> f_table(N+1, 0); long long sum = 0; priority_queue<long long> que; for(int i=0; i<N; i++) { sum += a[i]; que.push(-a[i]); } f_table[0] = sum; for(int i=0; i<N; i++) { int index = N + i; sum += a[index]; que.push(-a[index]); sum += que.top(); que.pop(); f_table[i + 1] = sum; } sum = 0; que.swap(priority_queue<long long int>()); vector<long long> b_table(N+1); for(int i=0; i<N; i++) { int index = 3*N-1 - i; sum += a[index]; que.push(a[index]); } b_table[0] = sum; for(int i=0; i<N; i++) { int index = 2*N-1 - i; sum += a[index]; que.push(a[index]); sum -= que.top(); que.pop(); b_table[i + 1] = sum; } long long ret = LLONG_MIN; for(int i=N; i<=2*N; i++) { ret = max(ret, f_table[i-N]-b_table[2*N-i]); } cout << ret << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:18: error: cannot bind non-const lvalue reference of type 'std::priority_queue<long long int>&' to an rvalue of type 'std::priority_queue<long long int>' 39 | que.swap(priority_queue<long long int>()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from a.cc:5: /usr/include/c++/14/bits/stl_queue.h:780:28: note: initializing argument 1 of 'void std::priority_queue<_Tp, _Sequence, _Compare>::swap(std::priority_queue<_Tp, _Sequence, _Compare>&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::less<long long int>]' 780 | swap(priority_queue& __pq) | ~~~~~~~~~~~~~~~~^~~~
s793585523
p03714
C++
#include <iostream> #include<sstream> #include<vector> #include<iterator> #include<queue> #include<climits> using namespace std; int main(void) { int N; cin >> N; vector<long long> a(3*N); for(int i=0; i<3*N; i++) cin >> a[i]; vector<long long> f_table(N+1, 0); long long sum = 0; priority_queue<long long> que; for(int i=0; i<N; i++) { sum += a[i]; que.push(-a[i]); } f_table[0] = sum; for(int i=0; i<N; i++) { int index = N + i; sum += a[index]; que.push(-a[index]); sum += que.top(); que.pop(); f_table[i + 1] = sum; } sum = 0; que.swap(priority_queue<long long>()); vector<long long> b_table(N+1); for(int i=0; i<N; i++) { int index = 3*N-1 - i; sum += a[index]; que.push(a[index]); } b_table[0] = sum; for(int i=0; i<N; i++) { int index = 2*N-1 - i; sum += a[index]; que.push(a[index]); sum -= que.top(); que.pop(); b_table[i + 1] = sum; } long long ret = LLONG_MIN; for(int i=N; i<=2*N; i++) { ret = max(ret, f_table[i-N]-b_table[2*N-i]); } cout << ret << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:18: error: cannot bind non-const lvalue reference of type 'std::priority_queue<long long int>&' to an rvalue of type 'std::priority_queue<long long int>' 39 | que.swap(priority_queue<long long>()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from a.cc:5: /usr/include/c++/14/bits/stl_queue.h:780:28: note: initializing argument 1 of 'void std::priority_queue<_Tp, _Sequence, _Compare>::swap(std::priority_queue<_Tp, _Sequence, _Compare>&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::less<long long int>]' 780 | swap(priority_queue& __pq) | ~~~~~~~~~~~~~~~~^~~~
s740609670
p03714
C++
#include <iostream> #include <algorithm> int main() { int N; long long min = LONG_MIN; std::cin >> N; unsigned long aa[30010]; unsigned long a[30010]; unsigned long aaa[30010]; for (int i = 0; i < 3*N; ++i) { std::cin >> aa[i]; } for (int i = 0; i < N; ++i) { for (int j = 0; j < 3*N; ++j) { a[j] = aa[j]; } for (int j = 0; j < 3 * N; ++j) { aaa[j] = aa[j]; } long long sum = 0; std::sort(a, a + N+i); for (int j = 0; j < N; ++j) { sum+= a[N+i -1- j]; } std::sort(aaa+ N + i, aaa+3*N ); for (int j = N+i; j < 2*N+i; ++j) { sum-= aaa[j]; } if (sum > min)min = sum; } std::cout << min; return 0; }
a.cc: In function 'int main()': a.cc:9:25: error: 'LONG_MIN' was not declared in this scope 9 | long long min = LONG_MIN; | ^~~~~~~~ a.cc:4:1: note: 'LONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <algorithm> +++ |+#include <climits> 4 |
s045822996
p03714
C++
#include "stdafx.h" #include <iostream> #include <algorithm> int main() { int N; long min = LONG_MIN; std::cin >> N; int aa[30010]; int a[30010]; int aaa[30010]; for (int i = 0; i < 3*N; ++i) { std::cin >> aa[i]; } for (int i = 0; i < N; ++i) { for (int j = 0; j < 3*N; ++j) { a[j] = aa[j]; } for (int j = 0; j < 3 * N; ++j) { aaa[j] = aa[j]; } int sum = 0; std::sort(a, a + N+i); for (int j = 0; j < N; ++j) { sum+= a[N+i -1- j]; } std::sort(aaa+ N + i, aaa+3*N ); for (int j = N+i; j < 2*N+i; ++j) { sum-= aaa[j]; } if (sum > min)min = sum; } std::cout << min; return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s228670668
p03714
C++
#include <cstdio> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <vector> #include <iostream> #include <queue> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define pq priority_queue #define FOR(i,a,b) for (long i=(a);i<(b);i++) #define RFOR(i,a,b) for (long i=(b)-1;i>=(a);i--) #define REP(i,n) for (long i=0;i<(n);i++) #define RREP(i,n) for (long i=(n)-1;i>=0;i--) #define MIN 2147483648 #define ALL(a) (a).begin(),a.end() #define MAXE(a) *max_element(ALL(a)) #define MINE(a) *min_element(ALL(a)) int main(){ long long N; cin >> N; long long a[300001]; REP(i,3*N) { cin >> a[i]; if(a[i]>950000000){ exit(1); } } cout << 0 << endl;
a.cc: In function 'int main()': a.cc:40:27: error: expected '}' at end of input 40 | cout << 0 << endl; | ^ a.cc:29:11: note: to match this '{' 29 | int main(){ | ^
s869921303
p03714
C++
#include <cstdio> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <vector> #include <iostream> #include <queue> //#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef priority_queue pq; #define FOR(i,a,b) for (long i=(a);i<(b);i++) #define RFOR(i,a,b) for (long i=(b)-1;i>=(a);i--) #define REP(i,n) for (long i=0;i<(n);i++) #define RREP(i,n) for (long i=(n)-1;i>=0;i--) #define MAX 2147483648 #define ALL(a) (a).begin(),a.end() #define MAXE(a) *max_element(ALL(a)) #define MINE(a) *min_element(ALL(a)) int main(){ long long N; cin >> N; long long a[300001]; REP(i,3*N) cin >> a[i]; pq <long long ,vl,greater<long long> > left; pq <long long ,vl,greater<long long> > right; long long kl[300001];//左のkまでの最大値を記録 long long kr[300001]; long long tl = 0; long long tr = 0; /* k */ // k = N ... 2N // left ... i = 0~k-1までの最大値 // right ... i = k~3N-1 までの最小値 //初期解 REP(i,N) { left.push(a[i]); tl+=a[i]; } kl[N] = tl; FOR(i,N,2*N){ left.push(a[i]); tl+=a[i]; tl-=left.top(); left.pop();//leftから最小のものをpopする kl[i+1] = tl; } FOR(i,2*N,3*N) { right.push(-a[i]); tr-=a[i]; } kr[2*N] = tr; for(ll i = 2*N-1;i>=N;i--){ right.push(-a[i]); tr-=a[i]; tr-=right.top(); right.pop(); kr[i] = tr; } long long out = kl[N]+kr[N]; FOR(i,N+1,2*N){ out = max(out,kl[i]+kr[i]); } cout << out << endl; }
a.cc:18:9: error: typedef declared 'auto' 18 | typedef priority_queue pq; | ^~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:37:9: error: invalid template-id 37 | pq <long long ,vl,greater<long long> > left; | ^~ a.cc:37:24: error: 'vl' was not declared in this scope; did you mean 'vll'? 37 | pq <long long ,vl,greater<long long> > left; | ^~ | vll a.cc:38:9: error: invalid template-id 38 | pq <long long ,vl,greater<long long> > right; | ^~ a.cc:56:22: error: request for member 'push' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)' 56 | left.push(a[i]); | ^~~~ a.cc:61:22: error: request for member 'push' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)' 61 | left.push(a[i]); | ^~~~ a.cc:63:26: error: request for member 'top' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)' 63 | tl-=left.top(); | ^~~ a.cc:64:22: error: request for member 'pop' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)' 64 | left.pop();//leftから最小のものをpopする | ^~~ a.cc:69:23: error: request for member 'push' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)' 69 | right.push(-a[i]); | ^~~~ a.cc:74:23: error: request for member 'push' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)' 74 | right.push(-a[i]); | ^~~~ a.cc:76:27: error: request for member 'top' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)' 76 | tr-=right.top(); | ^~~ a.cc:77:23: error: request for member 'pop' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)' 77 | right.pop(); | ^~~
s400922327
p03714
C++
#include <cstdio> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <vector> #include <iostream> #include <queue> using namespace std; typedef vector<int> vi; #define pq priority_queue #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 ALL(a) (a).begin(),a.end() #define MAXE(a) *max_element(ALL(a)) #define MINE(a) *min_element(ALL(a)) int main(){ int N; cin >> N; int a[300000]; REP(i,3*N) cin >> a[i]; pq <int,vi,greater<int> > left; pq <int> right; long out = LONG_MIN; long t = 0; FOR(k,N,2*N){ t = 0; REP(i,N) left.push(a[i]); FOR(i,2*N,3*N) right.push(a[i]); FOR(i,N,k){ left.push(a[i]); left.pop();//leftから最小のものをpopする } FOR(i,k,2*N){ right.push(a[i]); right.pop();//rightから最大のものをpopする } REP(i,N){ t += left.top() - right.top(); left.pop(); right.pop(); } out = max(t,out); } cout << out << endl; }
a.cc: In function 'int main()': a.cc:31:20: error: 'LONG_MIN' was not declared in this scope 31 | long out = LONG_MIN; | ^~~~~~~~ a.cc:9:1: note: 'LONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include <queue> +++ |+#include <climits> 9 | using namespace std;
s816824405
p03714
C++
#include <cstdio> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <vector> #include <iostream> #include <queue> using namespace std; typedef vector<int> vi; #define pq priority_queue #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 ALL(a) (a).begin(),a.end() #define MAXE(a) *max_element(ALL(a)) #define MINE(a) *min_element(ALL(a)) int main(){ int N; cin >> N; int a[300000]; REP(i,3*N) cin >> a[i]; pq <int,vi,greater<int> > left; pq <int> right; long out = LONG_MIN; long t = 0; FOR(k,N,2*N){ t = 0; REP(i,N) left.push(a[i]); FOR(i,2*N,3*N) right.push(a[i]); FOR(i,N,k){ left.push(a[i]); left.pop();//leftから最小のものをpopする } FOR(i,k,2*N){ right.push(a[i]); right.pop();//rightから最大のものをpopする } REP(i,N){ t += left.top() - right.top(); left.pop(); right.pop(); } out = max(t,out); } cout << out << endl; }
a.cc: In function 'int main()': a.cc:31:20: error: 'LONG_MIN' was not declared in this scope 31 | long out = LONG_MIN; | ^~~~~~~~ a.cc:9:1: note: 'LONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include <queue> +++ |+#include <climits> 9 | using namespace std;
s081849255
p03714
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> using namespace std; long long a[300000]; int main() { int n; long long sp=0; long long sl=0; long long ans; priority_queue<int>l;//後半n priority_queue<int,vector<int>,greater<int>>p;//前半n cin>>n; for(int i=0;i<3*n;i++) { cin>>a[i]; ans -= a[i]; } for(int i=n;i<n*2;i++) { sp=0; sl=0; p=priority_queue<long long,vector<long long>,greater<long long>>(); l=priority_queue<long long>(); for(int j=0;j<i;j++) { sp+=(long long)a[j]; p.push(a[j]); } for(int j=p.size();j>n;j=p.size()) { sp-=p.top(); cerr<<i<<" "<<p.top()<<endl; p.pop(); } for(int j=i;j<n*3;j++) { sl+=a[j]; l.push(a[j]); } for(int j=l.size();j>n;j=l.size()) { sl-=l.top(); cerr<<i<<" "<<l.top()<<endl; l.pop(); } cerr<<sp-sl<<endl; ans = max(ans,sp-sl); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:82: error: no match for 'operator=' (operand types are 'std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >' and 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >') 29 | p=priority_queue<long long,vector<long long>,greater<long long>>(); | ^ In file included from /usr/include/c++/14/queue:66, from a.cc:5: /usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >& std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >::operator=(const std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >&)' 496 | class priority_queue | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:496:11: note: no known conversion for argument 1 from 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >' to 'const std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >&' /usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >& std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >::operator=(std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >&&)' /usr/include/c++/14/bits/stl_queue.h:496:11: note: no known conversion for argument 1 from 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >' to 'std::priority_queue<int, std::vector<int, std::allocator<int> >, std::greater<int> >&&' a.cc:30:45: error: no match for 'operator=' (operand types are 'std::priority_queue<int>' and 'std::priority_queue<long long int>') 30 | l=priority_queue<long long>(); | ^ /usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<int>& std::priority_queue<int>::operator=(const std::priority_queue<int>&)' 496 | class priority_queue | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:496:11: note: no known conversion for argument 1 from 'std::priority_queue<long long int>' to 'const std::priority_queue<int>&' /usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<int>& std::priority_queue<int>::operator=(std::priority_queue<int>&&)' /usr/include/c++/14/bits/stl_queue.h:496:11: note: no known conversion for argument 1 from 'std::priority_queue<long long int>' to 'std::priority_queue<int>&&'
s369919796
p03714
Java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.AbstractCollection; import java.util.PriorityQueue; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Comparator; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Hamza Hasbi "hamzahasbi.me" */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskD solver = new TaskD(); solver.solve(1, in, out); out.close(); } static class TaskD { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); long[] a = new long[3 * n + 1]; long[] p = new long[3 * n + 1]; for (int i = 0; i < 3 * n; i++) { a[i] = in.nextLong(); } PriorityQueue<Long> left = new PriorityQueue<>(); PriorityQueue<Long> right = new PriorityQueue<Long>(new Comparator<Long>() { public int compare(Long int1, Long int2) { return int2.compareTo(int1); } }); long[] b = new long[2 * n + 1]; int index = (n % 2 == 0) ? 3 * n / 2 : 3 * n / 2 + 1; for (int i = 0; i < index; i++) { left.offer(a[i]); } for (int i = index; i < 3 * n; i++) { right.offer(a[i]); } long ans = 0; int r = n; boolean f = true; while (n > 0) { if (f) { left.poll(); f = !f; } else { right.poll(); f = !f; } n--; } while (!left.isEmpty()) { //out.print(left.peek()+" "); ans += left.poll(); } //out.printLine(); while (!right.isEmpty()) { //out.print(right.peek()+" "); ans -= right.poll(); } out.printLine(ans); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void printLine(long i) { writer.println(i); } public void close() { writer.close(); } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = read();
Main.java:151: error: reached end of file while parsing int c = read(); ^ 1 error
s066581222
p03714
C++
#include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f typedef long long ll; const int N = 1e5 + 10; ll front[N], end[N]; int num[3*N]; int main() { // freopen("in.txt", "r", stdin); int n; while (~scanf("%d", &n)) { for (int i = 0; i < 3*n; i++) scanf("%d", num + i); priority_queue<int, vector<int>, greater<int> >qmin; priority_queue<int> qmax; ll sum = 0; qmin.push(num[0]); for (int i = 0; i < n; i++) { sum += num[i]; qmin.push(num[i]); } int m = n<<1; front[n-1] = sum; for (int i = n; i < m; i++) { if (qmin.top() < num[i]) { sum += num[i]; sum -= qmin.top(); qmin.pop(); qmin.push(num[i]); } front[i] = sum; } sum = 0; for (int i = 3*n - 1; i >= m; i--) { sum += num[i]; qmax.push(num[i]); } end[m] = sum; for (int i = m - 1; i >= n; i--) { if (num[i] < qmax.top()) { sum += num[i]; sum -= qmax.top(); qmax.pop(); qmax.push(num[i]); } end[i] = sum; } ll ans = front[n-1] - end[n]; for (int i = n; i < m; i++) { // if (n == 1) // printf("%d %d\n", front[i-1], end[i]); ans = max(front[i-1] - end[i], ans); } printf("%lld\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:46:17: error: reference to 'end' is ambiguous 46 | end[m] = sum; | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ In file included from /usr/include/c++/14/string:53, 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/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:14: note: 'll end [100010]' 6 | ll front[N], end[N]; | ^~~ a.cc:56:25: error: reference to 'end' is ambiguous 56 | end[i] = sum; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:14: note: 'll end [100010]' 6 | ll front[N], end[N]; | ^~~ a.cc:58:39: error: reference to 'end' is ambiguous 58 | ll ans = front[n-1] - end[n]; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:14: note: 'll end [100010]' 6 | ll front[N], end[N]; | ^~~ a.cc:63:48: error: reference to 'end' is ambiguous 63 | ans = max(front[i-1] - end[i], ans); | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:14: note: 'll end [100010]' 6 | ll front[N], end[N]; | ^~~
s219386252
p03714
C++
#innclude <iostream> #include <queue> #include <vector> using namespace std; vector<int> midN; priority_queue<int, vector<int>, greater<int>> leftN; priority_queue<int> rightN; vector<long> savedLeft; vector<long> savedRight; int main(){ int N=0; cin>>N; int head=0; int tail=N-1; long sumLeft=0; long sumRight=0; long res=0; for(int i=0;i<N;i++){ int tmp; cin>>tmp; leftN.push(tmp); sumLeft+=tmp; } for(int i=0;i<N;i++){ int tmp; cin>>tmp; midN.push_back(tmp); } for(int i=0;i<N;i++){ int tmp; cin>>tmp; rightN.push(tmp); sumRight+=tmp; } res=sumLeft-sumRight; sumLeft=sumRight=0; savedLeft.push_back(sumLeft); savedRight.push_back(sumRight); for(int i=0;i<N;i++){ int opA=midN[i]-leftN.top(); if(opA>0){ leftN.pop(); leftN.push(midN[i]); sumLeft+=opA; } savedLeft.push_back(sumLeft); } for(int i=N-1;i>=0;i--){ int opB=rightN.top()-midN[i]; if(opB>0){ rightN.pop(); rightN.push(midN[i]); sumRight+=opB; } savedRight.push_back(sumRight); } long maxSum=0; for(int i=0;i<=N;i++){ long tmp=savedLeft[i]+savedRight[N-i]; if(tmp>maxSum) maxSum=tmp; } cout<<res+maxSum<<endl; return 0; }
a.cc:1:2: error: invalid preprocessing directive #innclude; did you mean #include? 1 | #innclude <iostream> | ^~~~~~~~ | include a.cc: In function 'int main()': a.cc:18:3: error: 'cin' was not declared in this scope 18 | cin>>N; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <queue> +++ |+#include <iostream> 3 | #include <vector> a.cc:77:3: error: 'cout' was not declared in this scope 77 | cout<<res+maxSum<<endl; | ^~~~ a.cc:77:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:77:21: error: 'endl' was not declared in this scope 77 | cout<<res+maxSum<<endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <queue> +++ |+#include <ostream> 3 | #include <vector>
s607063642
p03714
C++
#innclude <iostream> #include <queue> #include <vector> using namespace std; vector<int> midN; priority_queue<int, vector<int>, greater<int>> leftN; priority_queue<int> rightN; vector<long> savedLeft; vector<long> savedRight; int main(){ int N=0; cin>>N; int head=0; int tail=N-1; long sumLeft=0; long sumRight=0; long res=0; for(int i=0;i<N;i++){ int tmp; cin>>tmp; leftN.push(tmp); sumLeft+=tmp; } for(int i=0;i<N;i++){ int tmp; cin>>tmp; midN.push_back(tmp); } for(int i=0;i<N;i++){ int tmp; cin>>tmp; rightN.push(tmp); sumRight+=tmp; } res=sumLeft-sumRight; sumLeft=sumRight=0; savedLeft.push_back(sumLeft); savedRight.push_back(sumRight); for(int i=0;i<N;i++){ int opA=midN[i]-leftN.top(); if(opA>0){ leftN.pop(); leftN.push(midN[i]); sumLeft+=opA; } savedLeft.push_back(sumLeft); } for(int i=N-1;i>=0;i--){ int opB=rightN.top()-midN[i]; if(opB>0){ rightN.pop(); rightN.push(midN[i]); sumRight+=opB; } savedRight.push_back(sumRight); } long maxSum=0; for(int i=0;i<=N;i++){ long tmp=savedLeft[i]+savedRight[N-i]; if(tmp>maxSum) maxSum=tmp; } cout<<res+maxSum<<endl; return 0; }
a.cc:1:2: error: invalid preprocessing directive #innclude; did you mean #include? 1 | #innclude <iostream> | ^~~~~~~~ | include a.cc: In function 'int main()': a.cc:18:3: error: 'cin' was not declared in this scope 18 | cin>>N; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <queue> +++ |+#include <iostream> 3 | #include <vector> a.cc:77:3: error: 'cout' was not declared in this scope 77 | cout<<res+maxSum<<endl; | ^~~~ a.cc:77:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:77:21: error: 'endl' was not declared in this scope 77 | cout<<res+maxSum<<endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <queue> +++ |+#include <ostream> 3 | #include <vector>