submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s363341378
p03738
Java
import java.util.Scanner; class Main { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); if(a > b) { System.out.println("GREATER"); } else if(a < b) { System.out.println("LESS"); } else { System.out.println("EQUAL"); } }
Main.java:17: error: reached end of file while parsing } ^ 1 error
s262577567
p03738
Java
import java.util.scanner; class Main { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); if(a > b) { System.out.println("GREATER"); } else if(a < b) { System.out.println("LESS"); } else { System.out.println("EQUAL"); } } }
Main.java:1: error: cannot find symbol import java.util.scanner; ^ symbol: class scanner location: package java.util Main.java:5: error: cannot find symbol Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:5: error: cannot find symbol Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main 3 errors
s273966388
p03738
Java
import java.util.scanner; class Main { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); if(a > b) { System.out.println("GREATER"); } else if(a < b) { System.out.println("LESS"); } else { System.out.println("EQUAL"); } }
Main.java:17: error: reached end of file while parsing } ^ 1 error
s742712906
p03738
C++
#include <iostream> #include <stdio.h> #include <cstring> using namespace std; int main() { char a[101] = {0}; char b[101] = {0}; int check = 0; cin >> a >> b; int aa = strlen(a); int bb = strlen(b); if(a > b) cout << "GREATER"; else if(a == b) cout << "EQUAL"; else if(a < b) cout << "LESS"; else for(int i = 0; i < aa; i++){ if(a[i] > b[i]){ cout << "GREATER"; check = 1 break; } else if(a[i] < b[i]){ cout << "LESS"; check = 1; break; } } if(check == 0) cout << "EQUAL"; }
a.cc: In function 'int main()': a.cc:32:42: error: expected ';' before 'break' 32 | check = 1 | ^ | ; 33 | break; | ~~~~~
s792798906
p03738
C++
#include <iostream> #include <stdio.h> #include <cstring> using namespace std; int main() { string a, b; cin >> a >> b; if(a > b){ cout << "GREATER"; } if(a == b){ cout << "EQUAL"; } else cout << " " }
a.cc: In function 'int main()': a.cc:22:28: error: expected ';' before '}' token 22 | cout << " " | ^ | ; 23 | } | ~
s096932881
p03738
C
unsigned long long int a,b; scanf("%llu%llu",a,b); if(a==b){ printf("EQUAL"); }else if(a<b){ printf("LESS"); }else{ printf("GREATER"); } }
main.c:2:7: error: expected declaration specifiers or '...' before string constant 2 | scanf("%llu%llu",a,b); | ^~~~~~~~~~ main.c:2:18: error: expected declaration specifiers or '...' before 'a' 2 | scanf("%llu%llu",a,b); | ^ main.c:2:20: error: expected declaration specifiers or '...' before 'b' 2 | scanf("%llu%llu",a,b); | ^ main.c:3:1: error: expected identifier or '(' before 'if' 3 | if(a==b){ | ^~ main.c:5:2: error: expected identifier or '(' before 'else' 5 | }else if(a<b){ | ^~~~ main.c:7:2: error: expected identifier or '(' before 'else' 7 | }else{ | ^~~~ main.c:10:1: error: expected identifier or '(' before '}' token 10 | } | ^
s615844783
p03738
Java
import java.util.Scanner; public class Main{ public static void main(System.in){ Scanner scan = new Scanner(System.in); String a = scan.next(); String b = scan.next(); if(a.length() > b.length()){ System.out.println("GREATER"); break; } else if(a.length() < b.length()){ System.out.println("LESS"); break; } else { for(int i = 0 ; i < a.length() ; i++){ if(a.charAt(i) > b.charAt(i)){ System.out.println("GREATER"); break; } else if(a.charAt(i) > b.charAt(i)){ System.out.println("LESS"); break; } else { if(i == a.length - 1){ System.out.println("EQUAL"); } } } } } }
Main.java:4: error: <identifier> expected public static void main(System.in){ ^ 1 error
s361668778
p03738
C
#include <iostream> #include <cmath> #include <cstdio> using namespace std; const long D = 1000000007; int main() { string a, b; cin >> a >> b; if (a.length() < b.length()) { cout << "LESS" << endl; } else if (a.length() > b.length()) { cout << "GREATER" << endl; } else { cout << (a > b ? "GREATER" : a == b ? "EQUAL" : "LESS") << endl; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s126233893
p03738
C++
#include<iostream> #include<fstream> #include<string> #include<cmath> #include<queue> using namespace std; int main(){ string A,B; int numA,numB,dA,dB; int i; cin >> A; cin >> B; numA=A.length(); numB=B.length(); if (numA>numB){ cout<<"GREATER"<<endl; } else if(numA<numB){ cout<<"LESS"<<endl; } else{ for(i=0;i<=numA-1;i++){ if(A[i]>B[i]){ cout<<"GREATER"<<endl; break; } else if(A[i]<B[i]){ cout<<"LESS"<<endl; break; } else{ if(i==0){ cout<<"EQUAL"<<endl; break; } } } } } return 0; };
a.cc:48:1: error: expected unqualified-id before 'return' 48 | return 0; | ^~~~~~ a.cc:49:1: error: expected declaration before '}' token 49 | }; | ^
s694307843
p03738
C++
#include<iostream> using namespace std; int main(){ int a,b; cin>>a>>b; if(a>b)cout<<"GREATER"<<endl; else if(a==b)cout<<"EQUAL"<<endl; else cout<<"LESS"<<ednl; }
a.cc: In function 'int main()': a.cc:8:20: error: 'ednl' was not declared in this scope 8 | else cout<<"LESS"<<ednl; | ^~~~
s744572272
p03738
C++
package main import ( "bufio" "fmt" "os" "strconv" ) func main() { sc := NewScanner() a := "" a = sc.NextLine() b := "" b = sc.NextLine() if a == b { fmt.Printf("EQUAL\n") } else if a > b { fmt.Printf("GREATER\n") } else { fmt.Printf("LESS\n") } } type Scanner struct { r *bufio.Reader buf []byte p int } func NewScanner() *Scanner { rdr := bufio.NewReaderSize(os.Stdin, 1000) return &Scanner{r: rdr} } func (s *Scanner) Next() string { s.pre() start := s.p for ; s.p < len(s.buf); s.p++ { if s.buf[s.p] == ' ' { break } } result := string(s.buf[start:s.p]) s.p++ return result } func (s *Scanner) NextLine() string { s.pre() start := s.p s.p = len(s.buf) return string(s.buf[start:]) } func (s *Scanner) NextInt() int { v, _ := strconv.Atoi(s.Next()) return v } func (s *Scanner) NextIntArray() []int { s.pre() start := s.p result := []int{} for ; s.p < len(s.buf); s.p++ { if s.buf[s.p] == ' ' { v, _ := strconv.Atoi(string(s.buf[start:s.p])) result = append(result, v) start = s.p + 1 } } v, _ := strconv.Atoi(string(s.buf[start:s.p])) result = append(result, v) return result } func (s *Scanner) NextMap() map[int]bool { s.pre() start := s.p mp := map[int]bool{} for ; s.p < len(s.buf); s.p++ { if s.buf[s.p] == ' ' { v, _ := strconv.Atoi(string(s.buf[start:s.p])) mp[v] = true start = s.p + 1 } } v, _ := strconv.Atoi(string(s.buf[start:s.p])) mp[v] = true return mp } func (s *Scanner) pre() { if s.p >= len(s.buf) { s.readLine() s.p = 0 } } func (s *Scanner) readLine() { s.buf = make([]byte, 0) for { l, p, e := s.r.ReadLine() if e != nil { panic(e) } s.buf = append(s.buf, l...) if !p { break } } }
a.cc:1:1: error: 'package' does not name a type 1 | package main | ^~~~~~~ a.cc:27:1: error: 'type' does not name a type; did you mean 'typeof'? 27 | type Scanner struct { | ^~~~ | typeof a.cc:33:1: error: 'func' does not name a type 33 | func NewScanner() *Scanner { | ^~~~ a.cc:37:6: error: expected constructor, destructor, or type conversion before '(' token 37 | func (s *Scanner) Next() string { | ^ a.cc:49:6: error: expected constructor, destructor, or type conversion before '(' token 49 | func (s *Scanner) NextLine() string { | ^ a.cc:55:6: error: expected constructor, destructor, or type conversion before '(' token 55 | func (s *Scanner) NextInt() int { | ^ a.cc:60:6: error: expected constructor, destructor, or type conversion before '(' token 60 | func (s *Scanner) NextIntArray() []int { | ^ a.cc:77:6: error: expected constructor, destructor, or type conversion before '(' token 77 | func (s *Scanner) NextMap() map[int]bool { | ^ a.cc:94:6: error: expected constructor, destructor, or type conversion before '(' token 94 | func (s *Scanner) pre() { | ^ a.cc:100:6: error: expected constructor, destructor, or type conversion before '(' token 100 | func (s *Scanner) readLine() { | ^
s817512256
p03738
C++
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <queue> using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); string A, B; cin >> A; cin >> B; int n = max(A.size(), B.size()); string ans; if (A.size() > B.size()) { cout << "GREATER" << endl; return; } else if (B.size() < A.size()) { cout << "LESS" << endl; } else { for (int i = 0; i < n; i++) { if (A[i] > B[i]) { ans = "GREATER"; break; } else if (A[i] < B[i]) { ans = "LESS"; break; } else { ans = "EQUAL"; } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:22:5: error: return-statement with no value, in function returning 'int' [-fpermissive] 22 | return; | ^~~~~~
s066913677
p03738
Java
import java.util.Scanner; public class ABC { public static void main(String args[]){ Scanner sc = new Scanner(System.in); // 整数の入力 String input1 = sc.next(); String input2 = sc.next(); int a = new Integer(input1).intValue(); int b = new Integer(input2).intValue(); if(a == b) System.out.println("EQUAL"); if(a>b)System.out.println("GREATER"); if(a<b)System.out.println("LESS"); } }
Main.java:4: error: class ABC is public, should be declared in a file named ABC.java public class ABC { ^ Main.java:10: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal int a = new Integer(input1).intValue(); ^ Main.java:11: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal int b = new Integer(input2).intValue(); ^ 1 error 2 warnings
s672548690
p03738
Java
import java.io.File; import java.util.Scanner; public class ABC { public static void main(String args[]){ Scanner sc = new Scanner(System.in); // 整数の入力 String input1 = sc.next(); String input2 = sc.next(); int a = new Integer(input1).intValue(); int b = new Integer(input2).intValue(); if(a == b) System.out.println("EQUAL"); if(a>b)System.out.println("GREATER"); if(a<b)System.out.println("LESS"); } }
Main.java:5: error: class ABC is public, should be declared in a file named ABC.java public class ABC { ^ Main.java:11: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal int a = new Integer(input1).intValue(); ^ Main.java:12: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal int b = new Integer(input2).intValue(); ^ 1 error 2 warnings
s154908948
p03738
Java
import java.io.File; import java.util.Scanner; public class ABC { public static void main(String args[]){ Scanner sc = new Scanner(System.in); // 整数の入力 String input1 = sc.next(); String input2 = sc.next(); int a = new Integer(input1).intValue(); int b = new Integer(input2).intValue(); if(a == b) System.out.println("EQUAL"); if(a>b)System.out.println("GREATER"); if(a<b)System.out.println("LESS"); } }
Main.java:5: error: class ABC is public, should be declared in a file named ABC.java public class ABC { ^ Main.java:11: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal int a = new Integer(input1).intValue(); ^ Main.java:12: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal int b = new Integer(input2).intValue(); ^ 1 error 2 warnings
s006787463
p03738
C++
#include<iostream> #include <string> #include<algorithm> using namespace std; int main() { string a, b; int c=0; cin >> a >> b; for (int i = 0; i < min(a.size(), b.size());i++) { if (a[i] < b[i]) { c = 1; break; } else if (a[i] > b[i]) { c = 2; break; } } if (a.size() < b.size()) { c = 1; break; } if (a.size() > b.size()) { c = 2; break; } if (c == 1) { cout << "LESS" << endl; } else if (c == 2) { cout << "GREATER" << endl; } else if (c == 0) { cout << "EQUAL" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:17: error: break statement not within loop or switch 22 | break; | ^~~~~ a.cc:26:17: error: break statement not within loop or switch 26 | break; | ^~~~~
s493653135
p03738
C
#include <stdio.h> #include <stdlib.h> int main(){ char one[100] = {0}; char two[100] = {0}; int length i = 0; int length j = 0; int x; char buffer; scanf("%c",&buffer); while(buffer != '\n'){ one[i] = buffer; i++; scanf("%c",&buffer); } scanf("%c",&buffer); while(buffer >= '0' || buffer <= '9'){ two[j] = buffer; j++; scanf("%c",&buffer); } if(i > j){ printf("GREATER\n"); }else if(i < j){ printf("LESS\n"); }else{ while(i >=0){ x = j-i; if(one[x] > two[x]) {printf("GREATER\n"); break;} if(two[x] > one[x]) {printf("LESS\n"); break;} i--; if(i<0) printf("EQUAL\n"); } } return 0; }
main.c: In function 'main': main.c:7:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i' 7 | int length i = 0; | ^ main.c:7:15: error: 'i' undeclared (first use in this function) main.c:7:15: note: each undeclared identifier is reported only once for each function it appears in main.c:8:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'j' 8 | int length j = 0; | ^ main.c:8:15: error: 'j' undeclared (first use in this function)
s419778128
p03738
C++
#incldue<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; if(a>b)cout<<"GREATER"<<endl; else if(a==b)cout<<"EQUAL"<<endl; else cout<<"LESS"<<endl; return 0; }
a.cc:1:2: error: invalid preprocessing directive #incldue; did you mean #include? 1 | #incldue<bits/stdc++.h> | ^~~~~~~ | include a.cc: In function 'int main()': a.cc:5:2: error: 'cin' was not declared in this scope 5 | cin>>a>>b; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #incldue<bits/stdc++.h> a.cc:6:9: error: 'cout' was not declared in this scope 6 | if(a>b)cout<<"GREATER"<<endl; | ^~~~ a.cc:6:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:6:26: error: 'endl' was not declared in this scope 6 | if(a>b)cout<<"GREATER"<<endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #incldue<bits/stdc++.h> a.cc:7:15: error: 'cout' was not declared in this scope 7 | else if(a==b)cout<<"EQUAL"<<endl; | ^~~~ a.cc:7:15: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:7:30: error: 'endl' was not declared in this scope 7 | else if(a==b)cout<<"EQUAL"<<endl; | ^~~~ a.cc:7:30: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:8:7: error: 'cout' was not declared in this scope 8 | else cout<<"LESS"<<endl; | ^~~~ a.cc:8:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:8:21: error: 'endl' was not declared in this scope 8 | else cout<<"LESS"<<endl; | ^~~~ a.cc:8:21: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s567894584
p03738
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String num1 = in.next(); String num2 = in.next(); Compare com = new Main(); int result = com.Compare(num1, num2); String display = ""; if (result == -1) { display = "LESS"; }else if (result == 1) { display = "GREATER"; } else { display = "EQUAL"; } System.out.println(display); } private int Compare(String num1, String num2) { // TODO Auto-generated method stub int len1 = num1.length(); int len2 = num2.length(); if (len1 < len2) { return -1; }else if (len1 > len2) { return 1; }else { int i = 0; while (i < len1) { if (num1.charAt(i) > num2.charAt(i)) { return 1; }else if(num1.charAt(i) < num2.charAt(i)){ return -1; } i++; } } return 0; } }
Main.java:8: error: cannot find symbol Compare com = new Main(); ^ symbol: class Compare location: class Main 1 error
s849281823
p03738
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<queue> #include<vector> #include<map> #define For(i,a,b) for(int i=a;i<=b;i++) #define ForD(i,a,b) for (int i=a;i>=b;i--) #define LL long long #define INF (2147483647) #define sqr(x) ((x)*(x)) using namespace std; inline int read(){ int data=0,w=1; char ch=0; while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar(); if (ch=='-') w=-1,ch=getchar(); while (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar(); return data*w; } inline void write(int x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } int main(){ char s1[1000],s2[1000]; scanf("%s",s1),scanf("%s",s2); if (strlen(s1)<strlen(s2)) puts("LESS"); else if (strlen(s2)<strlen(s1)) puts("GREATER"); if (strlen(s1)==strlen(s2)){ int t=0; For(i,0,strlen(s1)){ if (s1[i]<s2[i]){ t=1;break; } if (s1[i]>s2[i]){ t=2;break; } }a if (t==1) puts("LESS"); if (t==2) puts("GREATER"); if (t==0) puts("EQUAL"); } }
a.cc: In function 'int main()': a.cc:48:18: error: 'a' was not declared in this scope 48 | }a | ^
s257846602
p03738
C++
#include<iostream> #include <string> #include <algorithm> using namespace std; void main() { long A, B; cin >> A >>B; //cin >> B ; if (A < B) { cout << "LESS" << endl; } else if (A == B) { cout << "EQUAL" << endl; } else if (A > B) { cout << "GREATER" << endl; } }
a.cc:5:1: error: '::main' must return 'int' 5 | void main() | ^~~~
s895740936
p03738
C++
#include<iostream> #include<string> using namespace std; int main(){ long long int a,b; cin>>a>>b; long long char c=a,d=b; if(c>d){ cout<<"GREATER"<<endl; } if(c<d){ cout<<"LESS"<<endl; } if(c==d){ cout<<"EQUAL"<<endl; } }
a.cc: In function 'int main()': a.cc:9:6: error: 'long long' specified with 'char' 9 | long long char c=a,d=b; | ^~~~ a.cc:9:6: error: 'long long' specified with 'char'
s935835466
p03738
C++
#include<iostream> #include<string> using namespace std; int main(){ long long char a,b; cin>>a>>b; if(a>b){ cout<<"GREATER"<<endl; } if(a<b){ cout<<"LESS"<<endl; } if(a==b){ cout<<"EQUAL"<<endl; } }
a.cc: In function 'int main()': a.cc:6:6: error: 'long long' specified with 'char' 6 | long long char a,b; | ^~~~ a.cc:6:6: error: 'long long' specified with 'char'
s816961471
p03738
C++
#include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf("%d%d", &a, &b)l if (a > b) printf("GREATER\n"); else if (a == b) printf("EQUAL\n"); else printf("LESS\n"); }
a.cc: In function 'int main()': a.cc:6:26: error: expected ';' before 'l' 6 | scanf("%d%d", &a, &b)l | ^ | ; a.cc:8:5: error: 'else' without a previous 'if' 8 | else if (a == b) printf("EQUAL\n"); | ^~~~
s037220470
p03738
C++
#include <bits/stdc++.h> using namespace std; int main() { string A, B; cin >> A >> B; ll len = max(A.size(), B.size()); while (A.size() < len) A = "0" + A; while (B.size() < len) B = "0" + B; if (A < B) cout << "LESS" << endl; else if (A > B) cout << "GREATER" << endl; else cout << "EQUAL" << endl; }
a.cc: In function 'int main()': a.cc:7:5: error: 'll' was not declared in this scope 7 | ll len = max(A.size(), B.size()); | ^~ a.cc:8:23: error: 'len' was not declared in this scope 8 | while (A.size() < len) A = "0" + A; | ^~~ a.cc:9:23: error: 'len' was not declared in this scope 9 | while (B.size() < len) B = "0" + B; | ^~~
s184946096
p03738
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(a59_b(sc.next(),sc.next())); } static String a59_b(String i1, String i2) { BigInteger b1 = new BigInteger(i1); BigInteger b2 = new BigInteger(i2); int i = b1.compareTo(b2); if (i == -1) { return "LESS"; } else if (i == 1) { return "GREATER"; } else { return "EQUAL"; } } }
Main.java:10: error: cannot find symbol BigInteger b1 = new BigInteger(i1); ^ symbol: class BigInteger location: class Main Main.java:10: error: cannot find symbol BigInteger b1 = new BigInteger(i1); ^ symbol: class BigInteger location: class Main Main.java:11: error: cannot find symbol BigInteger b2 = new BigInteger(i2); ^ symbol: class BigInteger location: class Main Main.java:11: error: cannot find symbol BigInteger b2 = new BigInteger(i2); ^ symbol: class BigInteger location: class Main 4 errors
s193695961
p03738
C++
#include <iostream> using namespace std; int main(void){ char A,B; cin >> A >> B; if(A.length() > B.length()) cout << "GREATER" << endl; else if(A.length() < B.length()) cout << "LESS" << endl; else{ if(+A == +B) cout << "EQUAL" << endl; else if(+A > +B) cout << "GREATER" << endl; else if(+A < +B) cout << "LESS" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:7:8: error: request for member 'length' in 'A', which is of non-class type 'char' 7 | if(A.length() > B.length()) | ^~~~~~ a.cc:7:21: error: request for member 'length' in 'B', which is of non-class type 'char' 7 | if(A.length() > B.length()) | ^~~~~~ a.cc:9:13: error: request for member 'length' in 'A', which is of non-class type 'char' 9 | else if(A.length() < B.length()) | ^~~~~~ a.cc:9:26: error: request for member 'length' in 'B', which is of non-class type 'char' 9 | else if(A.length() < B.length()) | ^~~~~~
s879014537
p03738
C++
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #include<algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; int main(){ string a,b; cin>>a>>b; if(a.size()>b.size())cout<<"GREATER"<<endl; else if(a>b)cout<<"GREATER"<<endl; else if(a==b)cout<<"EQUAL"<<endl; else if(a<b)<<"LESS"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:23:17: error: expected primary-expression before '<<' token 23 | else if(a<b)<<"LESS"<<endl; | ^~
s103325690
p03738
Java
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class TaskB { public static void main(String[] args) { Scanner in = new Scanner(System.in); int result; String a = in.nextLine(); String b = in.nextLine(); BigInteger aa = new BigInteger(a); BigInteger bb = new BigInteger(b); result = aa.compareTo(bb); if (result == 0) { System.out.println("EQUAL"); } else if (result == 1) { System.out.println("GREATER"); } else if (result == -1) { System.out.println("LESS"); } } }
Main.java:7: error: class TaskB is public, should be declared in a file named TaskB.java public class TaskB { ^ 1 error
s936614349
p03738
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner scan = new Scanner(System.in); String A =scan.next(); String B =scan.next(); int a = 0; int b = 0; int count=0; if(A.length()>B.length()){ System.out.println("GREATER"); System.exit(0); }else if (B.length()>A.length()){ System.out.println("LESS"); System.exit(0); }else if(A.length()==B.length()){ for(int i =0;i<A.length();i++){ a= Character.getNumericValue(A.charAt(i)); b= Character.getNumericValue(B.charAt(i)); if(a>b){ System.out.println("GREATER"); System.exit(0); }else if(b>a){ System.out.println("LESS"); System.exit(0); }else{ count++; if(count==A.length()){ System.out.println("EQUAL"); } } } }
Main.java:36: error: reached end of file while parsing } ^ 1 error
s670119220
p03738
C++
#include <iostream> #include <string> using namespace std; const int MAX_N = 1000; char A[MAX_N], B[MAX_N]; void solve() { if (strcmp(A, B) > 0) { cout << "GREATER" << endl; } else if (strcmp(A, B) < 0) { cout << "LESS" << endl; } else if (strcmp(A, B) == 0) { cout << "EQUAL" << endl; } } int main() { //入力 cin >> A >> B; solve(); return 0; }
a.cc: In function 'void solve()': a.cc:11:13: error: 'strcmp' was not declared in this scope 11 | if (strcmp(A, B) > 0) { | ^~~~~~ a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s802536361
p03738
C++
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; int main() { string a, b; cin >> a >> b; const auto s1 = a.size(), s2 = b.size(); if (s1 == s2) { const auto c = strcmp(a.c_str(), b.c_str()); if (c < 0) { cout << "LESS" << endl; } else if (c > 0) { cout << "GREATER" << endl; } else { cout << "EQUAL" << endl; } } else if (s1 > s2) { cout << "GREATER" << endl; } else { cout << "LESS" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:20: error: 'strcmp' was not declared in this scope 14 | const auto c = strcmp(a.c_str(), b.c_str()); | ^~~~~~ a.cc:6:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <vector> +++ |+#include <cstring> 6 | using namespace std;
s384983029
p03738
C
include <stdio.h> int main(void){ int a,b; scanf("%d",&a); scanf("%d",&b); if(&a>&b){ printf("GREATER"); }else if(&a<&b){ printf("LESS"); }else{ printf("EQUAL"); } printf("\n"); return 0; }
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include <stdio.h> | ^
s655080480
p03738
C
include <stdio.h> int main(void){ int a,b; scanf("%d",&a); scanf("%d",&b); if(a>b){ printf("GREATER"); }else if(a<b){ printf("LESS"); }else{ printf("EQUAL"); } printf("\n"); return 0; return 0; }
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include <stdio.h> | ^
s846988337
p03738
C++
#include <cstdio> using namespace std; int main(){ long double A, B; scanf("%Lf\n%Lf", &A, &B); if (A > B) printf("GREATER\n"); else if (A < B) printf("LESS\n"); else if (A == B) printf("EQUAL\n"); return 0; } [ohwa
a.cc:12:1: error: expected unqualified-id before '[' token 12 | [ohwa | ^
s409670127
p03738
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int in(void){ int i;scanf("%d",&i); return i; } long long llin(void){ long long i;scanf("%lld",&i); return i; } void print(int a){ printf("%d\n",a); } void llprint(long long a){ printf("%lld\n",a); } void print2(int a,int b){ printf("%d %d\n",a,b); } long long max(long long a,long long b){ return a>b?a:b; } long long min(long long a,long long b){ return a<b?a:b; } int main(void){ char a[102],b[102]; scanf("%s",a); scanf("%s",b); if(strlen(a)!=strlen(b)){ puts(strlen(a)>strlen(b)?"GREATER":"LESS"); } else{ int i; for(i=0;i<strlen(a);i++){ if(a[i]!=b[i]){ puts(a[i]>b[i]?"GREATER":"LESS"); break; } }if(i==strlen(a)puts("EQUAL"); } return 0; }
main.c: In function 'main': main.c:44:33: error: expected ')' before 'puts' 44 | }if(i==strlen(a)puts("EQUAL"); | ~ ^~~~ | ) main.c:46:9: error: expected expression before '}' token 46 | } | ^
s973236048
p03738
C++
//インクルード #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <boost/multiprecision/cpp_int.hpp> //型宣言 typedef long long ll; typedef unsigned long long ull; typedef std::string string; typedef string answerType; //変数宣言 boost::multiprecision A; boost::multiprecision B; std::vector<string> Ai; std::vector<string> Bi; answerType answer; //関数のプロトタイプ宣言 //入力の取得 void getInput(); //答えを求める answerType calcAnswer(); //メイン関数 int main() { //入力の取得 getInput(); //答え answerType answer = calcAnswer(); //答えの出力 std::cout << answer << std::endl; //正常終了 return EXIT_SUCCESS; } //入力の取得 void getInput() { std::cin >> A >> B; } //答えを求める answerType calcAnswer() { if(A > B) { return "GREATER"; } if(A < B) { return "LESS"; } return "EQUAL"; }
a.cc:6:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 6 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s092221876
p03738
C++
#include <bits/stdc> using namespace std; int main(void){ string A, B; cin >> A >> B; int a = A.size(); int b = B.size(); if(a>b){ cout << "GREATER" << endl; return 0; }else if(a<b){ cout << "LESS" << endl; return 0; } for(int i=a-1; i>=0; i--){ if(A[i]>B[i]){ cout << "GREATER" << endl; return 0; }else if(A[i]<B[i]){ cout << "LESS" << endl; return 0; } } cout << "EQUAL" << endl; return 0; }
a.cc:1:10: fatal error: bits/stdc: No such file or directory 1 | #include <bits/stdc> | ^~~~~~~~~~~ compilation terminated.
s439861143
p03738
C++
#include <bits/stdc using namespace std; int main(void){ string A, B; cin >> A >> B; int a = A.size(); int b = B.size(); if(a>b){ cout << "GREATER" << endl; return 0; }else if(a<b){ cout << "LESS" << endl; return 0; } for(int i=a-1; i>=0; i--){ if(A[i]>B[i]){ cout << "GREATER" << endl; return 0; }else if(A[i]<B[i]){ cout << "LESS" << endl; return 0; } } cout << "EQUAL" << endl; return 0; }
a.cc:1:20: error: missing terminating > character 1 | #include <bits/stdc | ^ a.cc:1:10: fatal error: bits/stdc: No such file or directory 1 | #include <bits/stdc | ^ compilation terminated.
s082012208
p03738
Java
import java.util.Scanner; public class Tester { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s1 = in.next(); String s2 = in.next(); in.close(); if(s1.length() > s2.length()) { System.out.println("Greater"); } else if(s1.length() < s2.length()) { System.out.println("LESS"); } else if(s1.compareTo(s2) > 0) { System.out.println("Greater"); } else if(s1.compareTo(s2) < 0) { System.out.println("LESS"); } else { System.out.println("EQUAL"); } } }
Main.java:3: error: class Tester is public, should be declared in a file named Tester.java public class Tester { ^ 1 error
s127787195
p03738
C++
#include <iostream> #include <string> using namespace std; int main(void) { string A, B; cin >> A >> B; if (A.length() > B.length()) { while (B.length() < A.length()) { B = "0" + B; } } else { while (A.length() < B.length()) { A = "0" + A; } } if (strcmp(A.c_str(), B.c_str()) > 0) { cout << "GREATER" << endl; } else if (strcmp(A.c_str(), B.c_str()) < 0) { cout << "LESS" << endl; } else { cout << "EQUAL" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:13: error: 'strcmp' was not declared in this scope 20 | if (strcmp(A.c_str(), B.c_str()) > 0) { | ^~~~~~ a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s457889715
p03738
C++
int main() { int A, B; cin >> A >> B; if (A - B > 0) { cout << "GREATER" << endl; } else if (A - B == 0) { cout << "EQUAL" << endl; } else { cout << "LESS" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:3:3: error: 'cin' was not declared in this scope 3 | cin >> A >> B; | ^~~ a.cc:5:5: error: 'cout' was not declared in this scope 5 | cout << "GREATER" << endl; | ^~~~ a.cc:5:26: error: 'endl' was not declared in this scope 5 | cout << "GREATER" << endl; | ^~~~ a.cc:7:5: error: 'cout' was not declared in this scope 7 | cout << "EQUAL" << endl; | ^~~~ a.cc:7:24: error: 'endl' was not declared in this scope 7 | cout << "EQUAL" << endl; | ^~~~ a.cc:9:5: error: 'cout' was not declared in this scope 9 | cout << "LESS" << endl; | ^~~~ a.cc:9:23: error: 'endl' was not declared in this scope 9 | cout << "LESS" << endl; | ^~~~
s990176102
p03738
C++
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { string s1, s2,s3; cin>>s1>>s2; bool f = false; if(s1 == s2) { cout<<"EQUAL"<<endl; return 0; } if(s1.size()>s2.size()) f = true; else if(s1.size() == s2.size() && (s1>s2) f = true; if(f) { cout<<"GREATER"; return 0; } else { cout<<"LESS"; return 0; } }
a.cc: In function 'int main(int, const char**)': a.cc:20:50: error: expected ';' before 'f' 20 | else if(s1.size() == s2.size() && (s1>s2) f = true; | ^~ | ; a.cc:22:9: error: expected primary-expression before 'if' 22 | if(f) | ^~ a.cc:20:60: error: expected ')' before 'if' 20 | else if(s1.size() == s2.size() && (s1>s2) f = true; | ~ ^ | ) 21 | 22 | if(f) | ~~ a.cc:35:1: error: expected primary-expression before '}' token 35 | } | ^
s487047139
p03738
C++
#include <iostream> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <string> #include <set> #include <map> using namespace std; typedef long long ll; int main() { //freopen("/Users/qianjay/Documents/apac/in", "r", stdin); char s1[1024],s2[1024]; scanf("%s%s",s1,s2); if(strcmp(s1, s2)<0) { cout<<"LESS"<<endl; } else if(strcmp(s1, s2)==0)cout<<"EQUAL"<<endl; else cout<<"GREATER"<<endll; return 0; }
a.cc: In function 'int main()': a.cc:27:27: error: 'endll' was not declared in this scope 27 | else cout<<"GREATER"<<endll; | ^~~~~
s878524061
p03738
C++
a = int(input()) b = int(input()) if a > b: print("GREATER") elif a < b: print("LESS") else: print("EQUAL")
a.cc:1:1: error: 'a' does not name a type 1 | a = int(input()) | ^
s688656777
p03738
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; public class ProblemB { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String line = input.readLine(); BigInteger A = new BigInteger(line); line = input.readLine(); BigInteger B = new BigInteger(line); if (A.compareTo(B)==1) { System.out.println("GREATER"); } else if (A.compareTo(B)==-1) { System.out.println("LESS"); } else { System.out.println("EQUAL"); } } }
Main.java:6: error: class ProblemB is public, should be declared in a file named ProblemB.java public class ProblemB { ^ 1 error
s245663693
p03739
C++
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0) #define ALL(x) (x).begin(),(x).end() template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;} template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;} template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);} template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);} template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);} int main() { int n; cin >> n; vector<int> a(n); rep(i,n) cin >> a[i]; ll ans_p = 0; ll sum_p = 0; rep(i, n) { if(i%2) { // - if(sum_p + a[i] < 0) { sum_p += a[i]; } else { ans_p += (sum_p+a[i]) + 1; sum_p = -1; } } else { // + if(sum_p + a[i] > 0) { sum_p += a[i]; } else { ans_p += abs(sum_p+a[i]) + 1; sum_p = 1; } } } ll ans_m = 0; ll sum_m = 0; rep(i, n) { if(!(i%2)) { // + if(sum_m + a[i] < 0) { sum_m += a[i]; } else { ans_m += (sum_m+a[i]) + 1; sum_m = -1; } } else { // - if(sum_m + a[i] > 0) { sum_m += a[i]; } else { ans_m += abs(sum_m+a[i]) + 1; sum_m = 1; } } } cout << min(ans_m, ans_p) << endl; }
a.cc:3:9: fatal error: atcoder/all: No such file or directory 3 | #include<atcoder/all> | ^~~~~~~~~~~~~ compilation terminated.
s341048926
p03739
C++
#include <iostream> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) long long main(void){ long long n; cin >> n; long long a[n]; rep(i,n){ cin >> a[i]; } long long ans = 1000000000; for(long long p=0;p<=1;p++){ long long tmpans = 0; long long sum = 0; rep(i,n){ if(i % 2 == p){ if(a[i] + sum <= 0){ tmpans += 1 - (a[i] + sum); sum = 1; } else{ sum = a[i] + sum; } } else{ if(a[i] + sum >= 0){ tmpans += 1 + a[i] + sum; sum = -1; } else{ sum = a[i] + sum; } } } ans = min(ans,tmpans); } cout << ans << endl; }
cc1plus: error: '::main' must return 'int'
s652657135
p03739
C++
#includ<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; int sum=arr[0]; int sum1,sum2; int ans1=0,ans2=0; // case 1 if(sum>0) { sum1=sum; sum2=-1; ans1=0; ans2=sum+1; } else if(sum<0) { sum2=sum; sum1=1; ans2=0; ans1=abs(sum)+1; } else { sum1=1; sum2=1; ans2=1; ans1=1; } for(int i=1;i<n;i++) { if(sum1>0) { sum1=sum1+arr[i]; if(sum1<0) continue; else { ans1+=sum1+1; sum1=-1; } } else { sum1=sum1+arr[i]; if(sum1>0) continue; else { ans1+=abs(sum1)+1; sum1=1; } } } // case 2; for(int i=1;i<n;i++) { if(sum2>0) { sum2=sum2+arr[i]; if(sum2<0) continue; else { ans2+=sum2+1; sum2=-1; } } else { sum2=sum2+arr[i]; if(sum2>0) continue; else { ans2+=abs(sum2)+1; sum2=1; } } } if(ans1<ans2) cout<<ans1; else cout<<ans2; cout<<endl; }
a.cc:1:2: error: invalid preprocessing directive #includ; did you mean #include? 1 | #includ<bits/stdc++.h> | ^~~~~~ | include a.cc: In function 'int main()': a.cc:5:4: error: 'cin' was not declared in this scope 5 | cin>>n; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #includ<bits/stdc++.h> a.cc:23:11: error: 'abs' was not declared in this scope 23 | ans1=abs(sum)+1; | ^~~ a.cc:48:19: error: 'abs' was not declared in this scope 48 | { ans1+=abs(sum1)+1; | ^~~ a.cc:69:19: error: 'abs' was not declared in this scope 69 | { ans2+=abs(sum2)+1; | ^~~ a.cc:76:5: error: 'cout' was not declared in this scope 76 | cout<<ans1; | ^~~~ a.cc:76:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:78:4: error: 'cout' was not declared in this scope 78 | cout<<ans2; | ^~~~ a.cc:78:4: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:79:2: error: 'cout' was not declared in this scope 79 | cout<<endl; | ^~~~ a.cc:79:2: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:79:8: error: 'endl' was not declared in this scope 79 | cout<<endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #includ<bits/stdc++.h>
s869276180
p03739
C++
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; long int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; long int sum=arr[0]; long int ans=0; if(sum==0) { if(arr[i]>=0) { ans++; sum=-1; } else { ans++; sum=1; } } for(int i=1;i<n;i++) { if(sum<0) { sum=sum+arr[i]; if(sum>0) continue; else { ans+=abs(sum)+1; sum=1; } } else { sum+=arr[i]; if(sum<0) continue; else { ans+=sum+1; sum=-1; } } } cout<<ans; }
a.cc: In function 'int main()': a.cc:12:12: error: 'i' was not declared in this scope 12 | { if(arr[i]>=0) | ^
s207386222
p03739
C++
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; long int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; long int sum=arr[0]; long int ans=0; for(int i=1;i<n;i++) { if(sum<0) { sum=sum+arr[i]; if(sum>0) continue; else { ans+=abs(sum)+1; sum=1; } } else if { sum+=arr[i]; if(sum<0) continue; else { ans+=sum+1; sum=-1; } } } cout<<ans; }
a.cc: In function 'int main()': a.cc:23:7: error: expected '(' before '{' token 23 | { | ^ | (
s021259189
p03739
C++
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; long int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; long int sum=arr[0]; long int ans=0; for(int i=1;i<n;i++0 { if(sum<0) { sum=sum+arr[i]; if(sum>0) continue; else { ans+=abs(sum)+1; sum=1; } } else if { sum+=arr[i]; if(sum<0) continue; else { ans+=sum+1; sum=-1; } } } cout<<ans; }
a.cc: In function 'int main()': a.cc:11:21: error: expected ')' before numeric constant 11 | for(int i=1;i<n;i++0 | ~ ^ | ) a.cc:11:22: error: expected ';' before '{' token 11 | for(int i=1;i<n;i++0 | ^ | ; 12 | { if(sum<0) | ~
s982653322
p03739
C++
#include <bits/stdc++.h> using namespace std; using llong = long long; void input(vector<int>& rvnNum) { int nSize; cin >> nSize; rvnNum.resize(nSize); for (int& rnElm : rvnNum) cin >> rnElm; } llong calcMinOpeTimes(const vector<int>& cnrvnNum) { vector<llong> vnOpeTimes(2); for (int nEvnOdd = 0; nEvnOdd < vnOpeTimes.size(); nEvnOdd++) { llong nOpeTimes = 0; llong nCumlSum = 0; for (int n = 0; n < cnrvnNum.size(); n++) { nCumlSum += cnrvnNum[n]; if ( n % 2 == nEvnOdd ) if ( nCumlSum > 0 ); else { nOpeTimes += 1 - nCumlSum; nCumlSum = 1; } else if ( nCumlSum < 0 ); else { nOpeTimes += nCumlSum - (-1); nCumlSum = -1; } else; } vnOpeTimes[nEvnOdd] = nOpeTimes; } auto itElm = min_element(begin(vnOpeTimes), end(vnOpeTimes)); return *itElm; } int main() { vector<int> vnNum; input(vnNum); cout << calcMinOpeTimes(vnNum) << endl; return 0; }
a.cc: In function 'llong calcMinOpeTimes(const std::vector<int>&)': a.cc:40:9: error: 'else' without a previous 'if' 40 | else; | ^~~~
s685915773
p03739
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int d[n]; for(int i=0;i<n;i++) { cin >> d[i]; } int count=0; int sum=d[0]; int f =0; if(d[0]>0){ f=-1; } if(d[0]<0){ f=1; } for(int i=1;i<n;i++){ sum+=d[i]; if(sum==0){ if(f==1){ count++; f=-1; sum=1; continue; } if(f==-1){ count++; f=1; sum=-1; continue; } } if(sum>0){ if(f==1){ f=-1; continue; } if(f==-1){ count+=sum+1; sum=-1; f=1; continue; } } if(sum<0){ if(f==-1){ f=1; continue; } if(f==1){ count+=1-sum; sum=1; f=-1; continue; } } } int ccount=0; int ssum; int ff =0; if(d[0]>0){ ff=1; ccount=1+d[0]; ssum=-1; } if(d[0]<0){ ff=-1; ccount=1-d[0]; ssum=1; } for(int i=1;i<n;i++){ ssum+=d[i]; if(ssum==0){ if(ff==1){ ccount++; ff=-1; ssum=1; continue; } if(ff==-1){ ccount++; ff=1; ssum=-1; continue; } } if(ssum>0){ if(ff==1){ ff=-1; continue; } if(ff==-1){ ccount+=ssum+1; ssum=-1; ff=1; continue; } } if(ssum<0){ if(ff==-1){ ff=1; continue; } if(ff==1){ ccount+=1-ssum; ssum=1; ff=-1; continue; } } } int s= min(count,ccount) cout << s << endl; }
a.cc: In function 'int main()': a.cc:117:2: error: expected ',' or ';' before 'cout' 117 | cout << s << endl; | ^~~~
s009494296
p03739
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int d[n]; for(int i=0;i<n;i++) { cin >> d[i]; } int count=0; int sum=d[0]; int f =0; if(d[0]>0){ f=-1; } if(d[0]<0){ f=1; } for(int i=1;i<n;i++){ sum+=d[i]; if(sum==0){ if(f==1){ count++; f=-1; sum=1; continue; } if(f==-1){ count++; f=1; sum=-1; continue; } } if(sum>0){ if(f==1){ f=-1; continue; } if(f==-1){ count+=sum+1; sum=-1; f=1; continue; } } if(sum<0){ if(f==-1){ f=1; continue; } if(f==1){ count+=1-sum; sum=1; f=-1; continue; } } } int ccount=0; int ssum=; int ff =0; if(d[0]>0){ ff=1; ccount=-1-d[0]; ssum=-1; } if(d[0]<0){ ff=-1; ccount=1-d[0]; ssum=1; } for(int i=1;i<n;i++){ sum+=d[i]; if(ssum==0){ if(ff==1){ ccount++; ff=-1; ssum=1; continue; } if(ff==-1){ ccount++; ff=1; ssum=-1; continue; } } if(ssum>0){ if(f==1){ ff=-1; continue; } if(ff==-1){ ccount+=sum+1; ssum=-1; ff=1; continue; } } if(ssum<0){ if(ff==-1){ ff=1; continue; } if(ff==1){ ccount+=1-sum; ssum=1; ff=-1; continue; } } } cout << min(count,ccount) << endl; }
a.cc: In function 'int main()': a.cc:63:12: error: expected primary-expression before ';' token 63 | int ssum=; | ^
s914842609
p03739
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int d[n]; for(int i=0;i<n;i++) { cin >> d[i]; } int count=0; int sum=d[0]; int f =0; if(d[0]>0){ f=-1; } if(d[0]<0){ f=1; } for(int i=1;i<n;i++){ sum+=d[i]; if(sum>0){ if(f==1){ f=-1; continue; } if(f==-1){ count+=sum+1; sum=-1; f=1; continue; } } if(sum<0){ if(f==-1){ f=1; continue; } if(f==1){ count+=1-sum; sum=1; f=-1; continue; } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:48:2: error: expected '}' at end of input 48 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s341915026
p03739
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int d[n]; for(int i=0;i<n;i++) cin >> d[i]; int count=0; int sum=d[0]; int f =0; if(d[0]>0){ f=-1; } if(d[0]<0){ f=1; } for(int i=1;i<n;i++){ sum+=d[i]; if(sum>0){ if(f==1){ f=-1; continue; } if(f==-1){ count+=sum+1; sum=-1; f=1; continue; } } if(sum<0){ if(f==-1){ f=1; continue; } if(f==1){ count+=1-sum; sum=1; f=-1; continue; } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:46:2: error: expected '}' at end of input 46 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s354017414
p03739
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int d[n]; for(int i=0;i<n;i++) cin >> d[i]; int count=0; int sum=d[0]; int f =0; if(d[0]>0){ f=-1; } if(d[0]<0){ f=1; } for(int i=1;i<n;i++){ sum+=d[i]; if(sum>0){ if(f==1) { f=-1; continue; } if(f==-1){ count+=sum+1; sum=-1; f=1; continue; } if(sum<0){ if(f==-1){ f=1; continue; } if(f==1){ count+=1-sum; sum=1; f=-1; continue; } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:19:21: note: to match this '{' 19 | for(int i=1;i<n;i++){ | ^ a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s369337435
p03739
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; int main(){ int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; int sum = 0; int sign = 1; int cout = 0; int ans = INT_MAX; // if 0 +1 rep(j, 2){ if (j == 0) sign = 1; else sign = -1; sum = 0; cout = 0; rep(i, n){ sum += a[i]; if ((sign > 0) && (sum <= 0)){ cout += (1 - sum); sum = 1; } else if ((sign < 0) && (sum >= 0)){ cout += abs(-1 - sum); sum = -1; } sign = sign == 1 ? -1 : 1; } if (ans > cout) ans = cout; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:15: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 36 | cout << ans << endl; | ~~~~~~~~~~~~^~~~~~~
s078797773
p03739
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, c) for (int i = 0; i < (int)c; i++) int main() { int n; scanf("%d", &n); vector<int> a(n); rep(i, n) scanf("%d", &a[i]); ll temp = 0; //+- ll pm = 0; rep(i, n) { temp = temp + a[i]; if(i % 2 == 0) { if(temp <= 0) { pm = pm + 1 - temp; temp = 1; } } else { if(temp >= 0) { pm = pm + 1 + temp; temp = -1; } } } //-+ ll mp = 0; temp = 0; rep(i, n) { temp = temp + a[i]; if(i % 2 == 1) { if(temp <= 0) { mp = mp + 1 - temp; temp = 1; } } else { if(temp >= 0) { mp = mp + 1 + temp; temp = -1; } } } printf("%lld\n", min(pm, mp)); return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: 'll' was not declared in this scope 11 | ll temp = 0; | ^~ a.cc:14:11: error: expected ';' before 'pm' 14 | ll pm = 0; | ^~~ | ; a.cc:16:17: error: 'temp' was not declared in this scope; did you mean 'tm'? 16 | temp = temp + a[i]; | ^~~~ | tm a.cc:19:33: error: 'pm' was not declared in this scope; did you mean 'tm'? 19 | pm = pm + 1 - temp; | ^~ | tm a.cc:25:33: error: 'pm' was not declared in this scope; did you mean 'tm'? 25 | pm = pm + 1 + temp; | ^~ | tm a.cc:32:11: error: expected ';' before 'mp' 32 | ll mp = 0; | ^~~ | ; a.cc:33:9: error: 'temp' was not declared in this scope; did you mean 'tm'? 33 | temp = 0; | ^~~~ | tm a.cc:38:33: error: 'mp' was not declared in this scope 38 | mp = mp + 1 - temp; | ^~ a.cc:44:33: error: 'mp' was not declared in this scope 44 | mp = mp + 1 + temp; | ^~ a.cc:50:30: error: 'pm' was not declared in this scope; did you mean 'tm'? 50 | printf("%lld\n", min(pm, mp)); | ^~ | tm a.cc:50:34: error: 'mp' was not declared in this scope 50 | printf("%lld\n", min(pm, mp)); | ^~
s122288353
p03739
C++
#include <bits/stdc++.h> #include <cassert> #define rep(i,n) for (int i = 0; i < (n); ++i) #define ok() puts(ok?"Yes":"No"); #define chmax(x,y) x = max(x,y) #define chmin(x,y) x = min(x,y) using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using ii = pair<int, int>; using vvi = vector<vi>; using vii = vector<ii>; using gt = greater<int>; using minq = priority_queue<int, vector<int>, gt>; using P = pair<ll,ll>; const ll LINF = 1e18L + 1; const int INF = 1e9 + 1; //clang++ -std=c++11 -stdlib=libc++ int main() { int n; cin >> n; int a(n); rep(i,n) cin>>a[i]; ll ans = LINF; // even is positive // odd is nevgative ll sum=0; ll num=0; rep(i,n) { sum+=a[i]; if (i&1) { if (sum>=0) { num += (sum + 1); sum = -1; } } else { if (sum <= 0) { num += (-sum + 1); sum = 1; } } } chmin(ans, num); // even is negative // odd is positive num = 0; sum = 0; rep(i,n) { sum+=a[i]; if (i&1) { if (sum <= 0) { num += (-sum + 1); sum = 1; } } else { if (sum>=0) { num += (sum + 1); sum = -1; } } } chmin(ans, num); printf("%lld\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:24:18: error: invalid types 'int[int]' for array subscript 24 | rep(i,n) cin>>a[i]; | ^ a.cc:32:11: error: invalid types 'int[int]' for array subscript 32 | sum+=a[i]; | ^ a.cc:51:11: error: invalid types 'int[int]' for array subscript 51 | sum+=a[i]; | ^
s509467563
p03739
C++
#include<bits/stdc++.h> #define FF ios_base::sync_with_stdio(0);cin.tie(0) #define binary(value, size) cout << bitset<size>(value) << '\n' #define PI acos(-1.0) //3.1416(180 degree to radian) #define PIby2 asin(1) //(3.1416/2) for angle(90 degree to radian) #define eps 1e-67 #define pf printf #define sf scanf #define sz size() #define rr read #define ww write #define clr(arr) memset((arr),0,(sizeof(arr))) #define rep(i,a,b) for(long long int i=a;i<b;i++) #define repb(i,a,b) for(long long int i=a;i>=b;i--) #define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c) #define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c) #define asort(a) sort(a.begin(),a.end()) #define asort2(a,comp) sort(a.begin(),a.end(),comp) #define arev(a) reverse(a.begin(),a.end()) #define all(v) (v).begin(),(v).end() #define all2(v,a,b) (v).begin()+a,(v).end()-b #define F first #define S second #define pb push_back #define eb emplace_back #define pbb pop_back #define mp make_pair #define mt make_tuple #define BS(v,x) binary_search(v.begin(),v.end(),x) //return true /false #define LB(v,x) lower_bound(v.begin(),v.end(),x) //found and that value and not found than greater value pos #define UB(v,x) upper_bound(v.begin(),v.end(),x) //found and greater value pos && not found also greater pos #define convertlower(c) towlower(c) #define root(x) sqrt(x) #define power(a,n) pow(a,n) #define tu(c) towupper(c) #define sq(a) ((a)*(a)) #define cube(a) ((a)*(a)*(a)) #define mx 1000 #define MX 100000 #define mod 1000000007 #define INF 2000000000 #define N 10000000 #define Ceil(n) (long long int)ceil(n) #define Floor(n) (long long int)floor(n) #define deb(x) std::cout << #x << " = " << x << std::endl; #define out(ans) cout<<ans<<endl #define outs(ans) cout<<ans<<" "<<endl using namespace std; typedef string str; typedef long long int ll; typedef double lf; typedef long double llf; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<pll> vpll; typedef char ch; typedef map<ll,ll> mpl; int main() { ll tc; cin>>n; vll v; rep(i,0,n) { ll d; cin>>d; v.pb(d); } ll sign=1,sum=0,ans1=0,ans2=0; rep(i,0,n) { sum+=v[i]; if(sign*sum<=0) ans1+=labs(sign-sum),sum=sign; sign*=-1; } sign=-1,sum=0; rep(i,0,n) { sum+=v[i]; if(sign*sum<=0) ans2+=labs(sign-sum),sum=sign; sign*=-1; } cout<<min(ans1,ans2)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:68:10: error: 'n' was not declared in this scope; did you mean 'yn'? 68 | cin>>n; | ^ | yn
s160324771
p03739
C++
#include<bits/stdc++.h> #define FF ios_base::sync_with_stdio(0);cin.tie(0) #define binary(value, size) cout << bitset<size>(value) << '\n' #define PI acos(-1.0) //3.1416(180 degree to radian) #define PIby2 asin(1) //(3.1416/2) for angle(90 degree to radian) #define eps 1e-67 #define pf printf #define sf scanf #define sz size() #define rr read #define ww write #define clr(arr) memset((arr),0,(sizeof(arr))) #define rep(i,a,b) for(long long int i=a;i<b;i++) #define repb(i,a,b) for(long long int i=a;i>=b;i--) #define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c) #define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c) #define asort(a) sort(a.begin(),a.end()) #define asort2(a,comp) sort(a.begin(),a.end(),comp) #define arev(a) reverse(a.begin(),a.end()) #define all(v) (v).begin(),(v).end() #define all2(v,a,b) (v).begin()+a,(v).end()-b #define F first #define S second #define pb push_back #define eb emplace_back #define pbb pop_back #define mp make_pair #define mt make_tuple #define BS(v,x) binary_search(v.begin(),v.end(),x) //return true /false #define LB(v,x) lower_bound(v.begin(),v.end(),x) //found and that value and not found than greater value pos #define UB(v,x) upper_bound(v.begin(),v.end(),x) //found and greater value pos && not found also greater pos #define convertlower(c) towlower(c) #define root(x) sqrt(x) #define power(a,n) pow(a,n) #define tu(c) towupper(c) #define sq(a) ((a)*(a)) #define cube(a) ((a)*(a)*(a)) #define mx 1000 #define MX 100000 #define mod 1000000007 #define INF 2000000000 #define N 10000000 #define Ceil(n) (long long int)ceil(n) #define Floor(n) (long long int)floor(n) #define deb(x) std::cout << #x << " = " << x << std::endl; #define out(ans) cout<<ans<<endl #define outs(ans) cout<<ans<<" "<<endl using namespace std; typedef string str; typedef long long int ll; typedef double lf; typedef long double llf; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<pll> vpll; typedef char ch; typedef map<ll,ll> mpl; //vector<vector<int>> grid(n, vector<int>(n, 0)); 2D Array bool isLetter(char c) { return (c >= 'A' and c <= 'Z') or (c >= 'a' and c <= 'Z'); } bool isUpperCase(char c) { return c >= 'A' and c <= 'Z'; } bool isLowerCase(char c) { return c >= 'a' and c <= 'z'; } bool isDigit(char c) { return c >= '0' and c <= '9'; } bool isVowel(char c) { return c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u'; } bool isConsonant(char c) { return !isVowel(c); } template<class T> void Debug(T v) { for(int i=0; i<(int)v.size(); i++)cout << v[i] <<" "; cout<<endl; } template<class T> void Input(T &v) { for(int i=0; i<(int)v.size(); i++)cin >> v[i]; } template<class T> string toString(T n) { ostringstream ost; ost << n; ost.flush(); return ost.str(); } string intTobinary(int x) { std::string binary = std::bitset<32>(x).to_string(); return binary; } //BigMod (a^p)%mod template<typename A, typename P> int BigMod(A a, P p, const int MOD) { int ret = 1; while(p) { if(p & 1)ret = (1LL * ret * a) % MOD; a = (1LL * a * a) % MOD; p >>= 1LL; } return ret; } //Base (value,base) template<typename T> T toBase(T n, T base) { T ret = 0LL; while(n) { ret += n % base; ret *= 10LL; n /= base; } return ret; } // Divisor template<typename T> vector<T> Divisor(T value) { vector<T> v; for(int i = 1LL; i * i <= value; ++i) { if(value % i == 0) { v.push_back(i); if(i * i != value) v.push_back(value / i); } } return v; } //Primes template<typename T> bool prime(T n) { if (n % 2 == 0) return 0; for (T i = 3; i*i <= n; i += 2) { if (n % i == 0) return 0; } return 1; } //Sieve template<typename T> void SieveOfEratostheness(T n) { bool prime[n+1]; memset(prime, true, sizeof(prime)); for (T p=2; p*p<=n; p++) { if (prime[p] == true) { for (int i=p*p; i<=n; i += p) prime[i] = false; } } } //Math template<typename T> ll sum(std::vector<T> &v) { return std::accumulate(all(v), 0); } template<typename T> T minval(std::vector<T> &v) { return *std::min_element(all(v)); } template<typename T> T maxval(std::vector<T> &v) { return *std::max_element(all(v)); } template<typename T> void make_unique(std::vector<T> &v) { v.resize(unique(all(v)) - v.begin()); } template<typename T> void make_unique_sorted(std::vector<T> &v) { asort(v); v.resize(unique(all(v)) - v.begin()); } template<typename T> int lowerBound(std::vector<T> &v, T x) { return v.back() < x ? -1 : lower_bound(all(v), x) - v.begin(); } template<typename T> int upperBound(std::vector<T> &v, T x) { return v.back() < x ? -1 : upper_bound(all(v), x) - v.begin(); } double startTime = clock(); void showCurrentTime() { printf("%.6lf\n", ((double)clock() - startTime) / CLOCKS_PER_SEC); } //Graph /* std::vector<int> g[N], v, lev[N]; int par[N], vis[N]; void init(){ for(int i = 0; i < N; i++){ g[i].clear(); lev[i].clear(); par[i] = -1; vis[i] = 0; } } //DFS void dfs(int u, int p = -1, int d = 0){ lev[d].pb(u); par[u] = p; for( auto v : g[u]){ if(p == v) continue; dfs(v, u, d + 1); } } */ /* Graph representation: cin>>n>>ed; vi ar[n+1]; while(ed--) {cin>>a>>b) ar[a].pb(b); ar[b].pb(a); (if directed then comment out) } /* //DFS /* bool vis[MX]={0}; int graph[MX]; void DFS(int v) { vis[v]=1; rep(i,0,graph[v].size())//for(int child:graph[v]) { int child=graph[v][i]; if(vis[child]==0) { DFS(child); } } } */ //BFS /* vector<int> graph[10001]; bool vis[MX]={0}; int dist[MX]; int par[MX]; void BFS(int source) { queue<int> q; vis[source]=1; dist[source]=0; q.push(source); while(!q.empty()) { int node=q.front(); q.pop(); rep(i,0,graph[node].size()) { int next=graph[node][i]; if(vis[next]==0) { vis[next]=1; dist[next]=dist[node]+1; q.push(next); par[next]=node; } } } } */ //Bit Hacks ll MakeOneBit(ll decimalvalue, int pos) { return (decimalvalue | (1 << pos)); //make pos bit of value 1 } ll MakeZeroBit(ll decimalvalue, int pos) { return (decimalvalue & ~(1 << pos)); //make pos of value bit 0 } ll FlipBit(ll decimalvalue, int pos) { return (decimalvalue ^ (1 << pos)); //flip pos bit of value reverse } bool CheckBit(ll decimalvalue, int pos) { return (decimalvalue & (1 << pos)); } int MSB(ll k) { return ( 63 - __builtin_clzll(k)); // leftmost set bit } int LSB(ll k) { return __builtin_ffs(k)-1 ; // right most set bit } int Totalset(ll decimalvalue) { return __builtin_popcountll(decimalvalue); //total 1 in value } int Totolnotset(ll decimalvalue) { return MSB(decimalvalue) - Totalset(decimalvalue) + 1; //total 0 in value } bool ispow2(int i) { return i&&(i&-i)==i; } ll nC2(ll n) { return (n * (n - 1)) / 2; } ll nc3(ll n) { return (n * (n - 1) * (n - 2)) / 6; } ll apsum(ll n, ll a = 1, ll d = 1) { return (n * (a + a + (n - 1) * d) ) / 2; } ll LCM(ll a, ll b) { return (a / __gcd(a, b) ) * b; } ll OnetoNsum(ll n) { return (n*(n+1))/2; } //cout<<setprecision(decimal)<<value<<endl; //vector<vector<int>> grid(n, vector<int>(n, 0)); 2D Array int main() { ll tc; cin>>n; vll v; rep(i,0,n) { ll d; cin>>d; v.pb(d); } ll sign=1,sum=0,ans1=0,ans2=0; rep(i,0,n) { sum+=v[i]; if(sign*sum<=0) ans1+=labs(sign-sum),sum=sign; sign*=-1; } sign=-1,sum=0; rep(i,0,n) { sum+=v[i]; if(sign*sum<=0) ans2+=labs(sign-sum),sum=sign; sign*=-1; } cout<<min(ans1,ans2)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:402:10: error: 'n' was not declared in this scope; did you mean 'yn'? 402 | cin>>n; | ^ | yn
s317901475
p03739
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); ++i) #define rep2(i,s,n) for(int i = (s); i < (n); ++i) #define ll long long #define ld long double #define P pair<ll,ll> #define all(v) v.begin(),v.end() const ll mod = 1e9+7; const ll INF = 1e18; const double pi = acos(-1.0); int main(void) { ll n; cin>>n; vector<ll> a(n); rep(i,n) cin>>a[i]; ll ans=0,sum=0; rep(i,n){ sum+=a[i]; if(i%2==0){ if(sum<=0){ ans+=abs(1-sum); sum=1; } else{ if(sum>=0){ ans+=abs(1-sum); sum=-1; } } } } ll tmp=0,sum=0; rep(i,n){ sum+=a[i]; if(i%2==1){ if(sum<=0){ tmp+=abs(1-sum); sum=1; } else{ if(sum>=0){ tmp+=abs(1-sum); sum=-1; } } } } ans = min(ans,tmp); cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:38:14: error: redeclaration of 'long long int sum' 38 | ll tmp=0,sum=0; | ^~~ a.cc:21:14: note: 'long long int sum' previously declared here 21 | ll ans=0,sum=0; | ^~~
s777017657
p03739
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define FOR(i,start,end) for(int i=start;i<=end;i++) const int INF = 1001001001; typedef long long ll; const ll MOD=1000000007; using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); } template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); } template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); } template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); } template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); } template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a%b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; }; template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);FOR(i,1,FAC_MAX-1)fac[i]=fac[i-1]*i; ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];for(int i=FAC_MAX-2;i>=1;i--)ifac[i]=ifac[i+1]*T(i+1);} T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) {if(n%2==1)return T(0);return fac[n]*ifac[n/2]/(T(2)^(n/2));} // combination of paris for n }; typedef ModInt<1000000007> mint; int main(void){ // Your code here! int n; cin >> n; vector<ll> a(n); rep(i,n) cin >> a[i]; // +-+-.... ll sh = 0; ll nw = 0; rep(i,n) { nw += a[i]; if(i%2 == 0) { if(nw<= 0) { sh += 1 - nw; nw = 1; } } if(i%2 != 0) { if(nw>=0){ sh += nw + 1; nw = -1; } } } // -+-+... ll hs = 0; nw = 0; rep(i,n) { if(i%2 == 0) if(nw>=0) hs += 1 + nw,nw = -1; if(i%2 != 0) if(nw <= 0) += 1 - nw,nw = 1; } cout << min(hs,sh) << endl; } // 基本的にはlong long を使いましょう
a.cc: In function 'int main()': a.cc:84:34: error: expected primary-expression before '+=' token 84 | if(i%2 != 0) if(nw <= 0) += 1 - nw,nw = 1; | ^~
s901469137
p03739
C++
#include<bits/stdc++.h> using namespace std; /*int check(vector<int> a){ int time = 0; int pre_sum = a.at(0); int n = a.size(); if(a.at(0)<0){ for(int i = 1; i<n; i++){ int sum = pre_sum + a.at(i); if(i%2==1 && sum <= 0){ time += abs(sum-1); sum = 1; }else if (i%2==0 && sum >=0){ time += abs(sum+1); sum = -1; } pre_sum = sum; } }else if(a.at(0)>0){ for(int i = 1; i<n; i++){ int sum = pre_sum + a.at(i); if(i%2==0 && sum <= 0){ time += abs(sum-1); sum = 1; }else if(i%2==1 && sum >=0){ time += abs(sum+1); sum = -1; } pre_sum = sum; } } return time; } int zerocheck(vector<int> a){ a.at(0) = 1; int time1 = check(a)+1; a.at(0) = -1; int time2 = check(a)+1; int time = min(time1, time2); return time; } int main(){ int n; cin >> n; int time = 0; vector<int> a(n); for(auto& x:a){ cin >> x; } if(a.at(0) == 0){ time = zerocheck(a); }else{ time = check(a); } cout << time << endl; }*/ int main(){ int n; cin >> n; vector<int> a(n); for(auto& x: a){ cin >> x; } int sum1 = 0; int sum2 = 0; int time1 = 0; int time2 = 0; for(int i =0;i<n;i++){ sum1 += a.at(i); sum2 += a.at(i); if(i%2 == 0){ if(sum1<=0){ time1 += sum1*(-1)+1; sum1 = 1; } if(sum2>=0){ time2 += sum2+1; sum2 = -1; } } if(i%2==1){ if(sum1>=0){ time1 += sum1+1: sum1 = -1; } if(sum2<=0){ time2 += sum2*(-1)+1; sum2 = 1; } } } cout << min(time1, time2) << endl; }
a.cc: In function 'int main()': a.cc:89:48: error: expected ';' before ':' token 89 | time1 += sum1+1: | ^ | ;
s724476659
p03739
C++
#include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - #include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - k; #include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; }#include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max#include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; }#include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; }#include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum#include <stdint.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; using default_counter_t = int64_t; // macro #define let auto const& #define overload4(a, b, c, d, name, ...) name #define rep1(n) \ for (default_counter_t i = 0, end_i = default_counter_t(n); i < end_i; ++i) #define rep2(i, n) \ for (default_counter_t i = 0, end_##i = default_counter_t(n); i < end_##i; \ ++i) #define rep3(i, a, b) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; ++i) #define rep4(i, a, b, c) \ for (default_counter_t i = default_counter_t(a), \ end_##i = default_counter_t(b); \ i < end_##i; i += default_counter_t(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep2(i, n) \ for (default_counter_t i = default_counter_t(n) - 1; i >= 0; --i) #define rrep3(i, a, b) \ for (default_counter_t i = default_counter_t(b) - 1, \ begin_##i = default_counter_t(a); \ i >= begin_##i; --i) #define rrep4(i, a, b, c) \ for (default_counter_t \ i = (default_counter_t(b) - default_counter_t(a) - 1) / \ default_counter_t(c) * default_counter_t(c) + \ default_counter_t(a), \ begin_##i = default_counter_t(a); \ i >= begin_##i; i -= default_counter_t(c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) // function template <class C> constexpr C& Sort(C& a) { std::sort(std::begin(a), std::end(a)); return a; } template <class C> constexpr auto& Min(C const& a) { return *std::min_element(std::begin(a), std::end(a)); } template <class C> constexpr auto& Max(C const& a) { return *std::max_element(std::begin(a), std::end(a)); } template <class C> constexpr auto Total(C const& c) { return std::accumulate(std::begin(c), std::end(c), C(0)); } template <typename T> auto CumSum(std::vector<T> const& v) { std::vector<T> a(v.size() + 1, T(0)); for (std::size_t i = 0; i < a.size() - size_t(1); ++i) a[i + 1] = a[i] + v[i]; return a; } template <typename T> constexpr bool ChMax(T& a, T const& b) { if (a < b) { a = b; return true; } return false; } template <typename T> constexpr bool ChMin(T& a, T const& b) { if (b < a) { a = b; return true; } return false; } void In(void) { return; } template <typename First, typename... Rest> void In(First& first, Rest&... rest) { cin >> first; In(rest...); return; } template <class T, typename I> void VectorIn(vector<T>& v, const I n) { v.resize(size_t(n)); rep(i, v.size()) cin >> v[i]; } void Out(void) { cout << "\n"; return; } template <typename First, typename... Rest> void Out(First first, Rest... rest) { cout << first << " "; Out(rest...); return; } constexpr auto yes(const bool c) { return c ? "yes" : "no"; } constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } #ifdef USE_STACK_TRACE_LOGGER #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" #include <glog/logging.h> #pragma clang diagnostic pop #endif //__clang__ #endif // USE_STACK_TRACE_LOGGER signed main(int argc, char* argv[]) { (void)argc; #ifdef USE_STACK_TRACE_LOGGER google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); #else (void)argv; #endif // USE_STACK_TRACE_LOGGER int64_t n; In(n); vector<int64_t> a(n); rep(i, n) In(a[i]); bool sn = true; int64_t sum = 0; int64_t cost1 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost1 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost1 += k; sum += a[i] - k; } sn = (!sn); } sn = false; sum = 0; int64_t cost2 = 0; rep(i, n) { if (sn) { int64_t k = max(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; } += a[i] - k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; }(int64_t(0), 1 - sum - a[i]); cost2 += k; sum += a[i] + k; } else { int64_t k = max(int64_t(0), sum + a[i] + 1); cost2 += k; sum += a[i] - k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; }k; } sn = (!sn); } cout << min(cost1, cost2) << endl; return EXIT_SUCCESS; }
a.cc:173:21: error: stray '#' in program 173 | sum += a[i] - #include <stdint.h> | ^ a.cc:525:2: error: stray '#' in program 525 | }#include <stdint.h> | ^ a.cc:691:22: error: stray '#' in program 691 | int64_t k = max#include <stdint.h> | ^ a.cc:870:2: error: stray '#' in program 870 | }#include <stdint.h> | ^ a.cc:1049:2: error: stray '#' in program 1049 | }#include <stdint.h> | ^ a.cc:1221:10: error: stray '#' in program 1221 | sum#include <stdint.h> | ^ a.cc: In function 'int main(int, char**)': a.cc:173:22: error: 'include' was not declared in this scope 173 | sum += a[i] - #include <stdint.h> | ^~~~~~~ a.cc:173:31: error: 'stdint' was not declared in this scope; did you mean 'stdin'? 173 | sum += a[i] - #include <stdint.h> | ^~~~~~ | stdin a.cc:180:1: error: expected primary-expression before 'using' 180 | using namespace std; | ^~~~~ a.cc:225:1: error: a template declaration cannot appear at block scope 225 | template <class C> | ^~~~~~~~ a.cc:234:1: error: a template declaration cannot appear at block scope 234 | template <class C> | ^~~~~~~~ a.cc:242:1: error: a template declaration cannot appear at block scope 242 | template <typename T> | ^~~~~~~~ a.cc:256:1: error: a template declaration cannot appear at block scope 256 | template <typename T> | ^~~~~~~~ a.cc:267:1: error: a template declaration cannot appear at block scope 267 | template <typename First, typename... Rest> | ^~~~~~~~ a.cc:280:16: error: a function-definition is not allowed here before '{' token 280 | void Out(void) { | ^ a.cc:285:1: error: a template declaration cannot appear at block scope 285 | template <typename First, typename... Rest> | ^~~~~~~~ a.cc:293:34: error: a function-definition is not allowed here before '{' token 293 | constexpr auto Yes(const bool c) { return c ? "Yes" : "No"; } | ^ a.cc:294:34: error: a function-definition is not allowed here before '{' token 294 | constexpr auto YES(const bool c) { return c ? "YES" : "NO"; } | ^ a.cc:305:37: error: a function-definition is not allowed here before '{' token 305 | signed main(int argc, char* argv[]) { | ^ a.cc:1433:2: error: expected '}' at end of input 1433 | } | ^ a.cc:133:37: note: to match this '{' 133 | signed main(int argc, char* argv[]) { | ^
s539977042
p03739
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); for(auto& x:a){ cin >> x; } int sum = 0; int count1 = 0; int count2 = 0; for(int i = 0; i<n; i++){ sum += a.at(i); if(i_sum>=0 && i%2==1){ sum -= abs(sum)+1; count1 += abs(sum) +1; }else if(i_sum<=0 && i%2==0){ sum += abs(sum)+1; count1 += abs(sum)+1; } } sum =0; for(int i = 0; i<n; i++){ sum += a.at(i); if(i_sum>=0 && i%2==0){ sum -= abs(sum)+1; count2 += abs(sum) +1; }else if(i_sum<=0 && i%2==1){ sum += abs(sum)+1; count2 += abs(sum)+1); } } int count; count = min(count1, count2); cout << count << endl; }
a.cc: In function 'int main()': a.cc:18:20: error: 'i_sum' was not declared in this scope; did you mean 'sum'? 18 | if(i_sum>=0 && i%2==1){ | ^~~~~ | sum a.cc:29:28: error: 'i_sum' was not declared in this scope; did you mean 'sum'? 29 | if(i_sum>=0 && i%2==0){ | ^~~~~ | sum a.cc:34:61: error: expected ';' before ')' token 34 | count2 += abs(sum)+1); | ^ | ;
s758854083
p03739
C++
#include <bits/stdc++.h> using namespace std; int keta(int num){ int ans= 0 ; int rem; for (int i = 4; i >= 0 ; i--){ rem = pow(10,i); ans += (num / rem); num = num % rem; } return ans; } int main() { int n; cin >> n; vector<int64_t> ar(n); for(int i = 0; i < n; i++){ cin >> ar[i]; } int ans1, ans2 = 0; int cum = 0; //偶数が正の場合 for(int i = 0; i < n; i++){ int next = cum + ar[i]; if(i % 2 == 0){ if(next <= 0){ ans1 += abs(next - 1); cum = 1; }else{ cum = next; } }else{ if(next >= 0){ ans1 += abs(next + 1); cum = -1; }else{ cum = next; } } //偶数が負の場合 for(int i = 0; i < n; i++){ int next = cum + ar[i]; if(i % 2 == 0){ if(next >= 0){ ans2 += abs(next + 1); cum = -1; }else{ cum = next; } }else{ if(next <= 0){ ans2 += abs(next - 1); cum = 1; }else{ cum = next; } } cout << min(ans1, ans2) << endl; }
a.cc: In function 'int main()': a.cc:72:2: error: expected '}' at end of input 72 | } | ^ a.cc:32:29: note: to match this '{' 32 | for(int i = 0; i < n; i++){ | ^ a.cc:72:2: error: expected '}' at end of input 72 | } | ^ a.cc:17:12: note: to match this '{' 17 | int main() { | ^
s428700774
p03739
C++
#include <bits/stdc++/h> using namespace std; int change_num(int a[], int N) int res int sum = a[0]; for (int i = 1; i < N; i++) { if(sum * (sum + a[i]) < 0) continue; if(sum > 0 && sum + a[i] >= 0) { sum += a[i]; while (sum + a[i] >= 0) { res++; sum--; } } else if (sum < 0 && sum + a[i] < 0) { while (sum + a[i] <= 0) { res++; sum++; } } } return res; } int main() { int N; cin >> N; int a[N]; for (int i = 0; i < N; i++) cin >> a[i]; int ans = 0; int sum = a[0]; if (a[0] == 0) { int plus_ans; a[0] = 1; plus_ans = change_num(a, N) + 1; int minus_ans = 1; a[0] = -1; minus_ans = change_num(a, N) + 1; if(plus_ans < minus_ans) { ans = plus_ans; } else { ans = minus_ans; } } else { ans = change_num(a) } cout << ans << endl; }
a.cc:1:10: fatal error: bits/stdc++/h: No such file or directory 1 | #include <bits/stdc++/h> | ^~~~~~~~~~~~~~~ compilation terminated.
s357769784
p03739
C++
#include <iostream> #include <vector> long body(std::vector<long>& a){ long ans = 0; std::vector<long> s(a.size()); s.at(0) = a.at(0); for(unsigned long i = 1; i < a.size(); i++){ s.at(i) = s.at(i-1) + a.at(i); } long diff = 0; for(unsigned long i = 1; i < s.size(); i++){ s.at(i) += diff; // update long n = 0; if(s.at(i-1) > 0 && s.at(i) >= 0){ n = s.at(i) + 1; ans += n; diff -= n; s.at(i) += diff; }else if(s.at(i-1) < 0 && s.at(i) <= 0){ n = - s.at(i) + 1; ans += n; diff += n; s.at(i) += diff; } } return ans; } int main(int argc, char **argv) { long n; std::cin >> n; std::vector<long> a(n); for(long i = 0; i < n; i++){ std::cin >> a.at(i); } if(a.at(0) != 0){ ans = body(a); }else{ a.at(0) = -1; long ans_a = body(a) + 1; a.at(0) = 1; long ans_b = body(a) + 1; ans = std::min(ans_a, ans_b); } std::cout << ans << std::endl; }
a.cc: In function 'int main(int, char**)': a.cc:43:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 43 | ans = body(a); | ^~~ | abs a.cc:49:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 49 | ans = std::min(ans_a, ans_b); | ^~~ | abs a.cc:52:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 52 | std::cout << ans << std::endl; | ^~~ | abs
s190238717
p03739
C++
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <clocale> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); #define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i) #define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i) #define VFOR(i, s, n) for(int i = (s); i < (n); ++i) #define VFORS(i, s, n) for(int i = (s); i <= (n); ++i) #define REP(i, n) FOR(i, 0, n) #define REPS(i, n) FORS(i, 0, n) #define VREP(i, n) VFOR(i, 0, n) #define VREPS(i, n) VFORS(i, 0, n) #define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i) #define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i) #define RREP(i, n) RFOR(i, n, 0) #define RREPS(i, n) RFORS(i, n, 0) #define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i) #define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i) #define ALL(v) (v).begin(), (v).end() #define SORT(v) sort(ALL(v)) #define RSORT(v) sort(ALL(v), greater<decltype(v[0])>()) #define SZ(x) ((int)(x).size()) #define REV(x) reverse(ALL(x)) #define PB push_back #define EB emplace_back #define MP make_pair #define MT make_tuple #define BIT(n) (1LL<<(n)) #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()) using ld = long double; using ll = long long; using ui = unsigned int; using ull = unsigned long long; using Pi_i = pair<int, int>; using Pll_ll = pair<ll, ll>; using VB = vector<bool>; using VC = vector<char>; using VD = vector<double>; using VI = vector<int>; using VLL = vector<ll>; using VS = vector<string>; using VSH = vector<short>; using VULL = vector<ull>; const int MOD = 1000000007; const int INF = 1000000000; //1e9 const int NIL = -1; const ll LINF = 1000000000000000000; // 1e18 const double EPS = 1E-10; template<class T, class S> bool chmax(T &a, const S &b){ if(a < b){ a = b; return true; } return false; } template<class T, class S> bool chmin(T &a, const S &b){ if(b < a){ a = b; return true; } return false; } int main(){ int n; cin >> n; VI a(n); REP(i, n) cin >> a[i]; ll ans(LLONG_MAX); REP(s, 2){ ll sum(0); ll cnt(0); REP(i, n){ int sgn = (s + i) % 2 * 2 - 1; sum += a[i]; if(sum / sgn <= 0){ cnt += abs(sum - sgn); sum = sgn; } } chmin(ans, cnt); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:102:12: error: 'LLONG_MAX' was not declared in this scope 102 | ll ans(LLONG_MAX); | ^~~~~~~~~ a.cc:30:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 29 | #include <utility> +++ |+#include <climits> 30 | #include <vector>
s546894532
p03739
C++
#include <iostream> #include <algorithm> #include <cstring> #include <string> #include <vector> #include <cmath> #include <cctype> typedef long long ll; using namespace std; int main() { int N; ll res, ans; int count = 0; cin >> N; int a[N]; for (int i = 0; i < N; i++) { cin >> a[i]; } ll sum = 0; for (int i = 1, s = 1; i <= N; i++, s *= -1) { sum += a[i]; if (sum * s <= 0) { res += abs(sum - s); sum = s; } } ll sum = 0; for (int i = 1, s = -1; i <= N; i++, s *= -1) { sum += a[i]; if (sum * s <= 0) { ans = abs(sum - s); sum = s; } } cout << min(res, ans) << endl; return 0; }
a.cc: In function 'int main()': a.cc:32:8: error: redeclaration of 'll sum' 32 | ll sum = 0; | ^~~ a.cc:23:8: note: 'll sum' previously declared here 23 | ll sum = 0; | ^~~
s175358535
p03739
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<int> data(N); for(int i=0;i<N;i++)cin>>data[i]; int count=0; int ans=data[0]; int saisyo; for(int i=1;i<N;i++){ ans+=data[i]; if(i%2==0){ while(ans<=0){ ans++; count++; } }else{ while(ans>=0){ ans--; count++; } } } saisyo=count; count=0; ans=data[0]; while(ans>=0){ ans--; count++ } for(int i=0;i<N;i++){ ans+=data[i]; if(i%2!=0){ while(ans<=0){ ans++; count++; } }else{ while(ans>=0){ ans--; count++; } } } saisyo=min(saisyo,count); cout<<saisyo<<endl; }
a.cc: In function 'int main()': a.cc:35:20: error: expected ';' before '}' token 35 | count++ | ^ | ; 36 | } | ~
s897042179
p03739
C++
// 要復習 #include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG int64_t main() { int64_t n; cin >> n; int64_t a[n], b[n]; for (int64_t i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } //positive-negative-positive... case int64_t case1, total; if (a[0] > 0) { case1 = 0; total = a[0]; } else //if (a[0] <= 0) { case1 = 1 - a[0]; total = 1; } for (int64_t i = 1; i < n; i++) { int64_t ttmp = total + a[i]; int64_t atmp = a[i]; if ((ttmp * total) < 0 && ttmp != 0) { total = ttmp; } else { if (total > 0) { a[i] = -total - 1; } else { a[i] = -total + 1; } total += a[i]; } case1 += abs(a[i] - atmp); } //negative-positive... case int64_t case2; if (b[0] < 0) { case2 = 0; total = b[0]; } else //if (a[0] >= 0) { case2 = -1 - b[0]; total = -1; } for (int64_t i = 1; i < n; i++) { int64_t ttmp = total + b[i]; int64_t atmp = b[i]; if ((ttmp * total) < 0 && ttmp != 0) { total = ttmp; } else { if (total > 0) { b[i] = -total - 1; } else { b[i] = -total + 1; } total += b[i]; } case2 += abs(b[i] - atmp); } cout << min(case1, case2) << endl; }
a.cc:7:1: error: '::main' must return 'int' 7 | int64_t main() | ^~~~~~~
s777315211
p03739
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0;i<n;i++) #define erep(i,n) for(int i = 0;i<=n;i++) #define rep1(i,n) for(int i = 1;i<n;i++) #define erep1(i,n) for(int i = 1;i<=n;i++) typedef long long ll; #define vint vector<int> #define vstring vector<string> #define vll vector<ll> #define vbool vector<bool> #define INF 100000000 ll gcm(ll a,ll b); ll lcm(ll a,ll b); ll fac(ll a); int main(){ ll n; cin >> n; ll nowsum = 0; ll ans = 0; ll sum = 0; bool plus = false; bool minus = false; vll A(n); rep(i,n){ cin >> A[i]; sum += A[i]; rep(i,n){ nowsum += A[i]; if(i == 0){ if(nowsum == 0){ if(A[1] > 0){ ans = A[i] - 1; nowsum = (-1)*abs(A[i]-1); minus = true; } else if(A[1] < 0){ ans = A[i] + 1; nowsum = abs(A[i]-1); plus = true; } else{ if(sum >= 0){ ans = 1; nowsum = 1; plus = true; } else{ ans = 1; nowsum = -1; minus = true; } } else if(nowsum >= 0) plus = true; else minus = true; } else{ if(plus){ if(i%2 == 0){ //minusだったらだめ if(nowsum <= 0){ ans += abs(nowsum -A[i] - 1) - A[i]; nowsum = 1; } } else{ //plusだったらだめ if(nowsum >= 0){ ans += A[i] + abs(nowsum -A[i] + 1); nowsum = -1; } } } else if(minus){ if(i%2 == 0){ //plusだったらだめ if(nowsum >= 0){ ans += A[i] + abs(nowsum -A[i] + 1); nowsum = -1; } } else{ //minusだったらだめ if(nowsum <= 0){ ans += abs(nowsum -A[i] - 1) - A[i]; nowsum = 1; } } //cout << nowsum << " " << ans << endl; } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:57:7: error: expected '}' before 'else' 57 | else if(nowsum >= 0) plus = true; | ^~~~ a.cc:34:22: note: to match this '{' 34 | if(nowsum == 0){ | ^ a.cc:97:2: error: expected '}' at end of input 97 | } | ^ a.cc:19:11: note: to match this '{' 19 | int main(){ | ^
s436240448
p03739
C++
#include <iostream> #define rep(i, n) for(int i = 0; i < (n); i++) using namespace std; int main(){ int n; cin >> n; ll ary[n], cnt1 = 0, cnt2 = 0, sum = 0; rep(i, n) cin >> ary[i]; // S_odd < 0, S_even > 0 rep(i, n){ sum += ary[i]; if(i % 2 && sum >= 0){ cnt1 += sum + 1; sum = -1; } else if(i % 2 == 0 && sum <= 0){ cnt1 += -sum + 1; sum = 1; } } sum = 0; // S_odd > 0, S_even < 0 rep(i, n){ sum += ary[i]; if(i % 2 == 0 && sum >= 0){ cnt2 += sum + 1; sum = -1; } else if(i % 2 && sum <= 0){ cnt2 += -sum + 1; sum = 1; } } cout << min(cnt1, cnt2) << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'll' was not declared in this scope 8 | ll ary[n], cnt1 = 0, cnt2 = 0, sum = 0; | ^~ a.cc:9:22: error: 'ary' was not declared in this scope 9 | rep(i, n) cin >> ary[i]; | ^~~ a.cc:13:9: error: 'sum' was not declared in this scope 13 | sum += ary[i]; | ^~~ a.cc:13:16: error: 'ary' was not declared in this scope 13 | sum += ary[i]; | ^~~ a.cc:15:13: error: 'cnt1' was not declared in this scope 15 | cnt1 += sum + 1; | ^~~~ a.cc:18:13: error: 'cnt1' was not declared in this scope 18 | cnt1 += -sum + 1; | ^~~~ a.cc:22:5: error: 'sum' was not declared in this scope 22 | sum = 0; | ^~~ a.cc:25:16: error: 'ary' was not declared in this scope 25 | sum += ary[i]; | ^~~ a.cc:27:13: error: 'cnt2' was not declared in this scope 27 | cnt2 += sum + 1; | ^~~~ a.cc:30:13: error: 'cnt2' was not declared in this scope 30 | cnt2 += -sum + 1; | ^~~~ a.cc:35:17: error: 'cnt1' was not declared in this scope 35 | cout << min(cnt1, cnt2) << endl; | ^~~~ a.cc:35:23: error: 'cnt2' was not declared in this scope 35 | cout << min(cnt1, cnt2) << endl; | ^~~~
s956617699
p03739
C++
#include <iostream> #include <cmath> #include <map> #include <queue> #include <string> #include <string> #include <algorithm> using namespace std; int ch_sign(int n){ if(n == 0)return 0; return (n>0)-(n<0); } int main(){ int n; cin >> n; int a[n]; for(int i = 0; i<n; ++i) cin >> a[i]; int sign1 = (a[0] > 0) - (a[0] < 0), sign2 = -1*sign1; int s = a[0]; int ans1 = 0, ans2 = 0; for(int i = 1; i<n; ++i){ //cout << a[i] << ',' << s << ',' << sign << endl; //while(abs(a[i]) <= abs(s)){ ++ans; a[i] -= sign;} //int dis = abs(s) - abs(a[i]) + 1; //cout << dis << endl << endl; //if(dis > 0){ans += dis; a[i] -= sign*dis;} //s += a[i]; sign *= -1; s += a[i]; sign1 *= -1; sign2 *= -1; if(ch_sign(s) != sign1){ ans1 += abs(s-sign1); s = sign1;} if(ch_sign(s) != sign2){ ans2 += abs(s-sign2); s = sign2;} } cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:34:17: error: no match for 'operator>' (operand types are 'std::basic_ostream<char>' and 'int') 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ~~~~~~~~~~~~^~~~~ | | | | | int | std::basic_ostream<char> a.cc:34:17: note: candidate: 'operator>(int, int)' (built-in) 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ~~~~~~~~~~~~^~~~~ a.cc:34:17: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int' 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:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ 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:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ 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:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/string_view:702: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> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/string_view:710: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>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:34:18: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3915: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>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:34:18: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ 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:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::tuple<_UTypes ...>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ In file included from /usr/include/c++/14/map:63, from a.cc:3: /usr/include/c++/14/bits/stl_map.h:1564:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>(const map<_Key, _Tp, _Compare, _Allocator>&, const map<_Key, _Tp, _Compare, _Allocator>&)' 1564 | operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:1564:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::map<_Key, _Tp, _Compare, _Allocator>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ In file included from /usr/include/c++/14/map:64: /usr/include/c++/14/bits/stl_multimap.h:1186:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>(const multimap<_Key, _Tp, _Compare, _Allocator>&, const multimap<_Key, _Tp, _Compare, _Allocator>&)' 1186 | operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_multimap.h:1186:5: note: template argument deduction/substitution failed: a.cc:34:18: note: 'std::basic_ostream<char>' is not derived from 'const std::multimap<_Key, _Tp, _Compare, _Allocator>' 34 | cout << ans1>ans2 ? ans1 : ans2 << endl; return 0; | ^~~~ In file included from /usr/include/c++/14/deque:66, from /usr/include/c++/14/queue:62, from a.cc:4: /usr/include/c++/14/bits/stl_deque.h:2349:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)' 2349 | operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
s167401543
p03739
C++
#include <iostream> #include<string> #include<vector> #include<stdio.h> #include<math.h> #include<algorithm> #define MOD 1000000007 using namespace std; long long int modpow(long long int a, int n) { if (n == 0)return 1; if (n == 1) return a; long long int wk = modpow(a, n / 2); long long int ret = 0; if (n % 2 == 0) { ret = 1; } else { ret = a; } return (((ret * wk) % MOD) * wk) % MOD; } long long int gcd(long long int a, long long int b) { long long int tmp; if (a < b) { tmp = a; a = b; b = tmp; } long long int r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } long long int lcm(long long int a, long long int b) { long long int wk_int; wk_int = (a * b) % MOD; long long int ret; ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD; return ret; } int main() { int n; cin >> n; vector<long long int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } bool plusmode = true; long long int ans = LLONG_MAX; long long int wk_ans = 0; long long int sum = 0; for (int i = 0; i < n; i++) { plusmode = !plusmode; sum += a[i]; if (plusmode) { if (sum <= 0) { wk_ans += abs(sum) + 1; sum = 1; } } else { if (sum >= 0) { wk_ans += abs(sum) + 1; sum = -1; } } } if (wk_ans < ans)ans = wk_ans; plusmode = false; wk_ans = 0; sum = 0; for (int i = 0; i < n; i++) { plusmode = !plusmode; sum += a[i]; if (plusmode) { if (sum <= 0) { wk_ans += abs(sum) + 1; sum = 1; } } else { if (sum >= 0) { wk_ans += abs(sum) + 1; sum = -1; } } } if (wk_ans < ans)ans = wk_ans; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:83:29: error: 'LLONG_MAX' was not declared in this scope 83 | long long int ans = LLONG_MAX; | ^~~~~~~~~ a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 6 | #include<algorithm> +++ |+#include <climits> 7 |
s260738613
p03739
C++
#include<bits/stdc++.h> #include<iomanip> using namespace std; typedef long long ll; typedef long l; typedef pair<int,int> P; #define rep(i,n) for(int i=0;i<n;i++) #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() const int INF=1000000001; const double PI=3.141592653589; const ll LMAX=1000000000000001; ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;} int dx[]={-1,0,1,0}; int dy[]={0,1,0,-1}; int main(){ int n; cin>>n; vector<ll> a(n); rep(i,n) cin>>a[i]; bool f[]={1,0}; ll ans=LMAX; rep(j,2){ ll sum=0; ll c=0; bool F=f[j]; rep(i,n){ if(F){ if(sum+a[i]<0) sum+=a[i]; else{ c+=abs(sum+a[i])+1; sum=-1; } }else{ if(sum+a[i]>0) sum+=a[i]; else{ c+=abs(sum+a[i])+1; sum=1; } } } ans=min(ans,c); } cout<<c<<endl; return 0; }
a.cc: In function 'int main()': a.cc:53:9: error: 'c' was not declared in this scope 53 | cout<<c<<endl; | ^
s966929287
p03739
C++
.
a.cc:1:1: error: expected unqualified-id before '.' token 1 | . | ^
s990198110
p03739
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; //1回の操作で、a[i]のいずれかを+1or-1できる //以下になる最小の操作回数を求める //全てのiに対して第一項からi項までの和Siは0でない //SiとSi+1の符号が異なる //予めSiを全て計算し、Si>0,Si+1>=0なら-1-Si+1だけa[i+1]から引く //a[0] = 0 のとき、a[0]>0,a[0]<0とした時の操作回数の小さい方が答え //a[0] != 0のとき、Si <0,Si+1<=0ならSi+c = 1を満たすcとa[i]の差をカウント int main(){ ll n; cin >> n; vector<ll> a(n); for(int i= 0;i<n;i++{ cin >> a[i]; } vector<ll> copy_a = a; ll count = 0; ll sum = 0; if(a[0] != 0){ for(int i = 0;i<n-1;i++){ sum += a[i];//i項までの和 if(sum < 0 && sum + a[i+1] <=0){ ll na = 1 -sum;//sumに何を足せば1になるか これを新たなa[i+1]にする count += abs(na - a[i+1]); a[i+1] = na; } if(sum > 0 && sum + a[i+1] >=0){ ll na = -1 -sum;//sumに何を足せば-1になるか これを新たなa[i+1]にする count += abs(na - a[i+1]); a[i+1] = na; } } } else if(a[0] == 0){ a[0] = 1; ll count1 = 1; for(int i = 0;i<n-1;i++){ sum += a[i];//i項までの和 if(sum < 0 && sum + a[i+1] <=0){ ll na = 1 -sum;//sumに何を足せば1になるか これを新たなa[i+1]にする count1 += abs(na - a[i+1]); a[i+1] = na; } if(sum > 0 && sum + a[i+1] >=0){ ll na = -1 -sum;//sumに何を足せば-1になるか これを新たなa[i+1]にする count1 += abs(na - a[i+1]); a[i+1] = na; } } copy_a[0] = -1; ll count2 = 1; ll sum2 = 0; for(int i = 0;i<n-1;i++){ sum2 += copy_a[i];//i項までの和 if(sum2 < 0 && sum2 + copy_a[i+1] <=0){ ll na = 1 -sum2;//sumに何を足せば1になるか これを新たなa[i+1]にする count2 += abs(na - copy_a[i+1]); copy_a[i+1] = na; } if(sum2 > 0 && sum2 + copy_a[i+1] >=0){ ll na = -1 -sum2;//sumに何を足せば-1になるか これを新たなa[i+1]にする count2 += abs(na - copy_a[i+1]); copy_a[i+1] = na; } } count = min(count1,count2); } cout << count << endl; }
a.cc: In function 'int main()': a.cc:17:23: error: expected ')' before '{' token 17 | for(int i= 0;i<n;i++{ | ~ ^ | )
s820548398
p03739
C++
#include<bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long ll; typedef pair<ll,ll> P; const ll mod=1000000007; const ll LINF=1LL<<60; const int INF=1<<30; int main(){ ll n,l; cin >> n; vector<ll> a(n); cin >> a[0]; for(ll i = 1; i < n; i++) { cin >> l; a[i] = a[i - 1] + l; } ll tmp = 0; ll count = 0; for(ll i = 0; i < n - 1; i++) { if (i == 0 && a[i] != 1){ count+=abs(a[i]-1); tmp-=a[i]-1; } if ((a[i] + tmp)* (a[i + 1] + tmp) >= 0){//和の符号が前後で同じ時 if ((a[i+1] + tmp) <= 0){ count += abs(a[i+1] + tmp - 1); tmp -= (a[i+1] + tmp - 1); } else{ count += abs(a[i] + tmp + 1); tmp -= (a[i] + tmp + 1); } } if (a[n - 1] +tmp == 0){ count++; } ll ans=count; count =0; ll tmp2=0; for(ll i = 0; i < n - 1; i++) { if (i == 0 && a[i] != -1){ count+=abs(a[i]+1); tmp2-=a[i]+1; } if ((a[i] + tmp2)* (a[i + 1] + tmp2) >= 0){//和の符号が前後で同じ時 if ((a[i+1] + tmp2) <= 0){ count += abs(a[i+1] + tmp2- 1); tmp2 -= (a[i+1] + tmp2 - 1); } else{ count += abs(a[i] + tmp2+ 1); tmp2 -= (a[i] + tmp2+ 1); } } // cout << a[i] + tmp << endl; } // cout << a[n - 1] << endl; if (a[n - 1] +tmp2 == 0){ count++; } cout << min(ans,count)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:77:2: error: expected '}' at end of input 77 | } | ^ a.cc:16:11: note: to match this '{' 16 | int main(){ | ^
s791706377
p03739
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n], s[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (i == 0) { s[0] = a[0]; } else { s[i] = s[i - 1] + a[i]; } } long long cng = 0; long long ans1 = 0, ans2 = 0; if (a[0] == 0) { if (0 < a[1]) { cng--; } else { cng++; } ans++; } for (int i = 1; i < n; i++) { if (((s[i] + cng < 0) && (0 < s[i - 1] + cng)) || ((s[i] + cng > 0) && (0 > s[i - 1] + cng))) { //ok continue; } assert(s[i - 1] + cng != 0); if (s[i] + cng >= 0) //減らさないといけない { ans += s[i] + cng + 1; cng -= s[i] + cng + 1; } else //増やさないといけない { ans += -(s[i] + cng) + 1; cng += -(s[i] + cng) + 1; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:34:9: error: 'ans' was not declared in this scope; did you mean 'ans2'? 34 | ans++; | ^~~ | ans2 a.cc:47:13: error: 'ans' was not declared in this scope; did you mean 'ans2'? 47 | ans += s[i] + cng + 1; | ^~~ | ans2 a.cc:53:13: error: 'ans' was not declared in this scope; did you mean 'ans2'? 53 | ans += -(s[i] + cng) + 1; | ^~~ | ans2 a.cc:58:13: error: 'ans' was not declared in this scope; did you mean 'ans2'? 58 | cout << ans << endl; | ^~~ | ans2
s063678562
p03739
C++
#include <iostream> #include <algorithm> #include <string> #include <math.h> #include <bitset> #include <vector> #include <queue> #include <map> #define i64 int64_t #define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++) #define sort(vvv) sort(vvv.begin(),vvv.end()) #define rvs(vvv) reverse(vvv.begin(),vvv.end()) int inf = 1000000007; using namespace std; int main() { int n; cin >> n; vector<int> data(n); int ans = 0; ff(i, 0, n) { cin >> data.at(i); } vector<int> data2 = data; i64 sum = data.at(0); i64 sump = sum; ff(i, 1, n) { sump += data.at(i); if (sum * sump >= 0) { int c = sump; if (c < 0)c *= -1; c++; ans += c; if (sump > 0) { data.at(i) -= c; sump -= c; } else { data.at(i) += c; sump += c; } } sum += data.at(i); } i64 ans2 = 0; i64 sum = data2.at(0)*-1; i64 sump = sum; ff(i, 1, n) { sump += data2.at(i); if (sum * sump >= 0) { int c = sump; if (c < 0)c *= -1; c++; ans2 += c; if (sump > 0) { data2.at(i) -= c; sump -= c; } else { data2.at(i) += c; sump += c; } } sum += data2.at(i); } if (ans > ans2) { cout << ans << endl; } else { cout << ans2 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:49:13: error: redeclaration of 'int64_t sum' 49 | i64 sum = data2.at(0)*-1; | ^~~ a.cc:27:13: note: 'int64_t sum' previously declared here 27 | i64 sum = data.at(0); | ^~~ a.cc:50:13: error: redeclaration of 'int64_t sump' 50 | i64 sump = sum; | ^~~~ a.cc:28:13: note: 'int64_t sump' previously declared here 28 | i64 sump = sum; | ^~~~
s069204431
p03739
C++
#include<bits/stdc++.h> using namespace std; #define ll long long // long long省略 #define pb push_back // push_back省略 #define mp make_pair // make_pair省略 #define fi first // first省略 #define se second // second省略 #define itn int // int誤字保険 #define count cout // cout誤字保険 #define vecotr vector // vector誤字保険 #define ednl endl // endl誤字保険 #define opt() cin.tie(0); ios::sync_with_stdio(false) // 入出力速度改善 #define rep(i,l,r) for(ll i=(l);i<(r);i++) // 範囲[l, r)で刻み1のfor文(順方向) #define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k)) // 範囲[l, r)で刻みkのfor文(順方向) #define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--) // 範囲[l, r)で刻み1のfor文(逆方向) #define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k)) // 範囲[l, r)で刻みkのfor文(逆方向) #define all(x) (x).begin(), (x).end() // vectorのポインタ位置指定用 #define max(p,q)((p)>(q)?(p):(q)) // max拡張 #define min(p,q)((p)<(q)?(p):(q)) // min拡張 #define bit(n,m)(((n)>>(m))&1) // 変数nのm番目のbitを取り出す template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } int dy[]={0, 1, 0, -1}; // 4方向近傍 int dx[]={1, 0, -1, 0}; // 4方向近傍 #define INF ((1LL<<62)-(1LL<<31)) //#define MOD 998244353 #define MOD 1000000007 #define invp(a,p) pom(a,p-2,p) //////////////////////////////////////////////////////////////////////////////////////// int main(){ ll n; cin >> n; ll a[n]; rep(i,0,n) cin >> a[i]; //1. 累積和に0がないか? // iで累積和が0になるなら、iから先に+1 //2. 累積和の符号が反転しない // 反転するまで1を加える、1を引く ll csum[n]; csum[0] = a[0]; rep(i,1,n){ csum[i] = csum[i-1] + a[i]; //cout << csum[i] << ednl; } //初手が0じゃない場合 if(csum[0] != 0){ ll p1 = 0, m1 = 0; bool flag = (csum[0] > 0); rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } ll res = p1 + m1; if(csum[0] > 0){ p1 = 0; m1 = csum[0] + 1; }else{ p1 = -csum[0] + 1; m1 = 0; } flag = !(csum[0] > 0); rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } res = min(p1 + m1, res); cout << res << ednl; }else{ //初手が0の場合で決め打ちで+1した場合 ll p1 = 1, ll m1 = 0; flag = true; rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } ll res = p1+m1; //初手が0の場合で決め打ちで-1した場合 p1 = 0, m1 = 1; flag = false; rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } res = min(res, p1+m1); } cout << res << ednl; }
a.cc: In function 'int main()': a.cc:3:12: error: expected unqualified-id before 'long' 3 | #define ll long long // long long省略 | ^~~~ a.cc:92:20: note: in expansion of macro 'll' 92 | ll p1 = 1, ll m1 = 0; | ^~ a.cc:93:9: error: 'flag' was not declared in this scope 93 | flag = true; | ^~~~ a.cc:95:50: error: 'm1' was not declared in this scope; did you mean 'p1'? 95 | if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ | ^~ | p1 a.cc:107:21: error: 'm1' was not declared in this scope; did you mean 'p1'? 107 | ll res = p1+m1; | ^~ | p1 a.cc:126:13: error: 'res' was not declared in this scope; did you mean 'rep'? 126 | cout << res << ednl; | ^~~ | rep
s142292858
p03739
C++
#include<bits/stdc++.h> using namespace std; #define ll long long // long long省略 #define pb push_back // push_back省略 #define mp make_pair // make_pair省略 #define fi first // first省略 #define se second // second省略 #define itn int // int誤字保険 #define count cout // cout誤字保険 #define vecotr vector // vector誤字保険 #define ednl endl // endl誤字保険 #define opt() cin.tie(0); ios::sync_with_stdio(false) // 入出力速度改善 #define rep(i,l,r) for(ll i=(l);i<(r);i++) // 範囲[l, r)で刻み1のfor文(順方向) #define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k)) // 範囲[l, r)で刻みkのfor文(順方向) #define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--) // 範囲[l, r)で刻み1のfor文(逆方向) #define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k)) // 範囲[l, r)で刻みkのfor文(逆方向) #define all(x) (x).begin(), (x).end() // vectorのポインタ位置指定用 #define max(p,q)((p)>(q)?(p):(q)) // max拡張 #define min(p,q)((p)<(q)?(p):(q)) // min拡張 #define bit(n,m)(((n)>>(m))&1) // 変数nのm番目のbitを取り出す template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } int dy[]={0, 1, 0, -1}; // 4方向近傍 int dx[]={1, 0, -1, 0}; // 4方向近傍 #define INF ((1LL<<62)-(1LL<<31)) //#define MOD 998244353 #define MOD 1000000007 #define invp(a,p) pom(a,p-2,p) //////////////////////////////////////////////////////////////////////////////////////// int main(){ ll n; cin >> n; ll a[n]; rep(i,0,n) cin >> a[i]; //1. 累積和に0がないか? // iで累積和が0になるなら、iから先に+1 //2. 累積和の符号が反転しない // 反転するまで1を加える、1を引く ll csum[n]; csum[0] = a[0]; rep(i,1,n){ csum[i] = csum[i-1] + a[i]; //cout << csum[i] << ednl; } //初手が0じゃない場合 if(csum[0] != 0){ ll p1 = 0, m1 = 0; bool flag = (csum[0] > 0); rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } ll res = p1 + m1; if(csum[0] > 0){ p1 = 0; m1 = csum[0] + 1; }else{ p1 = -csum[0] + 1; m1 = 0; } bool flag = !(csum[0] > 0); rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } res = min(p1 + m1, res); cout << res << ednl; }else{ //初手が0の場合で決め打ちで+1した場合 ll p1 = 1, ll m1 = 0; flag = true; rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } ll res = p1+m1; //初手が0の場合で決め打ちで-1した場合 p1 = 0, m1 = 1; flag = false; rep(i,1,n){ if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ flag = !flag; continue; }else{ if(flag){ //このステップでは負であるべき m1 += csum[i] + p1 - m1 + 1; }else{ //このステップでは生であるべき p1 += -(csum[i] + p1 - m1) + 1; } flag = !flag; } } res = min(res, p1+m1); } cout << res << ednl; }
a.cc: In function 'int main()': a.cc:74:14: error: redeclaration of 'bool flag' 74 | bool flag = !(csum[0] > 0); | ^~~~ a.cc:53:14: note: 'bool flag' previously declared here 53 | bool flag = (csum[0] > 0); | ^~~~ a.cc:3:12: error: expected unqualified-id before 'long' 3 | #define ll long long // long long省略 | ^~~~ a.cc:92:20: note: in expansion of macro 'll' 92 | ll p1 = 1, ll m1 = 0; | ^~ a.cc:93:9: error: 'flag' was not declared in this scope 93 | flag = true; | ^~~~ a.cc:95:50: error: 'm1' was not declared in this scope; did you mean 'p1'? 95 | if((flag ? -1 : 1) * (csum[i] + p1 - m1) > 0){ | ^~ | p1 a.cc:107:21: error: 'm1' was not declared in this scope; did you mean 'p1'? 107 | ll res = p1+m1; | ^~ | p1 a.cc:126:13: error: 'res' was not declared in this scope; did you mean 'rep'? 126 | cout << res << ednl; | ^~~ | rep
s855274709
p03739
Java
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException{ Sequence solver = new Sequence(); solver.readInput(); solver.solve(); solver.writeOutput(); } static class Sequence { private int n; private int a[]; private int output; private Scanner scanner; public Sequence() { this.scanner = new Scanner(System.in); } public void readInput() { n = Integer.parseInt(scanner.next()); a = new int[n]; for(int i=0; i<n; i++) { a[i] = Integer.parseInt(scanner.next()); } } private int count(boolean sign) { long count=0; int sum=0; for(int i=0; i<n; i++) { sum += a[i]; if((i%2==0) == sign) { // a[i]までの合計を正にするとき if(sum<=0) { count += Math.abs(sum)+1; sum = 1; } } else { // a[i]までの合計を負にするとき if(0<=sum) { count += Math.abs(sum)+1; sum = -1; } } } return count; } public void solve() { output = Math.min(this.count(true), this.count(false)); } public void writeOutput() { System.out.println(output); } } }
Main.java:51: error: incompatible types: possible lossy conversion from long to int return count; ^ 1 error
s885030248
p03739
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() #define pb push_back typedef long long ll; const int INF = 1000000000; const long INF64 = 1000000000000000ll; const ll MOD = 1000000007ll; int main(){ ll n; std::cin >> n; std::vector<ll> a(n); rep(i,n)std::cin >> a[i]; ll ans1=0,ans2=0; ll sum=0; ll han=-1; rep(i,n){ han*=-1; sum+=a[i]; if(han<0){ ans1+=max(0,sum+1); sum-=max(0,sum+1); }else{ ans1-=min(0,sum-1); sum-=min(0,sum-1); } // std::cout << ans1 << std::endl; } han=1;sum=0; rep(i,n){ han*=-1; sum+=a[i]; if(han<0){ ans2+=max(0,sum+1); sum-=max(0,sum+1); }else{ ans2-=min(0,sum-1); sum-=min(0,sum-1); } // std::cout <<sum<<' '<< ans2 << std::endl; } std::cout << min(ans1,ans2) << std::endl; }
a.cc: In function 'int main()': a.cc:24:34: error: no matching function for call to 'max(int, ll)' 24 | ans1+=max(0,sum+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:24:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 24 | ans1+=max(0,sum+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:24:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 24 | ans1+=max(0,sum+1); | ~~~^~~~~~~~~ a.cc:25:33: error: no matching function for call to 'max(int, ll)' 25 | sum-=max(0,sum+1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:25:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 25 | sum-=max(0,sum+1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:25:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 25 | sum-=max(0,sum+1); | ~~~^~~~~~~~~ a.cc:27:34: error: no matching function for call to 'min(int, ll)' 27 | ans1-=min(0,sum-1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:27:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 27 | ans1-=min(0,sum-1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:27:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 27 | ans1-=min(0,sum-1); | ~~~^~~~~~~~~ a.cc:28:33: error: no matching function for call to 'min(int, ll)' 28 | sum-=min(0,sum-1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:28:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 28 | sum-=min(0,sum-1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:28:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 28 | sum-=min(0,sum-1); | ~~~^~~~~~~~~ a.cc:37:34: error: no matching function for call to 'max(int, ll)' 37 | ans2+=max(0,sum+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:37:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 37 | ans2+=max(0,sum+1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:37:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 37 | ans2+=max(0,sum+1); | ~~~^~~~~~~~~ a.cc:38:33: error: no matching function for call to 'max(int, ll)' 38 | sum-=max(0,sum+1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:38:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 38 | sum-=max(0,sum+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 |
s077239166
p03739
C++
#include <vector> #include <iostream> #include <cmath> using namespace std; using ll = long long; ll solve(vector<ll>& v, int first) { ll cost = abs(first - v[0]); ll sum = first; for (int i = 1; i < v.size(); ++i) { ll after = sum + v[i]; if (after * sum < 0) { sum = after; } else { cost += abs(after) + 1; sum = sum > 0 ? -1 : 1; } } return cost; } int main() { int N; cin >> N; vector<ll> v(N); for (int i = 0; i < N; i++) cin >> v[i]; ll ret = LONG_MAX; if (v[0] == 0) { ret = min(ret, solve(v, 1)); ret = min(ret, solve(v, -1)); } else { ret = min(ret, solve(v, v[0])); ret = min(ret, solve(v, v[0] > 0 ? -1 : 1)); } cout << ret << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:14: error: 'LONG_MAX' was not declared in this scope 31 | ll ret = LONG_MAX; | ^~~~~~~~ a.cc:4:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <cmath> +++ |+#include <climits> 4 |
s083378031
p03739
C++
#include <bits/stdc++.h> #define REP(i, n) for(ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) #define sz(x) int(x.size()) using namespace std; typedef long long ll; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; template <class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } int main() { int n; cin >> n; vector<ll> a(n); REP(i, n) { cin >> a[i]; } ll res = INF; ll ans = 0LL; ll s = a[0]; //はじめは正 for(int i = 1; i < n; i++) { s += a[i]; if(i % 2 == 1) { //負に if(s >= 0) { ans += s + 1; s = -1; } } else { //正に if(s <= 0) { ans += -s + 1; s = 1; } } } res = min(res, ans); // cout << s << endl; ans = 0; ll s = a[0]; for(int i = 1; i < n; i++) { s += a[i]; if(i % 2 == 0) { if(s >= 0) { ans += s + 1; s = -1; } } else { if(s <= 0) { ans += -s + 1; s = 1; } } } res = min(res, ans); cout << res << endl; }
a.cc: In function 'int main()': a.cc:64:8: error: redeclaration of 'll s' 64 | ll s = a[0]; | ^ a.cc:42:8: note: 'll s' previously declared here 42 | ll s = a[0]; | ^
s774859255
p03739
C++
#include<bits/stdc++.h> // debug #define d(x) cerr << #x ":" << x << endl; #define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl; #define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl; #define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl; #define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;} #define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;} #define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl; // iterate #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define reprev(i, n) reprrev(i, 0, n) #define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++) #define all(v) v.begin(), v.end() // etc #define chmin(mi, val) mi = min(mi, val); #define chmax(ma, val) ma = max(ma, val); using ll = long long; using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> v(n, 0); rep(i,n)cin >> v[i]; vector<int> p1(n+1,1), p2(n+1,1); rep(i,n+1){ if(i%2==0) p1[i]*=-1; } rep(i,n+1){ if(i%2==1) p2[i]*=-1; } // dump(p1) // dump(p2) priority_queue<int, vector<int>, greater<int> > pq; // dump(v) vector<ll>sum_until(n+1,0); int cnt; // pat1 cnt = 0; for(int i=1; i<=n; i++){ sum_until[i] = sum_until[i-1] + v[i-1]; // dump(sum_until) if(sum_until[i]*p1[i] < 0){ int plus = abs(sum_until[i]); dd(i,plus*p1[i]) d(sum_until[i]) sum_until[i] += plus*p1[i] + p1[i]; d(sum_until[i]) cnt += abs(plus*p1[i]) +1; } else if(sum_until[i] == 0){ sum_until[i] = p1[i]; cnt += 1; } dump(sum_until) d(cnt) pq.push(cnt); p1 = p2; // dump(sum_until) cnt = 0; for(int i=1; i<=n; i++){ d(i) sum_until[i] = sum_until[i-1] + v[i-1]; // dump(sum_until) if(sum_until[i]*p1[i] < 0){ int plus = abs(sum_until[i]); dd(i,plus*p1[i]) d(sum_until[i]) sum_until[i] += plus*p1[i] + p1[i]; d(sum_until[i]) cnt += abs(plus*p1[i]) +1; } else if(sum_until[i] == 0){ sum_until[i] = p1[i]; cnt += 1; } } pq.push(cnt); d(cnt) dump(sum_until) cout << pq.top() << endl; return 0; }
a.cc: In function 'int main()': a.cc:90:2: error: expected '}' at end of input 90 | } | ^ a.cc:23:11: note: to match this '{' 23 | int main(){ | ^
s949001072
p03739
C++
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) #define OP(m) cout << m << endl typedef long long ll; typedef unsigned long long ull; int main() { int n; cin >> n; int a[n]; rep(i, n) cin >> a[i]; ll cnt1 = 0, cnt2 = 0; ll sum = a[0]; for (int i = 1; i < n; i++) { if (i % 2 == 0 && sum < 0) sum = 1; //符号がプラスになるべきところ。 else if (i % 2 == 1 && sum > 0) sum = -1; //符号がマイナスになるべきところ。 sum += a[i]; cnt1 += abs(sum) + 1; } ll sum = a[0]; for (int i = 1; i < n; i++) { if (i % 2 == 0 && sum > 0) sum = -1; //符号マイナスになるべきところ。 else if (i % 2 == 1 && sum < 0) sum = 1; //符号がプラスになるべきところ。 sum += a[i]; cnt2 += abs(sum) + 1; } OP(min(cnt1, cnt2)); return 0; }
a.cc: In function 'int main()': a.cc:33:8: error: redeclaration of 'll sum' 33 | ll sum = a[0]; | ^~~ a.cc:21:8: note: 'll sum' previously declared here 21 | ll sum = a[0]; | ^~~
s348960852
p03739
C++
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) #define OP(m) cout << m << endl typedef long long ll; typedef unsigned long long ull; int main() { int n; cin >> n; int a[n]; rep(i, n) cin >> a[i]; ll cnt1 = 0, cnt2 = 0; ll sum = a[0]; rep(i, n) { if (i % 2 == 0 && sum < 0) sum = 1; //符号がプラスになるべきところ。 else if (i % 2 == 1 && sum > 0) sum = -1; //符号がマイナスになるべきところ。 cnt1 += abs(sum) + 1; } ll sum = a[0]; rep(i, n) { if (i % 2 == 0 && sum > 0) sum = -1; //符号マイナスになるべきところ。 else if (i % 2 == 1 && sum < 0) sum = 1; //符号がプラスになるべきところ。 cnt2 += abs(sum) + 1; } OP(min(cnt1, cnt2)); return 0; }
a.cc: In function 'int main()': a.cc:31:8: error: redeclaration of 'll sum' 31 | ll sum = a[0]; | ^~~ a.cc:21:8: note: 'll sum' previously declared here 21 | ll sum = a[0]; | ^~~
s753601847
p03739
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n;cin>>n; int a[n]; for (int i=0;i<n;i++) cin>>a[i]; ll mn=1e18; for (int i=0;i<2;i++) { ll sm=0; ll cnt=0; for (int j=0;j<n;j++) { sm+=a[j]; if ((i+j)%2==0) { if (sm<=0) { cnt+=-sm+1; sm=1; } } else { if (sm>=0) { cnt+=sm+1; sm=-1; } } } mn=min(mn,cnt); } cout<<cnt<<endl; return 0; }
a.cc: In function 'int main()': a.cc:30:11: error: 'cnt' was not declared in this scope; did you mean 'int'? 30 | cout<<cnt<<endl; | ^~~ | int
s964204813
p03739
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<long long int> A(N); long long int s = 0LL vector<long long int> V(N); for(int i = 0; i < N; i++){ cin >> A[i]; s += A[i]; V[i] = s; } //先手が+のパターン(i % 2 == 0のとき 1) long long int tmp1 = 0LL; long long int tmp2 = 0LL; for(int i = 0; i < N-1; i++){ if(i % 2 == 0){ if(V[i] > 0) continue; else{ tmp1 += 1LL - V[i]; V[i] = 1LL; V[i + 1] = 1LL + A[i+1]; } }else{ if(V[i] < 0) continue; else{ tmp1 += -1LL - V[i]; V[i] = -1LL; V[i + 1] = -1LL + A[i+1]; } } } for(int i = 0; i < N-1; i++){ if(i % 2 == 1){ if(V[i] > 0) continue; else{ tmp2 += 1LL - V[i]; V[i] = 1LL; V[i + 1] = 1LL + A[i+1]; } }else{ if(V[i] < 0) continue; else{ tmp2 += -1LL - V[i]; V[i] = -1LL; V[i + 1] = -1LL + A[i+1]; } } } cout << min(tmp1, tmp2); }
a.cc: In function 'int main()': a.cc:12:3: error: expected ',' or ';' before 'vector' 12 | vector<long long int> V(N); | ^~~~~~ a.cc:16:5: error: 'V' was not declared in this scope 16 | V[i] = s; | ^ a.cc:23:10: error: 'V' was not declared in this scope 23 | if(V[i] > 0) continue; | ^ a.cc:30:10: error: 'V' was not declared in this scope 30 | if(V[i] < 0) continue; | ^ a.cc:41:10: error: 'V' was not declared in this scope 41 | if(V[i] > 0) continue; | ^ a.cc:48:10: error: 'V' was not declared in this scope 48 | if(V[i] < 0) continue; | ^
s426214474
p03739
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<long long int> A(N); long long int s = 0LL vector<long long int> V(N); for(int i = 0; i < N; i++){ cin >> A[i]; s += A[i]; V[i] = s; } //先手が+のパターン(i % 2 == 0のとき 1) long long int tmp1 = 0LL; for(int i = 0; i < N-1; i++){ if(i % 2 == 0){ if(V[i] > 0) continue; else{ tmp1 += 1LL - V[i]; V[i] = 1LL; V[i + 1] = 1LL + A[i+1]; } }else{ if(V[i] < 0) continue; else{ tmp1 += -1LL - V[i]; V[i] = -1LL; V[i + 1] = -1LL + A[i+1]; } } } for(int i = 0; i < N-1; i++){ if(i % 2 == 1){ if(V[i] > 0) continue; else{ tmp2 += 1LL - V[i]; V[i] = 1LL; V[i + 1] = 1LL + A[i+1]; } }else{ if(V[i] < 0) continue; else{ tmp2 += -1LL - V[i]; V[i] = -1LL; V[i + 1] = -1LL + A[i+1]; } } } cout << min(tmp1, tmp2); }
a.cc: In function 'int main()': a.cc:12:3: error: expected ',' or ';' before 'vector' 12 | vector<long long int> V(N); | ^~~~~~ a.cc:16:5: error: 'V' was not declared in this scope 16 | V[i] = s; | ^ a.cc:23:10: error: 'V' was not declared in this scope 23 | if(V[i] > 0) continue; | ^ a.cc:30:10: error: 'V' was not declared in this scope 30 | if(V[i] < 0) continue; | ^ a.cc:41:10: error: 'V' was not declared in this scope 41 | if(V[i] > 0) continue; | ^ a.cc:43:9: error: 'tmp2' was not declared in this scope; did you mean 'tmp1'? 43 | tmp2 += 1LL - V[i]; | ^~~~ | tmp1 a.cc:48:10: error: 'V' was not declared in this scope 48 | if(V[i] < 0) continue; | ^ a.cc:50:9: error: 'tmp2' was not declared in this scope; did you mean 'tmp1'? 50 | tmp2 += -1LL - V[i]; | ^~~~ | tmp1 a.cc:56:21: error: 'tmp2' was not declared in this scope; did you mean 'tmp1'? 56 | cout << min(tmp1, tmp2); | ^~~~ | tmp1
s441300226
p03739
C++
#include <iostream> using namespace std; int main() { int n; long long *a cin >> n; a = new long long[n]; long long ans = 0; long long sum = 0; for (int i = 0; i < n; i++) cin >> a[i]; int flag = -1; if (a[0] > 0) flag = 1; else if (a[0] == 0) flag = 0; for (int i = 0; i < n; i++) { sum += a[i]; if (flag > 0 || flag == 0) { if (sum <= 0) { while (sum <= 0) { sum++; ans++; } } flag = -1; } else if (flag < 0) { if (sum >= 0) { while (sum >= 0) { sum--; ans++; } } flag = 1; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: expected initializer before 'cin' 8 | cin >> n; | ^~~ a.cc:9:5: error: 'a' was not declared in this scope 9 | a = new long long[n]; | ^
s562722615
p03739
C++
#include <iostream> // cin, cout, cerr, clog #include <algorithm> // minmax, sort, swap #include <numeric> // iota, accumulate, inner_product #include <cstdio> // printf, scanf #include <climits> // INT_MIN, LLONG_MIN #include <cmath> // long, trig, pow #include <string> // string, stoi, to_string #include <vector> // vector #include <queue> // queue, priority_queue #include <deque> // deque #include <stack> // stack #include <map> // key-value pairs sorted by keys #include <set> // set #include <unordered_map> // hashed by keys #include <unordered_set> // hashed by keys #include <iomanip> // cout<<setprecision(n) #include <functional> // std::function<void(int)> #define rep(i,n) for(int i = 0; i < (n); i++) #define ENDL '\n' #define print(i) std::cout << (i) << '\n' #define int long long // at least int64 > 9*10^18 #define all(v) (v).begin(), (v).end() /* libraries */ signed main() { int n; std::cin >> n; std::vector<int> a(n); rep(i,n) std::cin >> a[i]; const int INF = 1e18; int mincount = INF; rep(x,3) { int sum = a[0]; int count = 0; if(x==1) { if(sum>0) { count+=sum+1; sum = -1; } else if(sum=<0) { count+=1-sum; sum = 1; } } if(x==2) { if(sum=>0) { count+=sum+1; sum = -1; } else if(sum<0) { count+=1-sum; sum = 1; } } if(sum==0) continue; for(int i=1;i<n;i++) { if((sum+a[i])*sum>=0) { if(sum>0) { count+=a[i]+sum+1; sum = -1; } else if(sum<0) { count+=1-a[i]-sum; sum = 1; } } else sum+=a[i]; } mincount = std::min(count,mincount); } print(mincount); return 0; }
a.cc: In function 'int main()': a.cc:43:37: error: expected primary-expression before '<' token 43 | else if(sum=<0) { | ^ a.cc:49:32: error: expected primary-expression before '>' token 49 | if(sum=>0) { | ^
s695347301
p03739
C++
// ABC 59 C #include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < n; ++i) using namespace std; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const long long INF = 1LL<<60; ll foo(const vector<ll>& a, bool oddPositive) { size_t n = a.size(); vector<ll> b1(n); ll ans = 0; b1[0] = a[0]; if (oddPositive && a[0] <= 0) { b1[0] = 1; ans += abs(a[0] + 1); } if (!oddPositive && a[0] => 0) { b1[0] = -1; ans += abs(a[0] + 1); } for (int i = 1; i < n; i++) { if ((b1[i-1] + a[i]) * b1[i-1] < 0) { b1[i] = b1[i-1] + a[i]; continue; } if (a[i] + b1[i-1] == 0) { ans += 1; } else if (b1[i-1] * a[i] > 0) { // a[i], b[i-1] の符号が同じ ans += abs(a[i]) + abs(b1[i-1]) + 1; } else { // a[i], b[i-1] の符号が逆 ans += abs(b1[i-1]) - abs(a[i]) + 1; } b1[i] = b1[i-1] < 0 ? 1 : -1; } return ans; } int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { ll tmp = 0; cin >> tmp; a[i] = tmp; } ll ans1 = foo(a, true); // 奇数番目が正の数 ll ans2 = foo(a, false); // 奇数番目が負の数 cout << min(ans1, ans2) << endl; return 0; }
a.cc: In function 'll foo(const std::vector<long long int>&, bool)': a.cc:25:29: error: expected primary-expression before '>' token 25 | if (!oddPositive && a[0] => 0) { | ^