submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s841198690
p03780
C++
#include <iostream> #include <algorithm> #include <vector> #include <iterator> using namespace std; //cardsのうちK - num以上K - 1以下の和をもつ部分集合Sが作れるか// //をDPで判定する関数// bool search_set(vector<int> cards, int K, int num){ //exist[i][j]はcardsのi枚目まで使って合計jとなる部分集合を作れるかどうか// bool exist[cards.size()][K]; unsigned int i, j; //初期化// for(i = 1; i < K; i++){ if(cards[0] == i) exist[0][i] = true; else exist[0][i] = false; } //条件を満たす集合が見つかったかのフラグ// bool find = false; //サイズが1の場合は別に処理// if(cards.size() == 1){ for(int k = K - num; k < K; k++){ if(exist[0][k] = true){ find = true; break; } } return true; } //それ以外はDPmatrixを埋めていく// //exist[i][j](K - num <= j <= K - 1)がtrueになるまでループ// for(i = 1; i < cards.size(); i++){ //K - num <= j <= K - 1がtrueになったかどうかのフラグ// bool ok; for(j = 1; j < K; j++){ if(exist[i - 1][j] == true){ exist[i][j] = true; if(j + cards[i] < K) exist[i][j + cards[i]] = true; } if(cards[i] == j) exist[i][j] = true; if(j >= K - num && j <= K - 1 && exist[i][j] = true){ ok = true; break; } } //okがtrueなら見つかったので終了// if(ok){ find = true; break; } } return find; } int main(){ //カードの枚数N, 目標とする和K// int N, K, i; cin >> N >> K; //改行文字が入らないように1文字飛ばす// cin.ignore(); //N個のカードの数字が格納されたvector cards// string str; vector<int> cards; if(N > 1){ for(i = 0; i < N - 1; i++){ getline(cin, str, ' '); cards.push_back(stoi(str)); } } getline(cin, str); cards.push_back(stoi(str)); //cardsをソートする// sort(cards.begin(), cards.end()); //K以下の数字を持つカードの和sumをとる// long int sum = 0; for(i = 0; i < N; i++){ if(cards[i] < K) sum += cards[i]; else break; } //K以上の数のカードはそれ1枚の集合で必要となり// //他のカードと組んでギリギリの集合を作らないので消去// cards.erase(cards.begin() + i, cards.end()); //もしsumがKより小さいならK以下のカードはすべて不要// if(sum < K) cout << i << endl; //sumがKに等しいかすべてのカードがK以上ならばどれが抜けてもダメなので全て必要// else if(sum == K || i == 0) cout << 0 << endl; //それ以外は大きい方から1枚ずつ必要か判断// else{ //カードaの数字Naとすると、S < K && S + Na >= Kなる集合が見つかれば// //aは必要で、なければ不必要// //大きい方から見て初めて不要なカードが出た時点で// //それ以下の数のカードはすべて不要// vector<int> n_cards; for(i = cards.size() - 1; i >= 0; i--){ //n_cardsにcardsをコピー// copy(cards.begin(), cards.end(), back_inserter(n_cards)); //集合からcards[i]を消去// n_cards.erase(n_cards.begin() + i); //search_setはcardsのうちK - cards[i] <= S <= K - 1// //を満たす部分集合Sが存在するか確かめる関数// //Sが見つかったら同じ大きさの数のカードは飛ばしてループ続行// if(search_set(n_cards, K, cards[i])){ while(i >= 1){ if(cards[i] == cards[i - 1]) i--; else break; } } //falseならばその場でbreak// else break; n_cards.clear(); } //iは不要なカードのindexで止まっているので+1する// cout << i + 1 << endl; } return 0; }
a.cc: In function 'bool search_set(std::vector<int>, int, int)': a.cc:53:55: error: lvalue required as left operand of assignment 53 | if(j >= K - num && j <= K - 1 && exist[i][j] = true){ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
s204832650
p03780
C++
include <iostream> #include <algorithm> #include <vector> using namespace std; //cardsのうちcards[i]を除いた集合から、min以上max以下の部分集合Sが作れるか// //を再帰的に判定する関数// bool search_set(vector<int> cards, unsigned int i, int min, int max){ //もしmin <= 0 <= maxならこれ以上何も選ばず条件を満たす// if(min <= 0 && max >= 0) return true; //cardsの要素1ならそれをSの元に選んで条件を満たすか検討// else if(cards.size() == 1){ if(cards[0] >= min && cards[0] <= max) return true; else return false; } //そうでなければ集合から1つずつ元を選び、それをSに加えて再帰処理// else{ //cards[i]を除いた新たなvectorであるnew_cardsを作る// vector<int> new_cards(cards); auto itr = find(new_cards.begin(), new_cards.end(), cards[i]); new_cards.erase(itr); //new_cardsの要素からひとつずつSに加えて再帰// //そのどれかでtrueならtrueを返す// bool check = false; for(unsigned int j = 0; j < new_cards.size(); j++){ if(search_set(new_cards, j, min - new_cards[j], max - new_cards[j])){ check = true; break; } } return check; } } int main(){ //カードの枚数N, 目標とする和K// int N, K; cin >> N >> K; //改行文字が入らないように1文字飛ばす// cin.ignore(); //N個のカードの数字が格納されたvector cards// string str; vector<int> cards; if(N > 1){ for(int i = 0; i < N - 1; i++){ getline(cin, str, ' '); cards.push_back(stoi(str)); } } getline(cin, str); cards.push_back(stoi(str)); //cardsをソートする// sort(cards.begin(), cards.end()); //カードaの数字Naとすると、S < K && S + Na >= Kなる集合が見つかれば// //aは必要で、なければ不必要// //初めて必要なカードが出た時点でそれよりも大きい数のカードはすべて必要// int i; bool all = false; for(i = N - 1; i >= 0; i--){ //search_setはcardsのなかでcards[i]を除いて// //min以上max以下の和の集合が存在するか調べる// //falseならば同じ数字を飛ばしてループ継続// if(search_set(cards, i, K - cards[i], K - 1)){ while(i >= 1){ if(cards[i] == cards[i - 1]) i--; else break; } if(i == 0) all = true; } //trueならばその場でbreak// else break; } //全部ダメならNを出力// if(all) cout << 0 << endl; else cout << i + 1 << endl; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
s368525939
p03780
C++
#include <bits\stdc++.h> #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) #define reps(i,j,N) for(LL i=j;i<N;++i) typedef long long int LL; typedef std::pair<int, int> P; int N, K, a[5112]; int ans; int main() { in >> N >> K; rep(i, N) { in >> a[i]; } LL sum; std::sort(a, a + N, std::greater<int>()); rep(i, N) { sum = 0; reps(j, i, N) { sum += a[j]; if (sum >= K) { ans = std::max<LL>(ans, j + 1); sum -= a[j]; } } } ans = N - ans; out << ans << std::endl; return 0; }
a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory 1 | #include <bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s321679319
p03780
C++
#include <bits\stdc++.h> #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) #define reps(i,j,N) for(LL i=j;i<N;++i) typedef long long int LL; typedef std::pair<int, int> P; int N, K, a[5112]; int ans; int main() { in >> N >> K; rep(i, N) { in >> a[i]; } LL sum; std::sort(a, a + N, std::greater<int>()); rep(i, N) { sum = 0; reps(j, i, N) { sum += a[j]; if (sum >= K) { ans = std::max<LL>(ans, j + 1); sum -= a[j]; } } } ans = N - ans; out << ans << std::endl; return 0; }
a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory 1 | #include <bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s732836892
p03780
C++
#include "bits\stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) #define reps(i,j,N) for(LL i=j;i<N;++i) typedef long long int LL; typedef std::pair<int, int> P; int N, K, a[5112]; int ans; int main() { in >> N >> K; rep(i, N) { in >> a[i]; } LL sum; std::sort(a, a + N, std::greater<int>()); rep(i, N) { sum = 0; reps(j, i, N) { sum += a[j]; if (sum >= K) { ans = std::max<LL>(ans, j + 1); sum -= a[j]; } } } ans = N - ans; out << ans << std::endl; return 0; }
a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory 1 | #include "bits\stdc++.h" | ^~~~~~~~~~~~~~~ compilation terminated.
s257177069
p03780
C++
#include <iostream> #include <stdio.h> #include <string> #include <vector> #include <cmath> #include <algorithm> using namespace std; int main() { int N,K; cin >> N >> K; vector<long long int>A(N); for(int i=0; i < N; i++) cin >> A[i]; vector<vector<bool> >dp(N,vector<bool>(K)); int ans = 0; for(int i=0; i < N; i++){ long long int ai = A[i]; A[i] = 0; for(int y=0; y < K; y++){ if(A[0]==y) dp[0][y] = true; else dp[0][y] = false; } for(int x=0; x < N; x++){ dp[x][0] = true; } for(int x=1; x < N; x++){ for(int y=1; y < K; y++){ if(y-A[x] >= 0 && A[x] > 0) dp[x][y] = dp[x-1][y-A[x]]; if(dp[x][y] != true) dp[x][y] = dp[x-1][y]; } } } bool need = false; int s; if(K < ai) s = 0; else s = K-ai; for(int a=s; a < K; a++){ if(dp[N-1][a]){ need = true; break; } } if(need == false) ans++; A[i] = ai; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:12: error: 'ai' was not declared in this scope 41 | if(K < ai) s = 0; | ^~ a.cc:50:7: error: 'i' was not declared in this scope 50 | A[i] = ai; | ^ a.cc:50:12: error: 'ai' was not declared in this scope 50 | A[i] = ai; | ^~ a.cc: At global scope: a.cc:52:3: error: 'cout' does not name a type 52 | cout << ans << endl; | ^~~~ a.cc:53:3: error: expected unqualified-id before 'return' 53 | return 0; | ^~~~~~ a.cc:54:1: error: expected declaration before '}' token 54 | } | ^
s814838629
p03780
C++
#include<stdio.h> #include<stdlib.h> void main() { int N; int K; unsigned long long a[5000]; int i; int j; unsigned long long maxsum=0; unsigned long long *sets; unsigned long long sum[5000]; unsigned long long temp; unsigned long long necessary[5000]; int necessarycount=0; int unnecessary=0; scanf("%d %d",&N,&K); sets = (unsigned long long*) malloc (K); for(i=0; i<N;i++) { scanf("%llu",&a[i]); maxsum+=a[i]; } if(maxsum<K){ // all cards are unnecessary since cannot get full sum printf("%d\n",N); }else{ if(maxsum==K){ // all cards are necessary since need them to get full sum printf("0\n"); }else{ // find possible subsets of cards for(i=0; i<N; i++){ sum[i]=maxsum; necessary[i]=0; } for(i=0; i<N; i++){ for(j=0; j<N; j++) { temp = a[(i+j)%N]; if((sum[i]-temp)>=K) { sum[i]=sum[i]-temp; sets[i*N+j]=0; }else{ sets[i*N+j]=temp; } } } for(i=0;i<N;i++){ for(j=0;j<N;j++){ if(necessary[(i+j)%N]<sets[i*N+j]) { necessary[(i+j)%N]=sets[i*N+j]; necessarycount++; } } } unnecessary=N-necessarycount; printf("%d\n",unnecessary); } } free (sets); }
a.cc:4:1: error: '::main' must return 'int' 4 | void main() | ^~~~
s071535291
p03780
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> using namespace std; long long a[5001]; int main() { long long N,M,K,i,j,s,ans; scanf("%lld%lld",&N,&K); for(i=0; i<N; i++) scanf("%d",&a[i]); sort(a,a+N); ans=0,s=0; for(i=N-1; i>=0; i--) { s+=a[i]; ans++; if(s>=K) { s=0,ans=0; while(a[i]==a[i-1]&&i>0) i--; if(i==0) ans=0; } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:30:3: error: expected '}' at end of input 30 | } | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s784908437
p03780
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> using namespace std; long long a[5001]; int main() { long long N,M,K,i,j,s,ans; scanf("%lld%lld",&N,&K); for(i=0; i<N; i++) scanf("%d",&a[i]); sort(a,a+N); ans=0,s=0; for(i=N-1; i>=0; i--) { s+=a[i]; ans++; if(s>=K) { s=0,ans=0; while(a[i]==a[i-1]&&i>0) i--; if(i=0) ans=0; } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:30:3: error: expected '}' at end of input 30 | } | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s424104502
p03780
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; int main(){ long long int n,k,i,sum=0,plus=0,ans=0; cin>>n>>k; vector<int>A; int AA[n]; for(i=0;i<n;i++){ cin>>AA[i]; A.push_back(AA[i]); } sort(A.begin(), A.end() ); for(i=0;i<A.size;i++)sum+=A[i]; for(i=0;i<A.size;i++){ sum-=A[i]; if(sum<n)break; ans++; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:13: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 16 | for(i=0;i<A.size;i++)sum+=A[i]; | ~~^~~~ | () a.cc:17:13: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 17 | for(i=0;i<A.size;i++){ | ~~^~~~ | ()
s836906197
p03780
C++
#define SORT(v) sort(v.begin(), v.end()) #include <iostream> #include <map> #include <vector> #include <queue> #include <stack> #include <cstdlib> #include <algorithm> #include <cstdarg> #include <cstdio> #include <numeric> // #include "ane.cpp" #define INF (int)1e9 #define INFLL (long long)1e18 #define NMAX 5005 #define MMAX 5005 #define MOD 100000 using namespace std; // コメントアウトするとdb_printf()を実行しない #define DEBUG // デバッグ用printf void db_printf(const char* format, ...){ #ifndef DEBUG return; #endif va_list arg; va_start(arg, format); vprintf(format, arg); // コンソールに出力 va_end(arg); } // n次元配列の初期化。第2引数の型のサイズごとに初期化していく。 template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } typedef pair<int, int> p; typedef long long ll; ll N,M,K,A[NMAX],B,C,D,E; int dp[NMAX][MMAX] = {}; static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1}; static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1}; ll ans = 0; void solve(){ // 解答アルゴリズム sort(A, A+N); ll sum = 0; for (int i = 0; i < N && sum < M; ++i) { sum += A[i]; } if (sum < M) { ans = N; return; } ll dup=0; for (int i = 0; i < N; ++i) { sum -= A[i]; if (i && A[i] == A[i-1]) { dup++; }else{ dup = 0; } if(sum >= M)ans++; else break; } ans = max(0, ans - dup); } void debug(){ // デバッグ用出力 } void answer(){ // 解答出力 printf("%lld\n", ans); } int main(int argc, char const *argv[]) { // 入力の読み込み,番兵法 // Fill(dp, -1); scanf("%lld%lld", &N,&M); for (int i = 0; i < N; ++i) { scanf("%lld", &A[i]); } solve(); #ifdef DEBUG debug(); #endif answer(); return 0; }
a.cc: In function 'void solve()': a.cc:76:14: error: no matching function for call to 'max(int, ll)' 76 | ans = max(0, ans - dup); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:76:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 76 | ans = max(0, ans - dup); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:8: /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:76:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 76 | ans = max(0, ans - dup); | ~~~^~~~~~~~~~~~~~
s432811684
p03780
C
#include <stdio.h> #include <stdlib.h> int main() { int N,K,a[5000],b; scanf("%d %d",&N,&K); b=N; for(i=0;i<N;i++) { scanf("%d",a[i]); c+=a[i]; } while(c>=K) for(i=1;i<=N;i++) for(j=) }
main.c: In function 'main': main.c:9:9: error: 'i' undeclared (first use in this function) 9 | for(i=0;i<N;i++) | ^ main.c:9:9: note: each undeclared identifier is reported only once for each function it appears in main.c:12:9: error: 'c' undeclared (first use in this function) 12 | c+=a[i]; | ^ main.c:16:13: error: 'j' undeclared (first use in this function) 16 | for(j=) | ^ main.c:16:15: error: expected expression before ')' token 16 | for(j=) | ^ main.c:16:15: error: expected expression before ')' token main.c:18:1: error: expected expression before '}' token 18 | } | ^
s829715302
p03780
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> nums(N, 0); for (int i = 0; i < N; i++) cin >> nums[i]; sort(nums.begin(), nums.end()); int res = 0; int case_num = pow(2, N); for (int i = 0; i < N; i++){ int add = pow(2, i); int is_need = 0; int has = 0; for (int j = 0; j < case_num; j++){ if (((j >> i) & 1) == 0) { continue; } int sum = 0; for (int k = 0; k < 32; k++) { if (((j >> k) & 1) == 1) { sum += nums[k]; } } if (sum >= K) { has = 1; if (sum - nums[i] < K){ is_need = 1; } } if (is_need == 1) { break; } } if (has == 1 && is_need == 0) { res++; } } cout << res << endl; }
a.cc: In function 'int main()': a.cc:14:24: error: 'pow' was not declared in this scope 14 | int case_num = pow(2, N); | ^~~
s058663751
p03780
C++
#include <iostream> #include <queue> #include <map> #include <queue> #include <cmath> using namespace std; const int maxn = 5010; long long save[maxn]; long long sum[maxn][maxn]; int main(){ int n,i,j; long long k; scanf("%d%lld",&n,&k); for(i=1;i<=n;i++){ scanf("%lld",&save[i]); } sort(save+1, save+1+n); long long now = 0; for(i=1;i<=n;i++){ now += save[i]; if(now>=k){ break; } } bool flag = true; if(now>=k){ for(i=1;now>=k;i++){ now -= save[i]; } cout<<i-2<<endl; flag = false; } if(flag){ cout<<n<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 17 | sort(save+1, save+1+n); | ^~~~ | sqrt
s726352961
p03780
C++
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Yulian */ #include <iostream> #include <iostream> #include <fstream> #include <vector> #include <set> #include <cmath> #include <queue> #include <deque> #include <string> #include <algorithm> #include <map> #include <iostream> #include <fstream> #include <vector> #include <set> #include <cmath> #include <queue> #include <deque> #include <string> #include <algorithm> #include <map> #include <assert.h> using namespace std; class D { public: void rec(vector<int> &a, int k, int s, vector<bool> &g) { // int s = accumulate(v.begin(), v.end(), 0); // int s = accumulate(v.begin(), v.end(), 0); int tmp; for (int i = 0; i < a.size(); ++i) { if (a[i] != 0) { tmp = a[i]; if (s - tmp < k) { g[i] = g[i] || s >= k; } else { a[i] = 0; rec(a, k, s - tmp, g); a[i] = tmp; } } } } void solve(std::istream &in, std::ostream &out) { int n, k, res, sum = 0; in >> n >> k; vector<int> a(n); vector<bool> b(n, false); for (int i = 0; i < n; ++i) { in >> a[i]; } rec(a, k, accumulate(a.begin(), a.end(), 0), b); for (const auto &el : b) { if (!el) { ++res; } } out << res << endl; } }; int main() { D solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }
a.cc: In member function 'void D::solve(std::istream&, std::ostream&)': a.cc:67:15: error: 'accumulate' was not declared in this scope 67 | rec(a, k, accumulate(a.begin(), a.end(), 0), b); | ^~~~~~~~~~
s482304232
p03780
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> nums(N, 0); for (int i = 0; i < N; i++) cin >> nums[i]; sort(nums.begin(), nums.end()); int res = 0; int case_num = pow(2, N); for (int i = 0; i < N; i++){ int add = pow(2, i); int is_need = 0; int has = 0; for (int j = 0; j < case_num; j++){ if (((j >> i) & 1) == 0) { continue; } int sum = 0; for (int k = 0; k < 32; k++) { if (((j >> k) & 1) == 1) { sum += nums[k]; } } if (sum >= K) { has = 1; if (sum - nums[i] < K){ is_need = 1; } } if (is_need == 1) { break; } } if (has == 1 && is_need == 0) { res++; } } cout << res << endl; }
a.cc: In function 'int main()': a.cc:14:24: error: 'pow' was not declared in this scope 14 | int case_num = pow(2, N); | ^~~
s752132942
p03780
C++
#include<iostream> #include<algorithm> using namespace std; int a[5500]; int main() { int n, k; memset(a, 0, sizeof(a)); long long sum = 0; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum < k) { cout << n << endl; } else { sort(a, a + n); if (a[0] >= k) cout << 0 << endl; else { int ans; int tot = 0, tt = 0; for (int i = n - 1; i >= 0; i--) { if (a[i] >= k) { tt++; continue; } tot += a[i]; if (tot >= k) { ans = i; if ((i > 0) && (a[i - 1] == a[i])) { for (int j = i;; j--) { if (a[j] == a[i]) continue; if (a[j] < a[i]) { ans = j+1; break; } } } break; } } if (tot < k) ans = n - tt; cout << ans << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:10:9: error: 'memset' was not declared in this scope 10 | memset(a, 0, sizeof(a)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s457876404
p03780
C++
// // main.cpp // D // // Created by 黄宇凡 on 2017/3/18. // Copyright © 2017年 黄宇凡. All rights reserved. // #include <iostream> #include <cstdio> using namespace std; const int maxn = 405; int n,k; int a[maxn]; bool pre[maxn][maxn]; bool suf[maxn][maxn]; int main(int argc, const char * argv[]) { cin >> n >> k; long long sum = 0; for(int i = 1;i <= n;i++){ scanf("%d",a + i); sum += a[i]; } memset(pre,false,sizeof(pre)); memset(suf,false,sizeof(suf)); pre[0][0] = true; suf[n + 1][0] = true; for(int i = 1;i <= n;i++){ //pre[i][j] = pre[i - 1][j]; for(int j = k;j >= 0;j--){ pre[i][j] |= pre[i - 1][j]; if(j >= a[i])pre[i][j] |= pre[i - 1][j - a[i]]; } } for(int i = n;i >= 1;i--){ for(int j = k;j >= 0;j--){ suf[i][j] |= (suf[i + 1][j]); if(j >= a[i]) suf[i][j] |= suf[i + 1][j - a[i]]; } } /* for(int i = 0;i <= n + 1;i++){ for(int j = 0;j <= k;j++){ if(j == 0) continue; else {pre[i][j] |= pre[i][j - 1];suf[i][j] |= suf[i][j - 1];} } }*/ int ans = n; for(int i = 1;i <= n;i++){ bool flag = false; //bool f = false; for(int j = 0;j <= k - 1;j++){ for(int l = 0;l <= k - 1;l++){ if(pre[i - 1][j] && suf[i + 1][l] && (l + j < k) && (l + j + a[i] >= k)) flag = true; //if(pre[i - 1][j] && suf[i + 1][l] && (l + j + a[i]) >= k) f = true; // cout << suf[2][14] << endl; } } //cout << flag << " " << f << endl; if(flag) ans--; // if(!f) ans++; } //if(sum < (long long)k) ans += n; cout << ans << endl; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:31:5: error: 'memset' was not declared in this scope 31 | memset(pre,false,sizeof(pre)); | ^~~~~~ a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 10 | #include <cstdio> +++ |+#include <cstring> 11 | using namespace std;
s918576536
p03781
C++
#include<bits/stdc++.h> using namespace std; long long int x; cin>>x; cout<<0.5*(ceil(double(sqrt(8*x)))-1)<<"\n";
a.cc:4:1: error: 'cin' does not name a type 4 | cin>>x; | ^~~ a.cc:5:1: error: 'cout' does not name a type 5 | cout<<0.5*(ceil(double(sqrt(8*x)))-1)<<"\n"; | ^~~~
s186386836
p03781
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll mod=1000000007; int main() { ll n; cin>>n; ll aa=0; ll counter=0; for(ll i=1; i>0; i++){ aa+=i; counter++; if(aa==n){ cout<<counter<<endl; break;} else if(aa>n){ cout<<counter<<endl; break;}}} for(ll i=1; i<=m; i++){ aa=(aa*i)%mod;} aa=(aa*2)%mod; cout<<aa<<endl;}}
a.cc:20:1: error: expected unqualified-id before 'for' 20 | for(ll i=1; i<=m; i++){ | ^~~ a.cc:20:13: error: 'i' does not name a type 20 | for(ll i=1; i<=m; i++){ | ^ a.cc:20:19: error: 'i' does not name a type 20 | for(ll i=1; i<=m; i++){ | ^ a.cc:22:1: error: 'aa' does not name a type 22 | aa=(aa*2)%mod; | ^~ a.cc:23:1: error: 'cout' does not name a type 23 | cout<<aa<<endl;}} | ^~~~ a.cc:23:16: error: expected declaration before '}' token 23 | cout<<aa<<endl;}} | ^ a.cc:23:17: error: expected declaration before '}' token 23 | cout<<aa<<endl;}} | ^
s780635683
p03781
C++
#include<iostream> using namespace std; int main(){ int x; cin>>x; long long c=0; for(int i=0;i<1000000;i++){ c+=i; if(c>x){cout <<i<<endl;break}; } } }
a.cc: In function 'int main()': a.cc:9:33: error: expected ';' before '}' token 9 | if(c>x){cout <<i<<endl;break}; | ^ | ; a.cc: At global scope: a.cc:12:1: error: expected declaration before '}' token 12 | } | ^
s559129883
p03781
C++
#include <bits/stdc++.h> using namespace std; int main(){ int X; cin >> X; int p = 0; for (int i = 0; i < N; i++){ p+=i; if (X <= p){ cout << i; break; } } }
a.cc: In function 'int main()': a.cc:7:23: error: 'N' was not declared in this scope 7 | for (int i = 0; i < N; i++){ | ^
s611862026
p03781
C++
#include <iostream> #include <algorithm> #include <limits> using namespace std; int dest; int min_times = INT_MAX; int jump(int curr, int times) { if(curr == dest) return times - 1; if(curr > dest) return INT_MAX; if(times > min_times) return INT_MAX; int goRight = jump(curr + times, times + 1); if(goRight < min_times) min_times = goRight; int goLeft = jump(curr - times, times + 1); if(goLeft < min_times) min_times = goLeft; int notMove = jump(curr, times + 1); if(notMove < min_times) min_times = notMove; return min_times; } int main() { cin >> dest; int steps = jump(0, 0); cout << steps; return 0; }
a.cc:8:17: error: 'INT_MAX' was not declared in this scope 8 | int min_times = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <limits> +++ |+#include <climits> 4 | a.cc: In function 'int jump(int, int)': a.cc:15:16: error: 'INT_MAX' was not declared in this scope 15 | return INT_MAX; | ^~~~~~~ a.cc:15:16: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' a.cc:18:15: error: 'INT_MAX' was not declared in this scope 18 | return INT_MAX; | ^~~~~~~ a.cc:18:15: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s226011096
p03781
C++
#include <iostream> #include <algorithm> using namespace std; int dest; int min_times = INT_MAX; int jump(int curr, int times) { if(curr == dest) return times - 1; if(curr > dest) return INT_MAX; if(times > min_times) return INT_MAX; int goRight = jump(curr + times, times + 1); if(goRight < min_times) min_times = goRight; int goLeft = jump(curr - times, times + 1); if(goLeft < min_times) min_times = goLeft; int notMove = jump(curr, times + 1); if(notMove < min_times) min_times = notMove; return min_times; } int main() { cin >> dest; int steps = jump(0, 0); cout << steps; return 0; }
a.cc:7:17: error: 'INT_MAX' was not declared in this scope 7 | int min_times = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <algorithm> +++ |+#include <climits> 3 | a.cc: In function 'int jump(int, int)': a.cc:14:16: error: 'INT_MAX' was not declared in this scope 14 | return INT_MAX; | ^~~~~~~ a.cc:14:16: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' a.cc:17:15: error: 'INT_MAX' was not declared in this scope 17 | return INT_MAX; | ^~~~~~~ a.cc:17:15: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s390416430
p03781
C++
#include <bits/stdc++.h> #define r(i,n) for(int i = 0; i<n; i++) #define R(i,n) for(int i = 1; i<=n; i++) typedef long long ll; using namespace std; int main(){ int n,m=0; cin >> n; r(i,n){ m+=i; if(m>=n){ cout << i << endl; break; } } } }
a.cc:18:1: error: expected declaration before '}' token 18 | } | ^
s737361968
p03781
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <cmath> #include <numeric> #include <set> #include <list> #include <bitset> #include <cstdlib> using namespace std; int main() { int X; cin >> X; int step = 0; for (int i = 1; i <= X; i++) { if ((i * (i + 1)) / 2 == X) { cout << i << endl; break; } return 0; }
a.cc: In function 'int main()': a.cc:26:6: error: expected '}' at end of input 26 | } | ^ a.cc:14:1: note: to match this '{' 14 | { | ^
s766168680
p03781
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long x; cin>>x; for(int i=0;;i++){ if(1*(i+1)/2>=x){ cout<<t<<endl; return 0; } } }
a.cc: In function 'int main()': a.cc:8:13: error: 't' was not declared in this scope 8 | cout<<t<<endl; | ^
s034482918
p03781
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long x; cin>>x; for(int i=0;;i++){ if(t*(t+1)/2>=x){ cout<<t<<endl; return 0; } } }
a.cc: In function 'int main()': a.cc:7:8: error: 't' was not declared in this scope 7 | if(t*(t+1)/2>=x){ | ^
s987598781
p03781
C++
a
a.cc:1:1: error: 'a' does not name a type 1 | a | ^
s173531282
p03781
C++
#include<iostream> using namespace std; int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return 0;
a.cc: In function 'int main()': a.cc:14:14: error: expected '}' at end of input 14 | return 0; | ^ a.cc:6:1: note: to match this '{' 6 | { | ^
s633044525
p03781
C++
using namespace std; int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return 0;
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | 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 | using namespace std; a.cc:11:5: error: 'cout' was not declared in this scope 11 | cout << i; | ^~~~ a.cc:11:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:12:14: error: expected '}' at end of input 12 | return 0; | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s950683910
p03781
C++
using namespace std; int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return;
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | 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 | using namespace std; a.cc:11:5: error: 'cout' was not declared in this scope 11 | cout << i; | ^~~~ a.cc:11:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:12:5: error: return-statement with no value, in function returning 'int' [-fpermissive] 12 | return; | ^~~~~~ a.cc:12:12: error: expected '}' at end of input 12 | return; | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s998226369
p03781
C++
using namespace std; int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return 0;
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | 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 | using namespace std; a.cc:11:5: error: 'cout' was not declared in this scope 11 | cout << i; | ^~~~ a.cc:11:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:12:14: error: expected '}' at end of input 12 | return 0; | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s666746789
p03781
C++
#include <iostream> using namespace std; int main() { int i,n,s=0; cin>>n; for(i=1; ;i++){ s=s+i; if(s>=n)break; } cout <<i return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: expected ';' before 'return' 15 | cout <<i | ^ | ; ...... 18 | return 0; | ~~~~~~
s976467840
p03781
C++
using namespace std; int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return 0;
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | 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 | using namespace std; a.cc:11:5: error: 'cout' was not declared in this scope 11 | cout << i; | ^~~~ a.cc:11:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:12:14: error: expected '}' at end of input 12 | return 0; | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s390667715
p03781
C++
#include <iostream> using namespace std; int main() { int i,n,s=0; cin>>n; for(i=1; ;i++){ s=s+i; if(s>=n)break; } cout <<i return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: expected ';' before 'return' 15 | cout <<i | ^ | ; ...... 18 | return 0; | ~~~~~~
s262446884
p03781
C++
#include <iostream> using namespace std; int main() { int i,n,s=0; cin >> n; for(i=1; ; i++;){ s=s+i; if(s>=n) break; } cout << 1; return 0; }
a.cc: In function 'int main()': a.cc:9:19: error: expected ')' before ';' token 9 | for(i=1; ; i++;){ | ~ ^ | ) a.cc:9:20: error: expected primary-expression before ')' token 9 | for(i=1; ; i++;){ | ^
s391617708
p03781
C++
int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return 0;
a.cc: In function 'int main()': a.cc:4:5: error: 'cin' was not declared in this scope 4 | cin >> n; | ^~~ a.cc:9:5: error: 'cout' was not declared in this scope 9 | cout << i; | ^~~~ a.cc:10:14: error: expected '}' at end of input 10 | return 0; | ^ a.cc:2:1: note: to match this '{' 2 | { | ^
s808258269
p03781
C++
int main() { int n, i, s = 0; cin >> n; for (i = 1; ; i++) { s = s + i; if (s >= n) break; } cout << i; return 0;
a.cc: In function 'int main()': a.cc:4:5: error: 'cin' was not declared in this scope 4 | cin >> n; | ^~~ a.cc:9:5: error: 'cout' was not declared in this scope 9 | cout << i; | ^~~~ a.cc:10:14: error: expected '}' at end of input 10 | return 0; | ^ a.cc:2:1: note: to match this '{' 2 | { | ^
s553598567
p03781
C++
using namespace std; int main() { int n, i ,s = 0; cin >> n; for (i = 1; ; i++) { s = s+i; if (s >=n) break; } cout << i; return 0; }
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | 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 | using namespace std; a.cc:11:5: error: 'cout' was not declared in this scope 11 | cout << i; | ^~~~ a.cc:11:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s077132129
p03781
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const double EPS = 1e-9; const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef map<int, int> mi; typedef set<int> si; #define VV(T) vector<vector< T > > #define dump(x) cout << #x << " = " << (x) << endl #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl #define rep(i, n) REP(i, 0, n) // 0, 1, ..., n-1 #define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1 #define FOREACH(x,a) for(auto& (x) : (a) ) #define ALL(v) (v).begin() , (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define pb push_back #define pu push #define mp make_pair #define fi first #define sc second #define COUT(x) cout << (x) << endl #define VECCIN(x) for(auto&youso_: (x) )cin>>youso_ #define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; n > 0; i++) n -= i; cout << i - 1; return 0; }
a.cc: In function 'int main()': a.cc:48:13: error: 'i' was not declared in this scope 48 | cout << i - 1; | ^
s053957706
p03781
C++
l#include<iostream> #include<vector> using namespace std; int main(){ long long x,i; cin >> x; for(i=x;x<=i*(i+1)/2;i--); cout << i+1 << endl; }
a.cc:1:2: error: stray '#' in program 1 | l#include<iostream> | ^ a.cc:1:1: error: 'l' does not name a type 1 | l#include<iostream> | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 |
s130778071
p03781
C++
#include "bits/stdc++.h" #define ALL(x) x.begin(), x.end() #define LEN(x) (int)x.size() #define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0) using namespace std; typedef int64_t i64; typedef pair<int,int> pii; template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;} template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;} constexpr int INF = 0x3f3f3f3f; signed main() { i64 x ; cin >> x; i64 i = 1; i64 sum = 0; for (i = 1; sum < x; ++i) { sum += i; } cout << i-1 << endl; return 0; } #include "bits/stdc++.h" #define ALL(x) x.begin(), x.end() #define LEN(x) (int)x.size() #define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0) using namespace std; typedef int64_t i64; typedef pair<int,int> pii; template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;} template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;} constexpr int INF = 0x3f3f3f3f; signed main() { i64 x ; cin >> x; i64 i = 1; i64 sum = 0; for (i = 1; sum < x; ++i) { sum += i; } cout << i-1 << endl; return 0; }
a.cc:34:39: error: redefinition of 'template<class A, class B> bool chmax(A&, const B&)' 34 | template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;} | ^~~~~ a.cc:8:39: note: 'template<class A, class B> bool chmax(A&, const B&)' previously declared here 8 | template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;} | ^~~~~ a.cc:35:39: error: redefinition of 'template<class A, class B> bool chmin(A&, const B&)' 35 | template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;} | ^~~~~ a.cc:9:39: note: 'template<class A, class B> bool chmin(A&, const B&)' previously declared here 9 | template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;} | ^~~~~ a.cc:36:15: error: redefinition of 'constexpr const int INF' 36 | constexpr int INF = 0x3f3f3f3f; | ^~~ a.cc:10:15: note: 'constexpr const int INF' previously defined here 10 | constexpr int INF = 0x3f3f3f3f; | ^~~ a.cc:38:8: error: redefinition of 'int main()' 38 | signed main() | ^~~~ a.cc:12:8: note: 'int main()' previously defined here 12 | signed main() | ^~~~
s472278012
p03781
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in);) { new Main().solve(sc); } } void solve(Scanner sc) { int x = sc.nextInt(); int ans = 0; for (int i = 0; i < max; i++) { ans += i; if (ans >= x) { System.out.println(ans); break; } } } }
Main.java:13: error: cannot find symbol for (int i = 0; i < max; i++) { ^ symbol: variable max location: class Main 1 error
s475184075
p03781
C++
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i,n) for(int i=0;i<(int)n;++i) int main(){ int N, K; cin >> N >> K; vector<ll> a(N); REP(i, N) cin >> a[i]; ll res = 0; REP(i, N){ bool DP[K], DP_tmp[K]; REP(j, K) DP[j] = false; DP[0] = true; REP(j, N){ REP(k, K) DP_tmp[k] = DP[k]; if (j==i) continue; REP(k, K){ if (DP_tmp[k] && k+a[j]<K){ DP[k+a[j]]=true; } } } bool need = false; for(int j=max(K-a[i], 0);j<K;j++){ if (DP[j]) need = true; } res += need; } cout << N - res << endl; return 0; }
a.cc: In function 'int main()': a.cc:33:30: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)' 33 | for(int j=max(K-a[i], 0);j<K;j++){ | ~~~^~~~~~~~~~~ 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:33:30: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 33 | for(int j=max(K-a[i], 0);j<K;j++){ | ~~~^~~~~~~~~~~ /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:33:30: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 33 | for(int j=max(K-a[i], 0);j<K;j++){ | ~~~^~~~~~~~~~~
s046123560
p03781
C++
//123433333333364975546843924818757887827846493467345734648575757575757576618427973496421873454518738401246942481455434946194348649724846543794548
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s708659856
p03781
C++
#include <bits/stdc++.h> using namespace std ; int main () { int cnt = 0 , a ; cin >> a ; int j = 1 ; while ( 1 ){ cnt += j ; j ++ ; if ( cnt >= a ){ cout << i ; break ; } } }
a.cc: In function 'int main()': a.cc:14:21: error: 'i' was not declared in this scope 14 | cout << i ; | ^
s340465155
p03781
C++
#include <bits/stdc++.h> using namespace std ; int main () { int cnt = 0 , a ; cin >> a ; while ( 1 ){ cnt += i ; if ( cnt >= a ){ cout << cnt ; break ; } } } }
a.cc: In function 'int main()': a.cc:10:12: error: 'i' was not declared in this scope 10 | cnt += i ; | ^ a.cc: At global scope: a.cc:17:1: error: expected declaration before '}' token 17 | } | ^
s602615878
p03781
C++
using namespace std; int main() { int x,i; cin >> x; for(i = 0;x>0;x-=i) i++; cout << i << endl; return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: 'cin' was not declared in this scope 5 | cin >> x; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using namespace std; a.cc:8:9: error: 'cout' was not declared in this scope 8 | cout << i << endl; | ^~~~ a.cc:8:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:8:22: error: 'endl' was not declared in this scope 8 | cout << i << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | using namespace std;
s253052378
p03781
C++
N, K = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) ans = N t = 0 for i in range(N-1, -1, -1) : if t+a[i] < K : t += a[i] else : ans = min(ans, i) print(ans)
a.cc:1:1: error: 'N' does not name a type 1 | N, K = map(int, input().split()) | ^
s543887157
p03781
C++
#include<iostream> #include<cmath> double X; using namespace std; int main() { cin >> X; cout << long long(ceil((-1 + sqrt(1 + 8 * X)) / 2)) << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:17: error: expected primary-expression before 'long' 10 | cout << long long(ceil((-1 + sqrt(1 + 8 * X)) / 2)) << endl; | ^~~~
s585879988
p03781
C++
#include <iostream> using namespace std; int main(void){ int a; cin >> a; int num = 0; while (a > 0) num++; a >>= 1; } cout << num << endl; return 0; }
a.cc:16:1: error: 'cout' does not name a type 16 | cout << num << endl; | ^~~~ a.cc:18:1: error: expected unqualified-id before 'return' 18 | return 0; | ^~~~~~ a.cc:19:1: error: expected declaration before '}' token 19 | } | ^
s008357104
p03781
C++
ウー
a.cc:1:1: error: '\U000030a6\U000030fc' does not name a type 1 | ウー | ^~~~
s284138845
p03781
C++
ウー
a.cc:1:1: error: '\U000030a6\U000030fc' does not name a type 1 | ウー | ^~~~
s776192838
p03781
C++
using namespace std; #include<iostream> #include<string> int main() { int a,b,c,d,e,f; cin>>a>>b>>c>>d; f=c-a; e=d-b; if(e>1 && f>1) { for(int i=0;i<e-1;i++) cout<<"U"; for(int j=0;j<f-1;j++) cout<<"R"; cout<<"U"<<"RR"; for(int k=0;k<e;k++) cout<<"D"; for(int h=0;h<f-1;h++) cout<<"L"; cout<<"D"<<"LLURU"; for(int b=0;b<f-1;b++) cout<<"R"; for(int p=0;p<e;p++) cout<<"U"; for(int q=0;q<f-1;q++) cout<<"L"; cout<<"DLL"; for(int t=0;t<e;t++) cout<<"D"; cout<<"R"; } else { for(int b=0;b<e;b++) cout<<"U"; for(int b=0;b<f;b++) cout<<"L"; for(int b=0;b<e;b++) cout<<"D"; for(int b=0;b<f;b++) cout<<"L"; cout<<"L"; for(int b=0;b<e+1;b++) cout<<"U"; for(int b=0;b<f+1;b++) cout<<"R"; cout<<"DR"; for(int b=0;b<e+1;b++) cout<<"D"; for(int b=0;b<f+1;b++) cout<<"L"; cout<<"U"; } return 0;
a.cc: In function 'int main()': a.cc:63:14: error: expected '}' at end of input 63 | return 0; | ^ a.cc:9:1: note: to match this '{' 9 | { | ^
s639574143
p03781
Java
import java.util.Scanner; import java.util.ArrayList; public class Main{ ArrayList<int[]> kangs = new ArrayList<int[]>(); public void addKang(int pos, int steps){ int[] newKang = {pos, steps}; kangs.add(newKang); } public void clean(){ for(int i = 0; i < kangs.size() ; i++){ for(int j = i + 1; j < kangs.size(); j++){ if(kangs.get(i)[0] == kangs.get(j)[0]){ if(kangs.get(i)[1] <= kangs.get(j)[1]){ kangs.remove(j); } else if(kangs.get(i)[1] > kangs.get(j)[1]){ kangs.remove(i); kangs.add(i, kangs.get(j-1)); kangs.remove(j); } } } } for(int r = kangs.size() - 1; r >= 0 ; r--){ if(kangs.get(r)[0] < 0){ kangs.remove(r); } } } public void branch(int step){ ArrayList<int[]> replace = new ArrayList<int[]>(); for(int i = 0; i < kangs.size(); i++){ int[] currKang = kangs.get(i); int[] a1 = {currKang[0] + step, currKang[1] + 1}; int[] a2 = {currKang[0] - step, currKang[1] + 1}; int[] a3 = {currKang[0], currKang[1] + 1}; replace.add(a1); replace.add(a2); replace.add(a3); } kangs = replace; } public boolean hasFinished(int target){ for(int i = 0; i < kangs.size(); i++){ if(target == kangs.get(i)[0]){ return true; } } return false; } public void finalClean(int target){ for(int i = kangs.size() - 1; i >= 0 ; i--){ if(kangs.get(i)[0] != target){ kangs.remove(i); } } } public static void main(String[] args){ Scanner reader = new Scanner(System.in); int home = reader.nextInt(); //System.out.println(home); int step = 1; //int test = 0; KangHome aussie = new KangHome(); aussie.addKang(0,0); while(!aussie.hasFinished(home) /*&& test < 30*/){ aussie.branch(step); aussie.clean(); step++; } aussie.finalClean(home); int smallest = aussie.kangs.get(0)[1]; for(int i = 0; i < aussie.kangs.size(); i++){ if(aussie.kangs.get(i)[1] < smallest){ smallest = aussie.kangs.get(i)[1]; } } System.out.println(smallest); } }
Main.java:83: error: cannot find symbol KangHome aussie = new KangHome(); ^ symbol: class KangHome location: class Main Main.java:83: error: cannot find symbol KangHome aussie = new KangHome(); ^ symbol: class KangHome location: class Main 2 errors
s071599218
p03781
C++
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int X = sc.nextInt(); int result = 0; for(int i = 1; i <= X; i++){ if((i + 1) * i / 2 >= X){ result = i; break; } } System.out.println(result); sc.close(); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s216425047
p03781
Java
import java.util.Arrays; import java.util.Scanner; public class Main_070D { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void run() { int N = sc.nextInt(); int K = sc.nextInt(); int[] a = sc.nextIntArray(N); Arrays.sort(a); long sum = 0; for (int i = 0; i < N; i++) { sum += a[i]; } if (sum < K) { System.out.println(N); return; } int l = -1; int r = N; while (r - l > 1) { int mid = (l + r) / 2; if (isNeed(N, K, a, mid)) r = mid; else l = mid; } System.out.println(l + 1); } boolean isNeed(int n, int k, int[] a, int m) { // b[m]を利用しない部分集合を考える boolean[][] dp = new boolean[n + 1][k]; dp[0][0] = true; for (int i = 0; i < n; i++) { if (i == m) { for (int j = 0; j < k; j++) { if (dp[i][j]) dp[i + 1][j] = true; } } else { for (int j = 0; j < k; j++) { if (dp[i][j]) dp[i + 1][j] = true; if (dp[i][j] && j + a[i] < k) dp[i + 1][j + a[i]] = true; } } } for (int i = 0; i <= n; i++) { for (int j = 0; j < k; j++) { if (dp[i][j] && j + a[m] >= k) { return true; } } } return false; } public static void main(String[] args) { new Main_070D().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(int[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } boolean inner(int h, int w, int limH, int limW) { return 0 <= h && h < limH && 0 <= w && w < limW; } void swap(char[] x, int a, int b) { char tmp = x[a]; x[a] = x[b]; x[b] = tmp; } // find minimum i (k <= a[i]) int lower_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k <= a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } // find minimum i (k < a[i]) int upper_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k < a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } boolean palindrome(String s) { for (int i = 0; i < s.length() / 2; i++) { if (s.charAt(i) != s.charAt(s.length() - 1 - i)) { return false; } } return true; } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } int[] nextIntArray(int n) { int[] in = new int[n]; for (int i = 0; i < n; i++) { in[i] = nextInt(); } return in; } int[][] nextInt2dArray(int n, int m) { int[][] in = new int[n][m]; for (int i = 0; i < n; i++) { in[i] = nextIntArray(m); } return in; } double[] nextDoubleArray(int n) { double[] in = new double[n]; for (int i = 0; i < n; i++) { in[i] = nextDouble(); } return in; } long[] nextLongArray(int n) { long[] in = new long[n]; for (int i = 0; i < n; i++) { in[i] = nextLong(); } return in; } char[][] nextCharField(int n, int m) { char[][] in = new char[n][m]; for (int i = 0; i < n; i++) { String s = sc.next(); for (int j = 0; j < m; j++) { in[i][j] = s.charAt(j); } } return in; } } }
Main.java:5: error: class Main_070D is public, should be declared in a file named Main_070D.java public class Main_070D { ^ 1 error
s729160960
p03781
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; const ll MAXN=1e9+7; ll dp[MAXN]; vector<ll> dp2; vector<ll> nextdp2; int main(){ ll X; cin>>X; dp2.push_back(0); nextdp2.push_back(0); ll ret;ret=0; for(ll a=1;a<=X;++a){ for (ll b=0;b<dp2.size();++b){ if (dp[dp2[b]+a]>0){ dp[dp2[b]+a]=min(dp[dp2[b]+a],a); } else {dp[dp2[b]+a]=a; nextdp2.push_back(dp2[b]+a);} if(dp2[b]+a==X){ret=a;break;} } if(ret!=0)break; dp2=nextdp2; } cout<<ret<<endl; return 0; }
/tmp/cc6JGkAg.o: in function `main': a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `nextdp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0xc4): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x108): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x141): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x174): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `nextdp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x1ae): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc6JGkAg.o a.cc:(.text+0x20c): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s389620455
p03781
C
#include <stdio.h> int main() {     int i,a,n,sum=0;      //    for(i=1;i<=44720;i++){ //        sum+=i; //    } //    printf("%d\n",sum); //    return 0;     scanf("%d",&n);     for(i=1;i<=n;i++){         a=sum;         sum+=i;         if(n>a && n<=sum){             printf("%d\n",i);             return 0;         }     }      //    sum=n; //    for(i=1;i<=n;i++){ // //        if(sum>i) //            sum-=i;     //        else{ //            printf("%d\n",i); //            return 0; //        } //    }                }
main.c: In function 'main': main.c:4:1: error: stray '\302' in program 4 | <U+00A0><U+00A0><U+00A0><U+00A0>int i,a,n,sum=0; | ^~~~~~~~ main.c:4:2: error: stray '\302' in program 4 | <U+00A0><U+00A0><U+00A0><U+00A0>int i,a,n,sum=0; | ^~~~~~~~ main.c:4:3: error: stray '\302' in program 4 | <U+00A0><U+00A0><U+00A0><U+00A0>int i,a,n,sum=0; | ^~~~~~~~ main.c:4:4: error: stray '\302' in program 4 | <U+00A0><U+00A0><U+00A0><U+00A0>int i,a,n,sum=0; | ^~~~~~~~ main.c:5:1: error: stray '\302' in program 5 | <U+00A0><U+00A0><U+00A0><U+00A0> | ^~~~~~~~ main.c:5:2: error: stray '\302' in program 5 | <U+00A0><U+00A0><U+00A0><U+00A0> | ^~~~~~~~ main.c:5:3: error: stray '\302' in program 5 | <U+00A0><U+00A0><U+00A0><U+00A0> | ^~~~~~~~ main.c:5:4: error: stray '\302' in program 5 | <U+00A0><U+00A0><U+00A0><U+00A0> | ^~~~~~~~ main.c:11:1: error: stray '\302' in program 11 | <U+00A0><U+00A0><U+00A0><U+00A0>scanf("%d",&n); | ^~~~~~~~ main.c:11:2: error: stray '\302' in program 11 | <U+00A0><U+00A0><U+00A0><U+00A0>scanf("%d",&n); | ^~~~~~~~ main.c:11:3: error: stray '\302' in program 11 | <U+00A0><U+00A0><U+00A0><U+00A0>scanf("%d",&n); | ^~~~~~~~ main.c:11:4: error: stray '\302' in program 11 | <U+00A0><U+00A0><U+00A0><U+00A0>scanf("%d",&n); | ^~~~~~~~ main.c:13:1: error: stray '\302' in program 13 | <U+00A0><U+00A0><U+00A0><U+00A0>for(i=1;i<=n;i++){ | ^~~~~~~~ main.c:13:2: error: stray '\302' in program 13 | <U+00A0><U+00A0><U+00A0><U+00A0>for(i=1;i<=n;i++){ | ^~~~~~~~ main.c:13:3: error: stray '\302' in program 13 | <U+00A0><U+00A0><U+00A0><U+00A0>for(i=1;i<=n;i++){ | ^~~~~~~~ main.c:13:4: error: stray '\302' in program 13 | <U+00A0><U+00A0><U+00A0><U+00A0>for(i=1;i<=n;i++){ | ^~~~~~~~ main.c:14:1: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:2: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:3: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:4: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:5: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:6: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:7: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:14:8: error: stray '\302' in program 14 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>a=sum; | ^~~~~~~~ main.c:15:1: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:2: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:3: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:4: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:5: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:6: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:7: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:15:8: error: stray '\302' in program 15 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>sum+=i; | ^~~~~~~~ main.c:16:1: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:2: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:3: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:4: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:5: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:6: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:7: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:16:8: error: stray '\302' in program 16 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>if(n>a && n<=sum){ | ^~~~~~~~ main.c:17:1: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:2: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:3: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:4: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:5: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:6: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:7: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:8: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:9: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:10: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:11: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:17:12: error: stray '\302' in program 17 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>printf("%d\n",i); | ^~~~~~~~ main.c:18:1: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; | ^~~~~~~~ main.c:18:2: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; | ^~~~~~~~ main.c:18:3: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; | ^~~~~~~~ main.c:18:4: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; | ^~~~~~~~ main.c:18:5: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; | ^~~~~~~~ main.c:18:6: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; | ^~~~~~~~ main.c:18:7: error: stray '\302' in program 18 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>return 0; |
s081284514
p03781
C++
#include <stdio.h> int main() {     int i,a,n,sum=0;      //    for(i=1;i<=44720;i++){ //        sum+=i; //    } //    printf("%d\n",sum); //    return 0;     scanf("%d",&n);     for(i=1;i<=n;i++){         a=sum;         sum+=i;         if(n>a && n<=sum){             printf("%d\n",i);             return 0;         }     }      //    sum=n; //    for(i=1;i<=n;i++){ // //        if(sum>i) //            sum-=i;     //        else{ //            printf("%d\n",i); //            return 0; //        } //    }                }
a.cc:4:1: error: extended character   is not valid in an identifier 4 |     int i,a,n,sum=0; | ^ a.cc:4:1: error: extended character   is not valid in an identifier a.cc:4:1: error: extended character   is not valid in an identifier a.cc:4:1: error: extended character   is not valid in an identifier a.cc:5:1: error: extended character   is not valid in an identifier 5 |      | ^ a.cc:5:1: error: extended character   is not valid in an identifier a.cc:5:1: error: extended character   is not valid in an identifier a.cc:5:1: error: extended character   is not valid in an identifier a.cc:11:1: error: extended character   is not valid in an identifier 11 |     scanf("%d",&n); | ^ a.cc:11:1: error: extended character   is not valid in an identifier a.cc:11:1: error: extended character   is not valid in an identifier a.cc:11:1: error: extended character   is not valid in an identifier a.cc:13:1: error: extended character   is not valid in an identifier 13 |     for(i=1;i<=n;i++){ | ^ a.cc:13:1: error: extended character   is not valid in an identifier a.cc:13:1: error: extended character   is not valid in an identifier a.cc:13:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier 14 |         a=sum; | ^ a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier 15 |         sum+=i; | ^ a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier 16 |         if(n>a && n<=sum){ | ^ a.cc:16:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier 17 |             printf("%d\n",i); | ^ a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier 18 |             return 0; | ^ a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:18:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier 19 |         } | ^ a.cc:19:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier a.cc:19:1: error: extended character   is not valid in an identifier a.cc:21:1: error: extended character   is not valid in an identifier 21 |     } | ^ a.cc:21:1: error: extended character   is not valid in an identifier a.cc:21:1: error: extended character   is not valid in an identifier a.cc:21:1: error: extended character   is not valid in an identifier a.cc:22:1: error: extended character   is not valid in an identifier 22 |      | ^ a.cc:22:1: error: extended character   is not valid in an identifier a.cc:22:1: error: extended character   is not valid in an identifier a.cc:22:1: error: extended character   is not valid in an identifier a.cc:33:1: error: extended character   is not valid in an identifier 33 |      | ^ a.cc:33:1: error: extended character   is not valid in an identifier a.cc:33:1: error: extended character   is not valid in an identifier a.cc:33:1: error: extended character   is not valid in an identifier a.cc:34:1: error: extended character   is not valid in an identifier 34 |      | ^ a.cc:34:1: error: extended character   is not valid in an identifier a.cc:34:1: error: extended character   is not valid in an identifier a.cc:34:1: error: extended character   is not valid in an identifier a.cc:35:1: error: extended character   is not valid in an identifier 35 |      | ^ a.cc:35:1: error: extended character   is not valid in an identifier a.cc:35:1: error: extended character   is not valid in an identifier a.cc:35:1: error: extended character   is not valid in an identifier a.cc: In function 'int main()': a.cc:4:1: error: '\U000000a0\U000000a0\U000000a0\U000000a0int' was not declared in this scope 4 |     int i,a,n,sum=0; | ^~~~~~~ a.cc:5:1: error: '\U000000a0\U000000a0\U000000a0\U000000a0' was not declared in this scope 5 |      | ^~~~ a.cc:13:9: error: 'i' was not declared in this scope 13 |     for(i=1;i<=n;i++){ | ^ a.cc:13:16: error: 'n' was not declared in this scope 13 |     for(i=1;i<=n;i++){ | ^ a.cc:22:5: error: expected ';' before '\U000000a0\U000000a0\U000000a0\U000000a0' 22 |      | ^ | ; ...... 33 |      | ~~~~
s555585913
p03781
C++
#include <bits/stdc++..h> using namespace std; int main() { int n, p = 0; cin >> n; for(int i = 1; i*(i+1) < 2*n; i++) p = i; cout << p+1; }
a.cc:1:10: fatal error: bits/stdc++..h: No such file or directory 1 | #include <bits/stdc++..h> | ^~~~~~~~~~~~~~~~ compilation terminated.
s842087766
p03781
C
#include <cstdio> main() { int x; scanf("%d",&x); int s = 0, ans = 0,i = 1; while(s < x) { s += i++; ans++; } printf("%d\n",ans); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s938707421
p03781
C++
#include <cstdio> #include <algorithm> #include <iostream> #include <cstring> using namespace std; int n; int l[405],r[405]; int d[405][405]; int go(int now,int leftx){ if(now == n) return 0; int &ans = d[now][leftx]; if(ans!=-1) return ans; int rightend = leftx + r[now-1]-l[now-1]; ans = 987654321; for(int k=1;k<=400;k++){ int rnew = k + r[now] - l[now]; if(rnew < leftx || rnow < k) continue; //if(max(k,leftx) <= min(rnew,rightend)){ ans = min(ans,go(now+1,k) + abs(k-l[now])); //} } return ans; } int main() { scanf("%d",&n); if(n>=401) return 0; for(int i=0;i<n;i++){ scanf("%d %d",&l[i],&r[i]); } memset(d,-1,sizeof(d)); int res = 987654321; for(int i=1;i<=400;i++){ res = min(res,go(1,i)+abs(i-l[0])); } printf("%d\n",res); }
a.cc: In function 'int go(int, int)': a.cc:23:28: error: 'rnow' was not declared in this scope; did you mean 'rnew'? 23 | if(rnew < leftx || rnow < k) continue; | ^~~~ | rnew
s436443243
p03781
C
#include <stdio.h> int main(){ int a; int b=0; scanf(%d,&a); if(a>=0){ a=a-b; b++; } printf("%d",a); }
main.c: In function 'main': main.c:5:15: error: expected expression before '%' token 5 | scanf(%d,&a); | ^
s895783862
p03781
C
#include <stdio.h> int main(){ int a; int b=0; scanf(%d,&a); if(a>=0){ a=a-b; b++; } printf("%d",a); }
main.c: In function 'main': main.c:5:15: error: expected expression before '%' token 5 | scanf(%d,&a); | ^
s008861577
p03781
C
#include <stdio.h> int main(){ int a; int b=0; scanf(%d,&a); if(a>=0){ a=a-b; b++; } }
main.c: In function 'main': main.c:5:15: error: expected expression before '%' token 5 | scanf(%d,&a); | ^
s106718827
p03781
C
#include <stdio.h> int main(){ int a,b=0; scanf(%d,&a); if(a>=0){ a=a-b; b++; } }
main.c: In function 'main': main.c:4:15: error: expected expression before '%' token 4 | scanf(%d,&a); | ^
s513453404
p03781
C++
#include <bits/stdc++.h> #define N 2006 using namespace std; int a,b,n,t,p[N],ans[N];char c; int ask(int x,int y) { printf("? %d %d\n",x,y); fflush(stdout); scanf("%*c%c",&c); return c=='Y'?1:0; } int main() { scanf("%d%d",&a,&b);n=a+b; if(a<=b)return puts("Impossible"),0; for(int i=0;i<n;i++){ if(t){ if(ask(i,p[t]))p[++t]=i; else t--; }else p[++t]=i; } for(int i=0;i<n;i++)ans[i]=ask(p[t],i); printf('! '); for(int i=0;i<n;i++)putchar(ans[i]+48); return puts(""),0; }
a.cc:23:16: warning: multi-character character constant [-Wmultichar] 23 | printf('! '); | ^~~~ a.cc: In function 'int main()': a.cc:23:16: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 23 | printf('! '); | ^~~~ | | | int In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/stdio.h:363:43: note: initializing argument 1 of 'int printf(const char*, ...)' 363 | extern int printf (const char *__restrict __format, ...); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
s431662715
p03781
C++
#include <stdio.h> #include <math.h> int getX(n) { return n * (n+1) / 2; } int test(x) { int a = (int)sqrt((int)0x7FFFFFFF); int SUM[1000000]; SUM[0] = 0; for(int i=1;i<a;i++) { SUM[i] = SUM[i-1] + i; } for(int i=0;i<a;i++) { if(SUM[i] >= x) { return i; } } return -1; } int main() { int X; scanf("%d", &X); printf("%d\n", test(X)); return 0; }
a.cc:4:10: error: 'n' was not declared in this scope; did you mean 'yn'? 4 | int getX(n) { | ^ | yn a.cc:8:10: error: 'x' was not declared in this scope 8 | int test(x) { | ^ a.cc: In function 'int main()': a.cc:30:22: error: 'test' cannot be used as a function 30 | printf("%d\n", test(X)); | ~~~~^~~
s873779824
p03781
C++
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9) + 7; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } bitset<5010> left[5010], right[5010]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; vector<int>a(N + 1, -INF); rep(i, 1, N + 1)cin >> a[i]; sort(all(a)); int ans(N); left[0][0] = right[0][0] = 1; rep(i, 1, N + 1) { left[i] = left[i - 1]; if (a[i] >= K)continue; rrep(j, 0, K - a[i]) { if (left[i][j]) { left[i][j + a[i]] = 1; } } } rep(i, 1, N + 1) { right[i] = right[i - 1]; if (a[N + 1 - i] >= K)continue; rrep(j, 0, K - a[i]) { if (right[i][j]) { right[i][j + a[i]] = 1; } } } rep(i, 1, N + 1) { if (a[i] >= K) { ans--; continue; } // left[i-1] right[N-i] rep(j, 0, K - a[i]) { // left[i-1][j] right[N-i][K-a[i]-j] bool f(false); rep(k, K - a[i] - j, K - j) { if (left[i - 1][j] && right[N - i][K - a[i] - j]) { f = true; break; } } if (f) { ans--; break; } } } //vector<bool>f; //rep(i, 0, N) { // f = vector<bool>(K + 100, false); // f[0] = true; // if (a[i] >= K) { // ans++; // continue; // } // rep(j, 0, N) { // if (i == j)continue; // rrep(k, a[j], K + 100) { // f[k] = f[k - a[j]] || f[k]; // } // } // bool g(false); // rep(k, K - a[i], K)g = f[k] || g; // ans += g; // dump(ans); // //rep(i, 0, K + 100)cout << i << (i == K + 100 - 1 ? '\n' : ' '); // //rep(i, 0, K + 100)cout << f[i] << (i == K + 100 - 1 ? '\n' : ' '); //} // cout << ans << endl; //sort(all(a)); //vector<int>s(a); //rep(i, 1, N)s[i] += s[i - 1]; //auto x = lower_bound(all(s), K); //if (x == s.end()) { // cout << N << endl; // return 0; //} //int i(0); //while (*x>=K) { // *x -= a[i]; // i++; //} //cout << i-1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:9: error: reference to 'left' is ambiguous 28 | left[0][0] = right[0][0] = 1; | ^~~~ In file included from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54, from a.cc:1: /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:28:22: error: reference to 'right' is ambiguous 28 | left[0][0] = right[0][0] = 1; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:30:17: error: reference to 'left' is ambiguous 30 | left[i] = left[i - 1]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:30:27: error: reference to 'left' is ambiguous 30 | left[i] = left[i - 1]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:33:29: error: reference to 'left' is ambiguous 33 | if (left[i][j]) { | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:34:33: error: reference to 'left' is ambiguous 34 | left[i][j + a[i]] = 1; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:39:17: error: reference to 'right' is ambiguous 39 | right[i] = right[i - 1]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:39:28: error: reference to 'right' is ambiguous 39 | right[i] = right[i - 1]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:42:29: error: reference to 'right' is ambiguous 42 | if (right[i][j]) { | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:43:33: error: reference to 'right' is ambiguous 43 | right[i][j + a[i]] = 1; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:58:37: error: reference to 'left' is ambiguous 58 | if (left[i - 1][j] && right[N - i][K - a[i] - j]) { | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:58:55: error: reference to 'right' is ambiguous 58 | if (left[i - 1][j] && right[N - i][K - a[i] - j]) { | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~
s937451328
p03781
Java
public static void main(String[] args) { int x = 0; Scanner s = new Scanner(System.in); x = s.nextInt(); int t = 0; t = s.nextInt(); int now = 0; int ans = 0; for(int i = t; i > 0; i--) { if(now + t == x) { ans++; break; } else if(now + t < x) { now += t; ans++; } } System.out.println(ans); }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) { ^ (use --enable-preview to enable unnamed classes) 1 error
s704031845
p03781
Java
public static void main(String[] args) { int x = 0; Scanner s = new Scanner(System.in); x = s.nextInt(); int t = 0; t = s.nextInt(); int now = 0; int ans = 0; for(int i = t; i > 0; i--) { if(now + t == x) { ans++; break; } else if(now + t < x) { now += t; ans++; } } System.out.println(ans); }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) { ^ (use --enable-preview to enable unnamed classes) 1 error
s237257010
p03781
Java
public static void main(String[] arg) { int x = 0; Scanner s = new Scanner(System.in); x = s.nextInt(); int t = 0; t = s.nextInt(); int now = 0; int ans = 0; for(int i = t; i > 0; i--) { if(now + t == x) { ans++; break; } else if(now + t < x) { now += t; ans++; } } System.out.println(ans); }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] arg) { ^ (use --enable-preview to enable unnamed classes) 1 error
s945872189
p03781
Java
import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); int X = scanner.nextInt() { if (int i = 1 ; i <= X ; i++) { for (i * (i + 1) / 2 >= X) { System.out.println(i); break; } } } } }
Main.java:7: error: ';' expected int X = scanner.nextInt() { ^ Main.java:8: error: '.class' expected if (int i = 1 ; i <= X ; i++) { ^ Main.java:8: error: not a statement if (int i = 1 ; i <= X ; i++) { ^ Main.java:8: error: ';' expected if (int i = 1 ; i <= X ; i++) { ^ Main.java:9: error: not a statement for (i * (i + 1) / 2 >= X) { ^ Main.java:9: error: ';' expected for (i * (i + 1) / 2 >= X) { ^ 6 errors
s036775412
p03781
C
#inculed<stdio.h> int main (void){ int x,i,jump_cnt; scanf("%d",&x); for(i=0;i>x;i++){ jump_cnt=x/i; if(jump_cnt<=i)break; } printf("%d\n",i); }
main.c:1:2: error: invalid preprocessing directive #inculed; did you mean #include? 1 | #inculed<stdio.h> | ^~~~~~~ | include main.c: In function 'main': main.c:4:1: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 4 | scanf("%d",&x); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #inculed<stdio.h> main.c:4:1: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 4 | scanf("%d",&x); | ^~~~~ main.c:4:1: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:9:1: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 9 | printf("%d\n",i); | ^~~~~~ main.c:9:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:9:1: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:9:1: note: include '<stdio.h>' or provide a declaration of 'printf'
s323475984
p03781
C
#inculed<stdio.h> int main (void){ int x,i,jump_cnt; scanf("%d"&x); for(i=0;i>x;i++){ jump_cnt=x/i; if(jump_cnt<=i)break; } printf("%d.\n"i); }
main.c:1:2: error: invalid preprocessing directive #inculed; did you mean #include? 1 | #inculed<stdio.h> | ^~~~~~~ | include main.c: In function 'main': main.c:4:1: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 4 | scanf("%d"&x); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #inculed<stdio.h> main.c:4:1: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 4 | scanf("%d"&x); | ^~~~~ main.c:4:1: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:4:11: error: invalid operands to binary & (have 'char *' and 'int') 4 | scanf("%d"&x); | ~~~~^ | | | char * main.c:9:1: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 9 | printf("%d.\n"i); | ^~~~~~ main.c:9:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:9:1: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:9:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:9:15: error: expected ')' before 'i' 9 | printf("%d.\n"i); | ~ ^ | )
s445871271
p03781
C++
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <map> #include <vector> #include <sstream> #include <typeinfo> #include <fstream> #include <limits> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n , k; cin >> n >> k; vector<long long> a(n+1, 0); for(int i = 0; i < n; ++i){ cin >> a[i]; } // { // long long sum = 0; // bool isOk = false; // for(int i = 0; i < n; ++i){ // sum += a[i]; // if(k<=sum) { // isOk = true; // break; // } // } // if(!isOk) { // // cout << n << endl; // // return 0; // } // } sort(a.rbegin(), a.rend()); long long temp = 0; // sum long long first = 0; long long lastAns = -1; long long lastAnsNum = -1; for(int i = 0; i < n; ++i){ // cout << a[i] << " "; temp += a[i]; if(k<=temp) { // cout << "!" << endl; lastAns = i; lastAnsNum = min(lastAnsNum, a[i], k - (temp - a[i])); // a[i]; // cout << temp << endl; // cout << lastAnsNum << endl; // cout << k << " " << temp - a[i] << " " << k - (temp - a[i]) << endl; temp -= a[first]; first += 1; } // cout << "temp" << temp << endl; // cout << "lastasn" << lastAns << endl; // cout << "----------------------------" << endl; } if(lastAnsNum == -1) { cout << n << endl; return 0; } long long ans = 0; for(int i = 0; i < n; ++i){ // cout << lastAnsNum << " " << a[i] << endl; // cout << (a[i] < lastAnsNum) << endl; if (a[i] < lastAnsNum) { // cout << (a[i] < lastAnsNum) << endl; ans++; } } cout << ans << endl; return 0; }
In file included from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:59:29: required from here 59 | lastAnsNum = min(lastAnsNum, a[i], k - (temp - a[i])); // a[i]; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s336836974
p03781
C++
#include <iostream> using namespace std; #define F first #define S second #define ios ios_base::sync_with_stdio(0);cin.tie(0); typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; ll x; vector<int>tmp[6005]; vector<int>shel_dplft[6005]; vector<int>shel_dprt[6005]; int main() { ll n, k; cin >> n >> k; vector<ll>a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; vector<int>dp(5001, 0); dp[0] = 1; for(int i = 1; i <= n; i++){ vector<int>lol; for(int j = 5000 - a[i]; j>=0; j--) dp[j + a[i]] += dp[j]; for(int j = 0; j <= 5000; j++) if(dp[j]) lol.push_back(j); shel_dplft[i] = lol; } dp.clear(); dp.assign(5001, 0); dp[0] = 1; for(int i = n; i >= 1; i--){ vector<int>lol; for(int j = 5000 - a[i]; j>=0; j--) dp[j + a[i]] += dp[j]; for(int j = 0; j <= 5000; j++) if(dp[j]) lol.push_back(j); shel_dprt[i] = lol; } shel_dplft[0].push_back(0); shel_dprt[n + 1].push_back(0); int cnt = 0; for(int i = 1; i <= n; i++){ vector<int>red = shel_dplft[i-1]; vector<int>blue = shel_dprt[i + 1]; for(auto v : red){ int lo = 0, hi = blue.size() - 1; while(lo < hi){ int md =lo + (hi - lo + 1)/2; if(v + blue[md] < k) lo = md; else hi = md - 1; } if(v + blue[lo] + a[i] >= k && v + blue[lo] < k){ cnt++; break; } } } cout << n - cnt << '\n'; return 0; }
a.cc:8:9: error: 'vector' does not name a type 8 | typedef vector<int> vi; | ^~~~~~ a.cc:10:1: error: 'vector' does not name a type 10 | vector<int>tmp[6005]; | ^~~~~~ a.cc:11:1: error: 'vector' does not name a type 11 | vector<int>shel_dplft[6005]; | ^~~~~~ a.cc:12:1: error: 'vector' does not name a type 12 | vector<int>shel_dprt[6005]; | ^~~~~~ a.cc: In function 'int main()': a.cc:16:5: error: 'vector' was not declared in this scope 16 | vector<ll>a(n + 1); | ^~~~~~ a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 1 | #include <iostream> +++ |+#include <vector> 2 | using namespace std; a.cc:16:14: error: expected primary-expression before '>' token 16 | vector<ll>a(n + 1); | ^ a.cc:16:15: error: 'a' was not declared in this scope 16 | vector<ll>a(n + 1); | ^ a.cc:19:12: error: expected primary-expression before 'int' 19 | vector<int>dp(5001, 0); | ^~~ a.cc:20:5: error: 'dp' was not declared in this scope 20 | dp[0] = 1; | ^~ a.cc:22:16: error: expected primary-expression before 'int' 22 | vector<int>lol; | ^~~ a.cc:27:17: error: 'lol' was not declared in this scope; did you mean 'll'? 27 | lol.push_back(j); | ^~~ | ll a.cc:28:9: error: 'shel_dplft' was not declared in this scope 28 | shel_dplft[i] = lol; | ^~~~~~~~~~ a.cc:28:25: error: 'lol' was not declared in this scope; did you mean 'll'? 28 | shel_dplft[i] = lol; | ^~~ | ll a.cc:34:16: error: expected primary-expression before 'int' 34 | vector<int>lol; | ^~~ a.cc:39:17: error: 'lol' was not declared in this scope; did you mean 'll'? 39 | lol.push_back(j); | ^~~ | ll a.cc:40:9: error: 'shel_dprt' was not declared in this scope 40 | shel_dprt[i] = lol; | ^~~~~~~~~ a.cc:40:24: error: 'lol' was not declared in this scope; did you mean 'll'? 40 | shel_dprt[i] = lol; | ^~~ | ll a.cc:42:5: error: 'shel_dplft' was not declared in this scope 42 | shel_dplft[0].push_back(0); | ^~~~~~~~~~ a.cc:43:5: error: 'shel_dprt' was not declared in this scope 43 | shel_dprt[n + 1].push_back(0); | ^~~~~~~~~ a.cc:46:16: error: expected primary-expression before 'int' 46 | vector<int>red = shel_dplft[i-1]; | ^~~ a.cc:47:16: error: expected primary-expression before 'int' 47 | vector<int>blue = shel_dprt[i + 1]; | ^~~ a.cc:48:22: error: 'red' was not declared in this scope 48 | for(auto v : red){ | ^~~ a.cc:49:30: error: 'blue' was not declared in this scope 49 | int lo = 0, hi = blue.size() - 1; | ^~~~
s265073871
p03781
C++
#include <bits/stdc++.h> using namespace std; int main() { int x; cin>>x; if (x<=1) cout<<"1"; else if (x<=3) cout<<"2"; else if (x<=6) cout<<"3"; else if (x<=10 cout<<"4"; else if (x<=15) cout<<"5"; else if (x<=21) cout<<"6"; else if (x<=28) cout<<"7"; else if (x<=36) cout<<"8"; else if (x<=45) cout<<"9"; else cout<<"10"; return 0; }
a.cc: In function 'int main()': a.cc:10:19: error: expected ';' before 'cout' 10 | else if (x<=10 cout<<"4"; | ^~~~~ | ; a.cc:11:5: error: expected primary-expression before 'else' 11 | else if (x<=15) cout<<"5"; | ^~~~ a.cc:10:30: error: expected ')' before 'else' 10 | else if (x<=10 cout<<"4"; | ~ ^ | ) 11 | else if (x<=15) cout<<"5"; | ~~~~
s676821496
p03781
Java
import java.util.Scanner; /** * Created by paz on 17-3-18. */ public class Kangaroo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); long sum = 0; for(int i = 1; ;i++) { sum += i; if(sum >= x) { System.out.print(i); break; } } } }
Main.java:6: error: class Kangaroo is public, should be declared in a file named Kangaroo.java public class Kangaroo { ^ 1 error
s562806020
p03781
C
include <stdio.h> int main(){ int x, l, r; scanf("%d", &x); l = 1; r = x+1; while(l + 1 < r){ int y = (l & r) + (l ^ r) / 2; if((long long) y*(y+1)/2 < x) l = y+1; r = y; } if((long long) l*(l+1)/2 >= x) printf("%d\n", l); else printf("%d\n", l+1); return 0; }
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include <stdio.h> | ^
s654225369
p03781
C++
#include <bits/stdc++.h> .h> using namespace std; #define ll long long ll n,m; ll num[2000000]; int i; int main() { cin>>n; for(i=1;;i++) { m+=i; if(m>=n) { break; } } cout<<min(i,n)<<endl; return 0; }
a.cc:1:3781: warning: extra tokens at end of #include directive 1 | #include <bits/stdc++.h> .h> | ^ a.cc: In function 'int main()': a.cc:17:14: error: no matching function for call to 'min(int&, long long int&)' 17 | } | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:17:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 17 | } | ^ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:17:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 17 | } | ^
s522614335
p03781
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define pb emplace_back #define INF (1e9+1) //#define INF (1LL<<59) #define int ll int main(){ int n; cin>>n; int c=0; for(int i=1;;i++){ c+=i; if(c>=n){ cout<<i<<endl; return 0; } } }
a.cc:11:13: error: '::main' must return 'int' 11 | #define int ll | ^~ a.cc:13:1: note: in expansion of macro 'int' 13 | int main(){ | ^~~
s726802778
p03781
C++
#include<iostream> using namespace std; int main(void) { int X; cin >> X; cout << (int)ceil((-1 + sqrt(1 + 8.0 * X)) / 2) << endl; system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:8:33: error: 'sqrt' was not declared in this scope 8 | cout << (int)ceil((-1 + sqrt(1 + 8.0 * X)) / 2) << endl; | ^~~~ a.cc:8:22: error: 'ceil' was not declared in this scope 8 | cout << (int)ceil((-1 + sqrt(1 + 8.0 * X)) / 2) << endl; | ^~~~
s648845869
p03781
C++
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { final Scanner sc = new Scanner(System.in); final long X = sc.nextLong(); long pow = 0; for(int time = 0; pow < X; time++){ pow += time; if(X <= pow){ System.out.println(time); return; } } } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public int[] nextIntArray(int n) throws IOException { final int[] ret = new int[n]; for(int i = 0; i < n; i++){ ret[i] = this.nextInt(); } return ret; } public long[] nextLongArray(int n) throws IOException { final long[] ret = new long[n]; for(int i = 0; i < n; i++){ ret[i] = this.nextLong(); } return ret; } public void close() throws IOException { br.close(); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.Closeable; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.IOException; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.InputStream; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.io.InputStreamReader; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.Arrays; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: 'import' does not name a type 7 | import java.util.HashSet; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: 'import' does not name a type 8 | import java.util.LinkedList; | ^~~~~~ a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: 'import' does not name a type 9 | import java.util.Scanner; | ^~~~~~ a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:10:1: error: 'import' does not name a type 10 | import java.util.StringTokenizer; | ^~~~~~ a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:11:1: error: 'import' does not name a type 11 | import java.util.TreeMap; | ^~~~~~ a.cc:11:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:13:1: error: expected unqualified-id before 'public' 13 | public class Main { | ^~~~~~
s282398034
p03781
C++
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> #include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <map> #include <set> #include <numeric> #include <unordered_map> #include <unordered_set> #include <complex> #include <iterator> #include <array> #include <memory> //cin.sync_with_stdio(false); //streambuf using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; using vi = vector<int>; using vll = vector<ll>; using vpii = vector<pii>; using vpll = vector<pll>; using ti3 = tuple<int, int, int>; using vti3 = vector<ti3>; template<class T, int s>using va = vector<array<T, s>>; template<class T, class T2> using umap = unordered_map<T, T2>; template<class T> using uset = unordered_set<T>; template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; } template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; } #define ALL(a) a.begin(),a.end() #define rep(i,a) for(int i=0;i<a;i++) #define rep1(i,a) for(int i=1;i<=a;i++) #define rrep(i,a) for(int i=(a)-1;i>=0;i--) #define rrep1(i,a) for(int i=a;i;i--) const ll mod = 1000000007; #define REP rep template<class T>using heap = priority_queue<T, vector<T>, greater<T>>; template<class T>using pque = priority_queue<T, vector<T>, function<T(T, T)>>; template <class T> inline void hash_combine(size_t & seed, const T & v) { hash<T> hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } namespace std { template<typename S, typename T> struct hash<pair<S, T>> { inline size_t operator()(const pair<S, T> & v) const { size_t seed = 0; hash_combine(seed, v.first); hash_combine(seed, v.second); return seed; } }; // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl{ static void apply(size_t& seed, Tuple const& tuple){ HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0>{ static void apply(size_t& seed, Tuple const& tuple){ hash_combine(seed, std::get<0>(tuple)); } }; template <typename ... TT> struct hash<std::tuple<TT...>>{ size_t operator()(std::tuple<TT...> const& tt) const{ size_t seed = 0; HashValueImpl<std::tuple<TT...> >::apply(seed, tt); return seed; } }; } template<class T>int id(vector<T> &a, T b) { return lower_bound(ALL(a), b) - a.begin(); } ll pow(ll base, ll i, ll mod) { ll a = 1; while (i) { if (i & 1) { a *= base; a %= mod; } base *= base; base %= mod; i /= 2; } return a; } ll gcd(ll a, ll b) { while (b) { ll c = a%b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } int popcnt(unsigned long long a) { a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555); a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333); a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f); a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff); a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff); return (a & 0xffffffff) + (a >> 32); } class unionfind { vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う public: unionfind(int n) :par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); } int find(int x) { if (par[x] == x)return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); par[y] = x; size_[x] += size_[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return size_[find(x)]; } }; template<class T, class Func = function<T(T, T)>> class segtree { vector<T> obj; int offset; Func updater; T e; int bufsize(int num) { int i = 1; for (; num >i; i <<= 1); offset = i - 1; return (i << 1) - 1; } T query(int a, int b, int k, int l, int r) { if (r <= a || b <= l)return e; if (a <= 1 && r <= b)return obj[k]; else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r)); } public: T query(int a, int b) {//[a,b) return query(a, b, 0, 0, offset + 1); } void updateall(int l = 0, int r = -1) { if (r < 0)r = offset + 1; l += offset, r += offset; do { l = l - 1 >> 1, r = r - 1 >> 1; for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]); } while (r) } void update(int k, T &a) { k += offset; obj[k] = a; while (k) { k = k - 1 >> 1; obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]); } } segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {} segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) { copy(vec.begin(), vec.end(), obj.begin() + offset); updateall(); } typename vector<T>::reference operator[](int n) { return obj[n + offset]; } }; template<class T = int> class BIT {//多次元BITはループをネストすればいいらしい。 vector<T> bit; int n; public: BIT(int n) :obj(n + 1, 0) {} void add(int i, T x) { i++; while (i <= n) { bit[i] += x; i += i&-i; } } T sum(int i) { T s = 0; i++; while (i) { s += bit[i]; i &= i - 1; } return s; } }; template<class T = int> class rangeadd { BIT<T> b0, b1; public: rangeadd(int n) :b0(n), b1(n) {}; void add(int l, int r, T x) {//[l,r) b0.add(l, -x*(l - 1)); b1.add(l, x); b0.add(r, x*r); b1.add(r, -x); } T sum(int i) { if (i < 0)return 0; return b0.sum(i) + b1.sum(i)*i; } T sum(int l,int r) { return sum(r - 1) - sum(l - 1); } }; //end of lib //template<class S=void,int ptr_num, class T = char>class trie { // umap<T, trie<S, ptr_num, T> next; //public: // S key; // trie<S, ptr_num, T>* ptr[ptr_num] = {}; // trie(S &&data) :key(data) {} // trie(const S &data) :key(data) {} // void add(T x,S data) { // if (!next.find(x))next.insert(x, data); // } // trie& operator[](T x) { // return next[x]; // } // bool find(T x) { // retun next.find(x); // } //}; //template<class T=char>class AhoCorasick { // trie<pair<bool,int>, 2, T> tree; // AhoCorasick(vector<string> p) { // int num = 0; // vector<decltype(&tree)> que(p.size(),&tree); // for (int i = 0;; i++) { // bool end = 1; // int i = 0; // for (auto a : p) { // if (i >= a.size())break; // end = ;0 // que[i] = (*que[i])[a[i]]; // i++; // } // if (end)break; // } // } //}; int main() { int x; cin >> x; int i = 0; for (; x > 0; x -= i)i++; cout << i << endl; }
a.cc: In member function 'void segtree<T, Func>::updateall(int, int)': a.cc:174:9: error: expected ';' before '}' token 174 | } | ^ a.cc: In constructor 'BIT<T>::BIT(int)': a.cc:197:21: error: class 'BIT<T>' does not have any field named 'obj' 197 | BIT(int n) :obj(n + 1, 0) {} | ^~~
s974643264
p03781
C
#!/usr/bin/env python3 x = int(input()) S = {0} i = 0 while x not in S: i += 1 S = S | {s - i for s in S} | {s + i for s in S} print(i)
main.c:1:2: error: invalid preprocessing directive #! 1 | #!/usr/bin/env python3 | ^ main.c:3:1: warning: data definition has no type or storage class 3 | x = int(input()) | ^ main.c:3:1: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] main.c:3:5: error: expected expression before 'int' 3 | x = int(input()) | ^~~ main.c:5:1: warning: data definition has no type or storage class 5 | i = 0 | ^ main.c:5:1: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] main.c:6:1: error: expected ',' or ';' before 'while' 6 | while x not in S: | ^~~~~ main.c:8:32: error: expected identifier or '(' before '|' token 8 | S = S | {s - i for s in S} | {s + i for s in S} | ^ main.c:9:1: error: return type defaults to 'int' [-Wimplicit-int] 9 | print(i) | ^~~~~ main.c: In function 'print': main.c:9:1: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:10: error: expected '{' at end of input
s493560082
p03781
C++
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void run() { int x = sc.nextInt(); long c = 0; long cnt = 0; for (int i = 1;; i++) { if(c >= x) break; cnt++; c += i; } System.out.println(cnt); } public static void main(String[] args) { new Main().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(int[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } boolean inner(int h, int w, int limH, int limW) { return 0 <= h && h < limH && 0 <= w && w < limW; } void swap(char[] x, int a, int b) { char tmp = x[a]; x[a] = x[b]; x[b] = tmp; } // find minimum i (k <= a[i]) int lower_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k <= a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } // find minimum i (k < a[i]) int upper_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k < a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } boolean palindrome(String s) { for (int i = 0; i < s.length() / 2; i++) { if (s.charAt(i) != s.charAt(s.length() - 1 - i)) { return false; } } return true; } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } int[] nextIntArray(int n) { int[] in = new int[n]; for (int i = 0; i < n; i++) { in[i] = nextInt(); } return in; } int[][] nextInt2dArray(int n, int m) { int[][] in = new int[n][m]; for (int i = 0; i < n; i++) { in[i] = nextIntArray(m); } return in; } double[] nextDoubleArray(int n) { double[] in = new double[n]; for (int i = 0; i < n; i++) { in[i] = nextDouble(); } return in; } long[] nextLongArray(int n) { long[] in = new long[n]; for (int i = 0; i < n; i++) { in[i] = nextLong(); } return in; } char[][] nextCharField(int n, int m) { char[][] in = new char[n][m]; for (int i = 0; i < n; i++) { String s = sc.next(); for (int j = 0; j < m; j++) { in[i][j] = s.charAt(j); } } return in; } } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Arrays; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Scanner; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s588943403
p03782
C++
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <cstdio> #include <bitset> #include <queue> #include <deque> #include <algorithm> #include <numeric> #include <cassert> #include <functional> #include <stack> #include <cmath> #include <string> #include <complex> using namespace std; #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() #define INF (1 << 30) #define LLINF (1LL << 62) #define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__) constexpr int MOD = 1000000007; using ll = long long; using Pii = pair<int, int>; using Pll = pair<ll, ll>; inline int popcount(ll x) { return __builtin_popcountll(x); } inline int div2num(ll x) { return __builtin_ctzll(x); } inline bool bit(ll x, int b) { return (x >> b) & 1; } template <class T> string to_string(T s); template <class S, class T> string to_string(pair<S, T> p); string to_string(string s) { return s; } string to_string(const char s[]) { return to_string(string(s)); } template <class T> string to_string(T v) { if (v.empty()) return "{}"; string ret = "{"; for (auto x : v) ret += to_string(x) + ","; ret.back() = '}'; return ret; } template <class S, class T> string to_string(pair<S, T> p) { return "{" + to_string(p.first) + ":" + to_string(p.second) + "}"; } void debug() { cerr << endl; } template <class Head, class... Tail> void debug(Head head, Tail... tail) { cerr << to_string(head) << " "; debug(tail...); } struct IO { #ifdef _WIN32 inline char getchar_unlocked() { return getchar(); } inline void putchar_unlocked(char c) { putchar(c); } #endif std::string separator = " "; template <class T> inline void read(T &x) { char c; do { c = getchar_unlocked(); } while (c != '-' && (c < '0' || '9' < c)); bool minus = 0; if (c == '-') { minus = 1; c = getchar_unlocked(); } x = 0; while ('0' <= c && c <= '9') { x *= 10; x += c - '0'; c = getchar_unlocked(); } if (minus) x = -x; } inline void read(std::string &x) { char c; do { c = getchar_unlocked(); } while (c == ' ' || c == '\n'); x.clear(); do { x += c; c = getchar_unlocked(); } while (c != ' ' && c != '\n' && c != EOF); } template <class T> inline void read(std::vector<T> &v) { for (auto &x : v) read(x); } template <class S, class T> inline void read(std::pair<S, T> &p) { read(p.first); read(p.second); } template <class Head, class... Tail> inline void read(Head &head, Tail &... tail) { read(head); read(tail...); } template <class T> inline void write(T x) { char buf[32]; int p = 0; if (x < 0) { x = -x; putchar_unlocked('-'); } if (x == 0) putchar_unlocked('0'); while (x > 0) { buf[p++] = (x % 10) + '0'; x /= 10; } while (p) { putchar_unlocked(buf[--p]); } } inline void write(std::string x) { for (char c : x) putchar_unlocked(c); } inline void write(const char s[]) { for (int i = 0; s[i] != 0; ++i) putchar_unlocked(s[i]); } template <class T> inline void write(std::vector<T> v) { if (v.empty()) return; for (auto itr = v.begin(); itr + 1 != v.end(); ++itr) { write(*itr); write(separator); } write(v.back()); } template <class Head, class... Tail> inline void write(Head head, Tail... tail) { write(head); write(separator); write(tail...); } template <class Head, class... Tail> inline void writeln(Head head, Tail... tail) { write(head, tail...); write("\n"); } void set_separator(std::string s) { separator = s; } } io; struct Prime { int n; vector<int> table; vector<int> primes; Prime(int _n = 100000) { n = _n + 1; table.resize(n, -1); table[0] = 0; table[1] = -1; for (int i = 2; i * i < n; ++i) { if (table[i] == -1) { for (int j = i * i; j < n; j += i) { table[j] = i; } } } } void enumerate_primes() { primes.clear(); for (int i = 2; i < n; ++i) { if (table[i] == -1) primes.push_back(i); } } vector<pair<long long, int>> prime_factor(long long x) { map<long long, int> mp; long long div = 2; int p = 0; while (n <= x && div * div <= x) { if (x % div == 0) { mp[div]++; x /= div; } else { if (p + 1 < primes.size()) { div = primes[++p]; } else { div++; } } } if (x < n) { while (table[x] != -1) { mp[table[x]]++; x /= table[x]; } } if (x > 1) mp[x]++; vector<pair<long long, int>> ret; for (auto p : mp) ret.push_back(p); return ret; } }; template <int MOD = 1000000007> struct Math { vector<long long> fact, factinv, inv; Math(int n = 100000) { fact.resize(n + 1); factinv.resize(n + 1); inv.resize(n + 1); fact[0] = fact[1] = 1; factinv[0] = factinv[1] = 1; inv[1] = 1; for (int i = 2; i <= n; ++i) { fact[i] = fact[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; factinv[i] = factinv[i - 1] * inv[i] % MOD; } } long long C(int n, int r) { if (n < r || n < 0 || r < 0) { return 0; } else { return fact[n] * (factinv[r] * factinv[n - r] % MOD) % MOD; } } long long P(int n, int r) { if (n < r || n < 0 || r < 0) { return 0; } else { return fact[n] * factinv[n - r] % MOD; } } long long H(int n, int r) { return C(n + r - 1, r); } }; struct UnionFind { vector<int> data; vector<vector<int>> groups; UnionFind(int n) : data(n, -1) {} int root(int v) { return data[v] < 0 ? v : data[v] = root(data[v]); } bool unite(int u, int v) { if ((u = root(u)) == (v = root(v))) { return 1; } else { if (-data[u] < -data[v]) swap(u, v); data[u] += data[v]; data[v] = u; return 0; } } int size(int v) { return -data[root(v)]; } void make_groups() { map<int, vector<int>> mp; for (int i = 0; i < data.size(); ++i) mp[root(i)].push_back(i); groups.clear(); for (auto p : mp) groups.push_back(p.second); } }; namespace phc { long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } long long modinv(long long a) { long long b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MOD; if (u < 0) u += MOD; return u; } long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } } // namespace phc template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; constexpr int dy[4] = {-1, 0, 1, 0}, dx[4] = {0, -1, 0, 1}; int main() { int N, K; io.read(N, K); vector<ll> a(N); io.read(a); vector<bitset<5000>> cuml(N + 1), cumr(N + 1); cuml[0][0] = 1; REP(i, N) { cuml[i + 1] = cuml[i]; for (int j = 0; j < K - a[i]; ++j) if (cuml[i][j]) cuml[i + 1][j + a[i]] = 1; } cumr[N][0] = 1; for (int i = N - 1; i >= 0; --i) { cumr[i] = cumr[i + 1]; for (int j = 0; j < K - a[i]; ++j) if (cumr[i + 1][j]) cumr[i][j + a[i]] = 1; } int ans = N; REP(i, N) { int t = 0; vector<ll> cum(K + 1); REP(j, K) { cum[j + 1] = cum[j]; if (cumr[i + 1][j]) cum[j + 1]++; } REP(j, K) if (cuml[i][j]) { int l = max(0, K - a[i] - j); int r = max(0, K - j); if (cum[r] - cum[l] > 0) t = 1; } if (t) ans--; } io.writeln(ans); return 0; }
a.cc: In function 'int main()': a.cc:403:18: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 403 | int l = max(0, K - a[i] - j); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:403:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 403 | int l = max(0, K - a[i] - j); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:11: /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:403:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 403 | int l = max(0, K - a[i] - j); | ~~~^~~~~~~~~~~~~~~~~
s683950992
p03782
C++
#include<iostream> #include<math.h> #include<algorithm> #include<queue> #include<vector> #include<map> #include<set> #include<deque> using namespace std; int a[5000]; int bubuwa(int t);//tを省いた中で、部分和がk-a[t]以上k未満になるかどうか int n, k; bool dp[5001][5001]; int main() { //B cin >> n >> k; int i; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int left, right, mid; left = -1; right = n; mid = (left + right) / 2; while (right - left > 1) { if (bubuwa(mid) == 1) { right = mid; } else { left = mid; } mid = (right + left) / 2; } cout << right << endl; return 0; //ある値が必要であれば、それ以上もすべて必要である。従って二分探索を //用いて、最初に必要となる数を求める。必要かどうかの判定は部分和問題 //である。その数を省いた数列から部分和を取って、k未満かつその数があ //ればk以上となるような値となるかを調べる //A /*int x; cin >> x; int i; for (i = 0; i <= x; i++) { if (((i * (i - 1)) / 2 < x) && (x <= (i * (i + 1)) / 2)) { cout << i << endl; return 0; } } return 0; */ } int bubuwa(int t) { int i, j; memset(dp, 0, sizeof(dp)); dp[0][0] = true; for (i = 0; i < n; i++) { //if (i != t) { for (j = 0; j <= k; j++) { dp[i + 1][j] |= dp[i][j]; if (j >= a[i] && i != t)dp[i + 1][j] |= dp[i][j - a[i]]; } //} } for (i = k - a[t]; i < k; i++) { if (dp[n][i] == true) { return 1; } } return 0; }
a.cc: In function 'int bubuwa(int)': a.cc:79:9: error: 'memset' was not declared in this scope 79 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<set> +++ |+#include <cstring> 8 | #include<deque>
s334433958
p03782
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> P; ll Mod = 1000000007; bool R1[5021][5021]; bool R2[5021][5021]; int main() { ll N,K; cin >> N >> K; ll a[N]; for (int i = 0; i < N; i++) { cin >> a[i]; } ll ans = 0; R1[0][0] = true; if (a[0] <= K) R1[0][a[0]] = true; for (ll i = 1; i < N; i++) { for (ll j = 0; j <= K; j++) { R1[i][j] = R1[i-1][j]; if (0 <= j-a[i] && j-a[i] <= K) { if (R1[i-1][j-a[i]]) { R1[i][j] = true; } } } } R2[N-1][0] = true; if (a[N-1] <= K) R2[N-1][a[N-1]] = true; for (ll i = N-2; i >= 0; i--) { for (ll j = 0; j <= K; j++) { R2[i][j] = R2[i+1][j]; if (0 <= j-a[i] && j-a[i] <= K) { if (R2[i+1][j-a[i]]) { R2[i][j] = true; } } } } // R1[i][j]はi番目までにjぴったりが作れるか R2[i][j]は逆順 // i = 0,N-1の時は例外処理 for (ll i = 1; i < N-1; i++) { if (a[i] >= K) { continue; } ll Can[K - a[i] + 1]; for (ll j = 0; j < K - a[i] + 1; j++) { Can[j] = 0; } for (ll j = 0; j < a[i]; j++) { if (R1[i-1][j]) { Can[0]++; } } for (ll j = 1; j < K - a[i] + 1; j++) { Can[j] = Can[j-1]; if (R1[i-1][j+a[i]-1]) Can[j]++; if (R1[i-1][j-1]) Can[j]--; } bool need = false; for (ll j = 0; j < K - a[i] + 1; j++) { if (Can[j] != 0 && R2[i+1][K-a[i]-j]) { need = true; } } if (!need) { ans++; } } if (a[0] < K) { bool need = false; for (ll i = K-a[0]; i < K; i++) { if (R2[1][i]) { need = true; } } if (!need) { ans++; } } if (a[N-1] < K) { bool need = false; for (ll i = K-a[N-1]; i < K; i++) { if (R1[N-2][i]) { need = true; } } if (!need) { ans++; } } if (n == 3) { ans--; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:93:7: error: 'n' was not declared in this scope 93 | if (n == 3) { | ^
s178586198
p03782
C++
#include<bits/stdc++.h> using namespace std; const int N=1001; int n,k,sum; int a[N],dp[N][N]; bool check(int x) { memset(dp,0,sizeof(dp)); if(x==1) { dp[2][0]=1; dp[2][a[2]]=1; for(int i=3;i<=n;i++) { for(int j=0;j<=k;j++) { dp[i][j]=dp[i-1][j]; if(j>=a[i]) dp[i][j]=dp[i-1][j]|dp[i-1][j-a[i]]; } } } else { dp[1][0]=1; dp[1][a[1]]=1; for(int i=2;i<=n;i++) { if(x==i) { for(int j=0;j<=k;j++) dp[i][j]=dp[i-1][j]; continue; } for(int j=0;j<=k;j++) { dp[i][j]=dp[i-1][j]; if(j>=a[i]) dp[i][j]=dp[i-1][j]||dp[i-1][j-a[i]]; } } } /* printf("x:%d\n",x); for(int i=1;i<=n;i++) { for(int j=0;j<=k;j++) printf("%d ",dp[i][j]); printf("\n"); } */ for(int i=k-a[x];i<k;i++) if(dp[n][i]) return true; return false; } int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); a[i]=min(a[i],k); } if(n==1) { if(a[1]>=k) printf("0\n"); else printf("1\n"); return 0; } sort(a+1,a+n+1); int lb=0,ub=n+1; while(lb+1<ub) { int mid=(lb+ub)/2; if(check(mid)) ub=mid; else lb=mid; } printf("%d\n",lb);sdgdsgdsg return 0; } gsgsdgsdgsdgdsgdsgdsgsdgsd
a.cc: In function 'int main()': a.cc:83:23: error: 'sdgdsgdsg' was not declared in this scope 83 | printf("%d\n",lb);sdgdsgdsg | ^~~~~~~~~ a.cc: At global scope: a.cc:86:1: error: 'gsgsdgsdgsdgdsgdsgdsgsdgsd' does not name a type 86 | gsgsdgsdgsdgdsgdsgdsgsdgsd | ^~~~~~~~~~~~~~~~~~~~~~~~~~
s781421139
p03782
C++
#include <bits/stdc++.h> using namespace std; int a[5050],b[5050],ans; bool f[5050]={true}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,k; cin>>n>>k; cin>>a[0]; b[0]=a[0]; for(int i=1;i<n;i++) { cin>>a[i]; b[i]=b[i-1]+a[i]; } for(int i=0;i<n/2;i++) { for(int j=n;j>n/2;j--) { if(b[j]-a[i]>=k) { for(int k=0;k<i-1;k++) { f[k]=false; } for(int k=j;k<n;k++) { f[k]=false; } } } } for(int i=0;i<n;i++) { if(f==true) { ans++; } } cout<<ans; }
a.cc: In function 'int main()': a.cc:37:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 37 | if(f==true) | ~^~~~~~
s793303180
p03782
C++
#include <bits/stdc++.h> #define f first #define s second using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; ll a[5005], dp[5005] = { 0 }; int main() { ll N, K; cin >> N >> K; for (int i = 0; i < N; ++i) { cin >> a[i]; a[i] = min(K, a[i]); } dp[0] = 1; for (int i = 0; i < N; ++i) { for (int j = K - a[i] - 1; j >= 0; --j) { dp[j + a[i]] += dp[j]; dp[j + a[i]] %= 1e16; } for (int j = 0; j < K; ++j) assert(dp[j] >= 0); ll ans = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < K - a[i]; ++j) { dp[j + a[i]] -= dp[j]; dp[j + a[i]] = (dp[j + a[i]] + 1e16) % 1e16; } //for (int j = 0; j < K; ++j) assert(dp[j] >= 0); ll cnt = 0; for (int j = K - a[i]; j < K; ++j) { cnt += dp[j]; cnt %= 1e16; } if (cnt == 0) ++ans; for (int j = K - a[i] - 1; j >= 0; --j) { dp[j + a[i]] += dp[j]; dp[j + a[i]] %= 1e16; } } cout << ans << '\n'; }
a.cc: In function 'int main()': a.cc:23:24: error: invalid operands of types 'll' {aka 'long long int'} and 'double' to binary 'operator%' 23 | dp[j + a[i]] %= 1e16; | ~~~~~~~~~~~~~^~~~~~~ a.cc:23:24: note: in evaluation of 'operator%=(ll {aka long long int}, double)' a.cc:30:48: error: invalid operands of types 'double' and 'double' to binary 'operator%' 30 | dp[j + a[i]] = (dp[j + a[i]] + 1e16) % 1e16; | ~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~ | | | | double double a.cc:36:15: error: invalid operands of types 'll' {aka 'long long int'} and 'double' to binary 'operator%' 36 | cnt %= 1e16; | ~~~~^~~~~~~ a.cc:36:15: note: in evaluation of 'operator%=(ll {aka long long int}, double)' a.cc:41:24: error: invalid operands of types 'll' {aka 'long long int'} and 'double' to binary 'operator%' 41 | dp[j + a[i]] %= 1e16; | ~~~~~~~~~~~~~^~~~~~~ a.cc:41:24: note: in evaluation of 'operator%=(ll {aka long long int}, double)' a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:12:12: note: to match this '{' 12 | int main() { | ^
s050059193
p03782
C++
//khodaya khodet komak kon #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define all(x) x.begin(), x.end() #pragma GCC optimise ("ofast") #pragma GCC optimise("unroll-loops") using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 200000 + 10; const ll MOD = 1000000000 + 7; const ll INF = 1000000000000000000; const ll LOG = 25; int n, k, a[N]; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); int ans = 0; for (int i = 1; i <= n; i++){ int sm = a[i]; for (int j = 1; j <= n; j++){ if (j == i) continue; sm += a[j]; if (sm >= k){ if (sm - a[i] >= k) cnt++; break; } } if (sm < k) } cout << cnt; return 0; }
a.cc: In function 'int32_t main()': a.cc:36:53: error: 'cnt' was not declared in this scope; did you mean 'int'? 36 | if (sm - a[i] >= k) cnt++; | ^~~ | int a.cc:41:9: error: expected primary-expression before '}' token 41 | } | ^ a.cc:42:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 42 | cout << cnt; | ^~~ | int
s467162278
p03782
C++
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define MOD 1000000007 using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } //コーナーケース if(n == 1) { cout << (a[i] < k) << endl; return 0; } if(n == 2) { int ans = 0; if(a[1] >= k) { ans++; } if(a[0] >= k) { ans++; } cout << ans << endl; return 0; } vector<vector<bool>> dpf(n + 2, vector<bool>(5002, false)); vector<vector<bool>> dpb(n + 2, vector<bool>(5002, false)); dpf[0][0] = true; for(int i = 1; i <= n; i++) { for(int j = 0; j < 5002; j++) { dpf[i][j] = dpf[i - 1][j]; if(j - a[i - 1] >= 0 && dpf[i - 1][j - a[i - 1]]) { dpf[i][j] = true; } } } dpb[n + 1][0] = true; for(int i = n; i >= 1; i--) { for(int j = 0; j < 5002; j++) { dpb[i][j] = dpb[i + 1][j]; if(j - a[i - 1] >= 0 && dpb[i + 1][j - a[i - 1]]) { dpb[i][j] = true; } } } vector<vector<int>> front(n + 2), back(n + 2); for(int i = 1; i <= n; i++) { for(int k = 0; k < 5002; k++) { if(dpf[i][k]) { front[i].push_back(k); } if(dpb[i][k]) { back[i].push_back(k); } } } int ans = 0; // 1番目が必要かどうか auto itr = lower_bound(all(back[2]), k - a[0]); if(itr != back[2].end() && *itr < k) { ans++; } // n番目が必要かどうか itr = lower_bound(all(front[n - 1]), k - a[n - 1]); if(itr != front[n - 1].end() && *itr < k) { ans++; } for(int i = 2; i < n; i++) { int tmp = 0; for(auto x : front[i - 1]) { auto itr2 = lower_bound(all(back[i + 1]), k - a[i - 1] - x); if(itr2 != back[i + 1].end() && *itr2 < k - x) { tmp = 1; } } ans += tmp; } cout << n - ans << endl; }
a.cc: In function 'int main()': a.cc:15:20: error: 'i' was not declared in this scope 15 | cout << (a[i] < k) << endl; | ^
s805499951
p03782
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 6e3; const int MAXK = 6e3; int N, K; ll A[MAXN]; ll pref[MAXN]; bool canReach[MAXK]; int main() { cin >> N >> K; for (int i = 0; i < N; i++) cin >> A[i]; sort(A, A + N); pref[0] = 0; for (int i = 0; i < N; i++) pref[i+1] = pref[i] + A[i]; int bestReach = 0; canReach[0] = 1; int ans = 0; for (int i = N-1; i >= 0; i--) { if (bestReach + pref[i+1] < K) { ans++; } for (int v = K-1-A[i]; v >= 0; v--) { if (canReach[v]) { canReach[A[i]+v] = true; bestReach = max(bestReach, A[i]+v); } } } cout << ans << '\n'; }
a.cc: In function 'int main()': a.cc:30:24: error: no matching function for call to 'max(int&, ll)' 30 | bestReach = max(bestReach, A[i]+v); | ~~~^~~~~~~~~~~~~~~~~~~ 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:30:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 30 | bestReach = max(bestReach, A[i]+v); | ~~~^~~~~~~~~~~~~~~~~~~ /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:30:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 30 | bestReach = max(bestReach, A[i]+v); | ~~~^~~~~~~~~~~~~~~~~~~
s984890656
p03782
C++
// #pragma GCC optimize("Ofast") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define DECIMAL(n) std::cout << std::fixed;std::cout << std::setprecision(n); #define hell 1000000007 #define narak 998244353 #define PI 3.14159265358979323844 #define mp make_pair #define eb emplace_back #define pb push_back #define fi first #define se second #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define REVERSE(v) reverse(ALL(v)) #define endl "\n" #define maxc(v) *max_element(ALL(v)) #define minc(v) *min_element(ALL(v)) #define sqr(a) (a)*(a) #define GCD(m,n) __gcd(m,n) #define LCM(m,n) m*(n/GCD(m,n)) #define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>(a)[xxx] #define rep(i, n) for(int i = 0; i < (n); ++i) #define repA(i, a, n) for(int i = a; i <= (n); ++i) #define repD(i, a, n) for(int i = a; i >= (n); --i) #define trav(a, x) for(auto& a : x) #define sz(a) (int)a.size() #define sl(a) (int)a.length() #define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands} #define inset(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.insert(tmp);commands} #define display(x) trav(a,x) cout<<a<<" ";cout<<endl #define debug cerr<<"bhau"<<endl #define between(n,a,b) (a<=n&&n<=b) #define clamp(n,a,b) (((n)<(a))?(a):(((n)>(b))?(b):(n))) #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1){ std::cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); } #define elasped_time 1.0 * clock() / CLOCKS_PER_SEC template<typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template<typename T, typename U> static inline void amax(T &x, U y) { if (x < y) x = y; } std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count()); #define ll long long #define ld long double #define pii std::pair<int, int> #define pll std::pair<ll, ll> #define vi vector<int> #define vvi vector<vi > #define vii vector<pii > #define point complex<ll> #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> /*----------------------Graph Moves----------------*/ //const int fx[]={+1,-1,+0,+0}; //const int fy[]={+0,+0,+1,-1}; //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move /*------------------------------------------------*/ //primes for hashing 937,991,1013,1409,1741 std::ostream& operator<<(std::ostream& out,pii a) { out<<a.fi<<" "<<a.se; return out; } std::ostream& operator<<(std::ostream& out,pll a) { out<<a.fi<<" "<<a.se; return out; } std::istream& operator>>(std::istream& in,pii &a) { in>>a.fi>>a.se; return in; } std::istream& operator>>(std::istream& in,pll &a) { in>>a.fi>>a.se; return in; } using namespace std; using namespace __gnu_pbds; void meowmeow321() { int n; cin>>n; int k; cin>>k; int cnt=0; vi a; for (int i = 0; i < n; ++i) { int x; cin>>x; if(x>=k){ }else{ a.pb(x); } } n=sz(a); for (int i = 0; i < n; ++i) { bitset<5000> pos(1); for (int j = 0; j < n; ++j) { if(j!=i){ pos|=(pos<<a[j]); } } // bool flag=0; // for (int j = k-a[i]; j <k; ++j) { // flag|=pos[j]; // } if(!flag)cnt++; } cout<<cnt<<endl; } int main() { FAST; int testcases=1; //cin>>testcases; for(int i=0;i<testcases;++i) { meowmeow321(); } cerr<<endl<<"Time Elasped : "<<elasped_time<<endl; return 0; }
a.cc: In function 'void meowmeow321()': a.cc:139:13: error: 'flag' was not declared in this scope 139 | if(!flag)cnt++; | ^~~~
s422962198
p03782
C++
#include <bits/stdc++.h> #define f first #define s second using namespace std; const int N = 5005; int dp[N][N], n, k, a[N], tmp, x, z[N]; int sol(int i, int cur) { if(!i || a[i-1] < x) return cur; int &ret = dp[i][cur]; if(ret != -1) return ret; ret = sol(i-1, cur); if(cur + a[i] < k) return max(ret, sol(i-1, cur+a[i])); return ret; } bool check(int i) { x = a[i]; if(z[x] != -1) return z[x]; if(x >= k) return z[x] = 1; memset(dp, -1, sizeof dp); if(sol(n-1, 0) >= k-x) return z[x] = 1; return z[x] = retur0; } int main() { memset(z, -1, sizeof z); cin >> n >> k; for(int i=0; i<n; i++) scanf("%d", &a[i]); sort(a, a+n); while(a[n-1] >= k) n--; int s = 0, e = n-1; while(s <= e) { int mid = (s+e)>>1; if(check(mid)) e = mid-1; else s = mid+1; } cout << s << endl; }
a.cc: In function 'bool check(int)': a.cc:23:23: error: 'retur0' was not declared in this scope 23 | return z[x] = retur0; | ^~~~~~