submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s626865012
p03721
C++
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <set> using namespace std; ll N,K; ll num[100001]; int main(){ cin >> N >> K; set<int> s; for(int i=0;i<N;i++){ int a,b; cin >> a >> b; s.insert(a); num[a]+=b; } for(set<int> ::iterator itr = s.begin();itr!=s.end();itr++){ ll n=num[*itr]; if(K<=n){ cout << *itr << endl; return 0; } else K-=n; } return 0; }
a.cc:7:1: error: 'll' does not name a type 7 | ll N,K; | ^~ a.cc:8:1: error: 'll' does not name a type 8 | ll num[100001]; | ^~ a.cc: In function 'int main()': a.cc:10:10: error: 'N' was not declared in this scope 10 | cin >> N >> K; | ^ a.cc:10:15: error: 'K' was not declared in this scope 10 | cin >> N >> K; | ^ a.cc:16:5: error: 'num' was not declared in this scope; did you mean 'enum'? 16 | num[a]+=b; | ^~~ | enum a.cc:19:5: error: 'll' was not declared in this scope 19 | ll n=num[*itr]; | ^~ a.cc:20:11: error: 'n' was not declared in this scope 20 | if(K<=n){ | ^
s522887631
p03721
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; int main() { int N,K; cin >> N >> K; int a[N], b[N]; for(int i = 0; i < N; i++) { cin >> a[i] >> b[i]; } vector<pair<int,int> > v; for(int i = 0; i < N; i++) { v.push_back(pair<int,int>(a[i],b[i])); } sort(v.begin(), v.end()); long long sum = 0; long long ans = 0; for(int i = 0; i < N; i++) { sum += v[i].second; if(sum >= K) { ans = v[i].first; break; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:29:2: error: expected '}' at end of input 29 | } | ^ a.cc:7:12: note: to match this '{' 7 | int main() { | ^
s434694847
p03721
C++
#include <iostream> using namespace std; long long int cnt[100002]; int main(){ int N, K; cin>>N>>K; int number, pcs; for(int i = 0; i < N; i++){ cin>>number>>pcs; if(cnt[number] != 0){ cnt[number] += pcs; }else{ cnt[number] = pcs; } } unsigned long long int index = 0; for (int i = 0; i < 100000; i++){ index += cnt[array[i]] ; if(index >= K){ cout<<array[i]<<endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:24:23: error: missing template arguments before '[' token 24 | index += cnt[array[i]] ; | ^ a.cc:26:18: error: missing template arguments before '[' token 26 | cout<<array[i]<<endl; | ^
s964202029
p03721
C
#include <stdio.h> #include <stdlib.h> typedef struct SArray { int num; int quant; SArray* next; } SArray; SArray* GetAdd(SArray* arr, int a); void PutNode(SArray* arr, int a, int b); void FreeArr(SArray* arr); int main(void) { int n, k, i, a, b, temp; scanf("%d %d", &n, &k); SArray* arr = (SArray*)malloc(sizeof(SArray)); SArray* asTemp; arr->num = 0; arr->quant = 0; arr->next = NULL; for (i = 0; i < n; i++) { scanf("%d %d", &a, &b); asTemp = GetAdd(arr, a); if(asTemp != NULL) { asTemp->quant += b; } else { PutNode(arr, a, b); } } temp = 0; asTemp = arr->next; while (1) { temp += asTemp->quant; if (k <= temp) { printf("%d", asTemp->num); break; } asTemp = asTemp->next; } FreeArr(arr); return 0; } SArray* GetAdd(SArray* arr, int a) { SArray* asTemp = arr; while(asTemp->next != NULL) { if (asTemp->next->num == a) { return asTemp->next; } asTemp = asTemp->next; } return NULL; } void PutNode(SArray* arr, int a, int b) { SArray* asTemp = arr; SArray* asPut; while (asTemp->next != NULL) { if(asTemp->next->num > a) { asPut = (SArray*)malloc(sizeof(SArray)); asPut->num = a; asPut->quant = b; asPut->next = asTemp->next; asTemp->next = asPut; return; } asTemp = asTemp->next; } asPut = (SArray*)malloc(sizeof(SArray)); asPut->num = a; asPut->quant = b; asPut->next = NULL; asTemp->next = asPut; } void FreeArr(SArray* arr) { SArray* asTemp = arr; SArray* asFree; while(asTemp->next != NULL) { asFree = asTemp; asTemp = asTemp->next; free(asFree); } free(asTemp); }
main.c:7:2: error: unknown type name 'SArray' 7 | SArray* next; | ^~~~~~ main.c: In function 'main': main.c:37:9: error: assignment to 'SArray *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 37 | asTemp = arr->next; | ^ main.c:44:10: error: assignment to 'SArray *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 44 | asTemp = asTemp->next; | ^ main.c: In function 'GetAdd': main.c:54:19: error: request for member 'num' in something not a structure or union 54 | if (asTemp->next->num == a) { | ^~ main.c:55:17: error: returning 'int *' from a function with incompatible return type 'SArray *' [-Wincompatible-pointer-types] 55 | return asTemp->next; | ~~~~~~^~~~~~ main.c:57:10: error: assignment to 'SArray *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 57 | asTemp = asTemp->next; | ^ main.c: In function 'PutNode': main.c:66:18: error: request for member 'num' in something not a structure or union 66 | if(asTemp->next->num > a) { | ^~ main.c:71:17: error: assignment to 'int *' from incompatible pointer type 'SArray *' [-Wincompatible-pointer-types] 71 | asTemp->next = asPut; | ^ main.c:74:10: error: assignment to 'SArray *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 74 | asTemp = asTemp->next; | ^ main.c:80:15: error: assignment to 'int *' from incompatible pointer type 'SArray *' [-Wincompatible-pointer-types] 80 | asTemp->next = asPut; | ^ main.c: In function 'FreeArr': main.c:88:10: error: assignment to 'SArray *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 88 | asTemp = asTemp->next; | ^
s253273078
p03721
C++
// bigArray.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int a, b; long long array[100000] = { 0 }; for (int i = 0; i < n; i++) { cin >> a >> b; array[a - 1] += b; } for (int i = 0; i < 100000; i++) { k -= array[i]; if (k <= 0) { cout << i + 1 << "\n"; break; } } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s978897696
p03721
C++
// bigArray.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int a, b; int array[100000] = { 0 }; for (int i = 0; i < n; i++) { cin >> a >> b; array[a - 1] += b; } for (int i = 0; i < 100000; i++) { k -= array[i]; if (k <= 0) { cout << i + 1 << "\n"; break; } } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s623174343
p03721
C++
import java.util.Scanner; import java.util.Arrays; import java.util.TreeMap; import java.util.Iterator; public class Main{ static long n; static long k; TreeMap<long, long> map = new TreeMap<long, long>(); Main(){ Scanner cin = new Scanner(System.in); this.n = cin.nextLong(); this.k = cin.nextLong(); for (int i = 0; i < n; i++) { long long a = cin.nextLong(); long long b = cin.nextLong(); if (map.containsKey(a)) { map.put(a, map.get(a) + b); } else { map.put(a, b); } } } public static void main() { long cur_i = 0; for(long key : map.keySet()) { cur_i += map.get(key); if(cur_i >= k){ System.out.println(key); return; } } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.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.TreeMap; | ^~~~~~ 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.util.Iterator; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: expected unqualified-id before 'public' 7 | public class Main{ | ^~~~~~
s716027235
p03721
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; long long K; cin >> N >> K; vector< pair<int, int> > v(N); for (int i = 0; i < N; ++i) { int a,b; cin >> a >> b; v[i] = pair<int, int>(a,b); } sort(v.begin(), v.end()); //for (int i = 0; i < N; ++i) { // cout << "(" << v[i].first << ", " << v[i].second << ")" << endl; //} long long k = 0; for (int i = 0; i < N; ++i) { k += v[i].second; if (k >= K) { cout << v[i].first << endl; break; } } }
a.cc: In function 'int main()': a.cc:20:9: error: 'sort' was not declared in this scope; did you mean 'short'? 20 | sort(v.begin(), v.end()); | ^~~~ | short
s260287401
p03721
C
#include <stdio.h> int main() { int n,k; const int max=10001; scanf("%d%d",&n,&k); int num[max]={0}; int a,b; for(int i=0;i<n;i++) { scanf("%d%d",&a,&b); num[a]=b; } for(int i=1;i<max;i++) { k-=num[i]; if(k<=0) { printf("%d",i); break; } } return 0; }
main.c: In function 'main': main.c:9:22: error: variable-sized object may not be initialized except with an empty initializer 9 | int num[max]={0}; | ^
s307648663
p03721
C++
#include <iostream> #define MAX 100000 using namespace std; int main(void) { int n,m,temp; cin >> n >> m; int b[100001]; for (int i=0;i<n;i++) { itn a,b; cin >> a >> b; b[a] += b; } for (int i=1;MAX > i;i++) { if (m <= b[i];) m -= b[i]; } return 0; }
a.cc: In function 'int main()': a.cc:11:25: error: 'itn' was not declared in this scope; did you mean 'int'? 11 | itn a,b; | ^~~ | int a.cc:12:32: error: 'a' was not declared in this scope 12 | cin >> a >> b; | ^ a.cc:16:39: error: expected primary-expression before ')' token 16 | if (m <= b[i];) | ^
s009799190
p03721
C++
#include <iostream> using namespace std; using ll = long long; int main(void) { int n; ll m; cin >> n >> m; int a[n],b[n]; for (int i=0;i<n;i++) { cin >> a[i] >> b[i]; } for (int i=0;i<n-1;i++) { for (int j=0;j<n-1-i;j++) { if (a[j]>a[j+1]) { temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; temp = b[j]; b[j] = b[j+1]; b[j+1] = temp; } } } int i; for (i=0;m > 0;i++) { m -= b[i]; } cout << a[i-1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:33: error: 'temp' was not declared in this scope; did you mean 'tm'? 17 | temp = a[j]; | ^~~~ | tm
s974257462
p03721
Java
package AtCoder; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; import java.io.PrintWriter; public class TaskC { long[] arr = new long[100000+1]; public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); int k = in.nextInt(); for (int i = 0; i < n; ++i) { int a = in.nextInt(); int b = in.nextInt(); arr[a] += b; } for (int i = 1; i <= 100000; ++i) { if (k > arr[i]) k -= arr[i]; else { out.println(i); break; } } } }
Main.java:8: error: class TaskC is public, should be declared in a file named TaskC.java public class TaskC { ^ 1 error
s151995266
p03721
C++
#include<bits/stdc++.h> #define rep(i,start,lim) for(lld i=start;i<lim;i++) #define repd(i,start,lim) for(lld i=start;i>=lim;i--) #define scan(x) scanf("%lld",&x) #define print(x) printf("%lld ",x) #define f first #define s second #define pb push_back #define mp make_pair #define br printf("\n") #define sz(a) lld((a).size()) #define YES printf("YES\n") #define NO printf("NO\n") #define all(c) (c).begin(),(c).end() using namespace std; #define INF 1011111111 #define LLINF 1000111000111000111LL #define EPS (double)1e-10 #define MOD 1000000007 #define PI 3.14159265358979323 using namespace std; typedef long double ldb; typedef long long lld; lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;} typedef vector<lld> vlld; typedef pair<lld,lld> plld; typedef map<lld,lld> mlld; typedef set<lld> slld; #define N 100005 vector<pair<int,int>> v,sum; int main() { lld n,curr=0,x,y; cin>>n>>k; rep(i,0,n) cin>>x>>y,v.pb({x,y}); sort(all(v)); rep(i,1,n) curr+=v[i].s,sum.pb(curr,v[0].f); auto it=lower_bound(all(sum),{k,LLINF}); it--; cout<<*it; return 0; }
a.cc: In function 'int main()': a.cc:34:17: error: 'k' was not declared in this scope 34 | cin>>n>>k; | ^ a.cc:37:39: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(lld&, int&)' 37 | rep(i,1,n) curr+=v[i].s,sum.pb(curr,v[0].f); | ~~~~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]' 1283 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]' 1300 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 2 provided a.cc:39:28: error: no matching function for call to 'lower_bound(std::vector<std::pair<int, int> >::iterator, std::vector<std::pair<int, int> >::iterator, <brace-enclosed initializer list>)' 39 | auto it=lower_bound(all(sum),{k,LLINF}); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)' 1530 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1530:5: note: template argument deduction/substitution failed: a.cc:39:28: note: couldn't deduce template parameter '_Tp' 39 | auto it=lower_bound(all(sum),{k,LLINF}); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)' 1963 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate expects 4 arguments, 3 provided
s598646422
p03721
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] a = new int[100000]; for(int i=0; i<100000; i++){ a[i] = 0; } for(int i=0; i<N; i++){ a[sc.nextInt()-1] += sc.nextInt(); } int min=0; for(int i=0; i<N; i++){ K-=a[i]; if(K<0){ min = i+1; break; } } System.out.println(min); sc.close(); }
Main.java:27: error: reached end of file while parsing } ^ 1 error
s559373998
p03721
C++
int main() { int N, K; cin >> N; cin >> K; map<int, int> mii; for (auto i = 0; i < N; i++) { int index, val; cin >> index; cin >> val; mii[index] += val; } int counter = 0; auto ind = mii.begin(); while (counter += ind->second < K) ind++; cout << ind->first; //char c = 'c'; //cin >> c; return 0; }
a.cc: In function 'int main()': a.cc:4:9: error: 'cin' was not declared in this scope 4 | cin >> N; | ^~~ a.cc:6:9: error: 'map' was not declared in this scope 6 | map<int, int> mii; | ^~~ a.cc:6:13: error: expected primary-expression before 'int' 6 | map<int, int> mii; | ^~~ a.cc:12:17: error: 'mii' was not declared in this scope 12 | mii[index] += val; | ^~~ a.cc:16:20: error: 'mii' was not declared in this scope 16 | auto ind = mii.begin(); | ^~~ a.cc:19:9: error: 'cout' was not declared in this scope 19 | cout << ind->first; | ^~~~
s411548360
p03721
C++
#include <iostream> #include <string> #include <map> #include <algorithm> using namespace std; void main() { int N, K; cin >> N; cin >> K; map<int, int> mii; for (auto i = 0; i < N; i++) { int index, val; cin >> index; cin >> val; mii[index] += val; } int counter = 0; auto ind = mii.begin(); while (true) { if (ind->second + counter < K) { counter += ind->second; ind++; //cout << counter << "///" << ind->second << endl;; } else { break; } } cout << ind->first; }
a.cc:7:1: error: '::main' must return 'int' 7 | void main() | ^~~~
s670276932
p03721
C++
#include <iostream> using namespace std; int main(void){ long long int N, K; cin >> N >> K; int A, B; long long int ans[100001]; for(int i = 0; i < N; ++i){ cin >> A >> B; ans[A] += B; } for(int i = 1; i <= 100000; ++i){ if(K <= ans[i]){ cout << i << endl; break; } K -= ans[i]; } break; }
a.cc: In function 'int main()': a.cc:21:1: error: break statement not within loop or switch 21 | break; | ^~~~~
s308216836
p03721
C++
#include <iostream> using namespace std; int main(void){ int N, K; cin >> N >> K; int A, B; for(int i = 0; i < N; ++i){ cin >> A >> B; ans[A] += B } for(int i = 1; i <= 100000; ++i){ if(K <= ans[i]){ cout << i << endl; break; } K -= B; } }
a.cc: In function 'int main()': a.cc:9:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 9 | ans[A] += B | ^~~ | abs a.cc:12:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 12 | if(K <= ans[i]){ | ^~~ | abs
s844105906
p03721
C++
#include <vector> #include <utility> #include <algorithm> using namespace std; int main() { int N,K; scanf ("%d %d", &N, &K); vector<pair<int, int>> V; V.reserve(N); for (int i = 0; i < N; i++) { int a,b; scanf("%d %d", &a, &b); V.push_back({a, b}); } sort(V.begin(), V.end()); for (auto v : V) { K -= v.second; if (K <= 0) { printf("%d\n", v.first); return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:10:3: error: 'scanf' was not declared in this scope 10 | scanf ("%d %d", &N, &K); | ^~~~~ a.cc:22:7: error: 'printf' was not declared in this scope 22 | printf("%d\n", v.first); | ^~~~~~ a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 3 | #include <algorithm> +++ |+#include <cstdio> 4 |
s162985318
p03721
C++
#include <iostream> #include <cstdint> #include <valarray> using namespace std; int main(void) { int N; long long K; cin >> N >> K; valarray<long long> s(0, 100000); for (int n = 0; n < N; n++) { int a, b; cin >> a >> b; s[a - 1] += b; } for (int n = 0; n < 100000; n++) { K -= s[n]; if (K <= 0) { cout << n + 1 << endl; return 0; } } }
a.cc: In function 'int main()': a.cc:13:36: error: call of overloaded 'valarray(int, int)' is ambiguous 13 | valarray<long long> s(0, 100000); | ^ In file included from a.cc:3: /usr/include/c++/14/valarray:639:5: note: candidate: 'std::valarray<_Tp>::valarray(const _Tp*, std::size_t) [with _Tp = long long int; std::size_t = long unsigned int]' 639 | valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n) | ^~~~~~~~~~~~~ /usr/include/c++/14/valarray:633:5: note: candidate: 'std::valarray<_Tp>::valarray(const _Tp&, std::size_t) [with _Tp = long long int; std::size_t = long unsigned int]' 633 | valarray<_Tp>::valarray(const _Tp& __t, size_t __n) | ^~~~~~~~~~~~~
s442161648
p03721
C
#include <iostream> #include <cstdint> #include <valarray> using namespace std; int main(void) { int N; int64_t K; cin >> N >> K; valarray<int> s(0, 100000); for (int n = 0; n < N; n++) { int a, b; cin >> a >> b; s[a - 1] += b; } for (int n = 0; n < 100000; n++) { K -= s[n]; if (K <= 0) { printf("%d\n", n + 1); return 0; } } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s307952763
p03721
C
#include <iostream> #include <cstdint> #include <valarray> using namespace std; int main(void) { int N; int64_t K; cin >> N >> K; valarray<int> s(0, 100000); for (int n = 0; n < N; n++) { int a, b; cin >> a >> b; s[a - 1] += b; } for (int n = 0; n < 100000; n++) { K -= s[n]; if (K <= 0) { printf("%d\n", n + 1); return 0; } } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s268848661
p03721
C
#include <iostream> #include <cstdint> #include <valarray> using namespace std; int main(void) { int N; int64_t K; cin >> N >> K; valarray<int> s(0, 100000); for (int n = 0; n < N; n++) { int a, b; cin >> a >> b; s[a - 1] += b; } for (int n = 0; n < 100000; n++) { K -= s[n]; if (K <= 0) { printf("%d\n", n + 1); return 0; } } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s328421373
p03721
C++
#include<iostream> using namespace std; int main(void) { int N = 0, K = 0, i = 0, count = 0, I = 0, ans = 0; int a[100000], b[100000]; cin >> N >> K; int min = 100000; for (i = 0; i < N; i++) { cin >> a[i] >> b[i]; } do { I = 0; min = 100000; for (i = 0; i < N; i++) { if (min> a[i]) { min = a[i]; I = i; } count += b[I]; ans = a[I]; a[I] = 1000000; } while (K>count); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:29:2: error: expected 'while' at end of input 29 | } | ^ a.cc:29:2: error: expected '(' at end of input 29 | } | ^ | ( a.cc:29:2: error: expected primary-expression at end of input a.cc:29:2: error: expected ')' at end of input 29 | } | ^ | ) a.cc:29:2: error: expected ';' at end of input 29 | } | ^ | ; a.cc:29:2: error: expected '}' at end of input a.cc:4:1: note: to match this '{' 4 | { | ^
s473519900
p03721
Java
//Do what you can't. import java.io.*; import java.util.*; import java.math.BigInteger; public class CB061A { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n=in.nextInt(),k=in.nextInt(); obj[] a=new obj[n]; for(int i=0;i<n;i++){ a[i]=new obj(in.nextInt(),in.nextInt()); } Arrays.sort(a); long sum=0; for(int i=0;i<n;i++){ sum+=a[i].ocr; if (sum>=k){ w.println(a[i].value); break; } } w.close(); } static class obj implements Comparable<obj>{ int value; int ocr; obj(int vl,int oc){ this.value=vl; this.ocr=oc; } public int compareTo(obj o){ return Integer.compare(this.value,o.value); } } static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public String readString() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isSpaceChar(c)); return res.toString(); } public String nextLine() { int c = snext(); while (isSpaceChar(c)) c = snext(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isEndOfLine(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
Main.java:6: error: class CB061A is public, should be declared in a file named CB061A.java public class CB061A { ^ 1 error
s573618152
p03721
Java
public class Main { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long K = sc.nextLong(); for (int i = 0; i < N; i++) { int res = sc.nextInt(); long count = sc.nextLong(); K -= count; if (K <= 0) { System.out.println(res); break; } } } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s178345445
p03721
C++
#include<iostream> #include<algorithm> using namespace std; struct AB{ int a; int b; }; bool operator<(const AB& left, const AB& right) { return left.a < right.a; } int main(){ int N long K; cin >> N >> K; AB ab[N]; for (int i = 0; i < N; i++) { cin >> ab[i].a >> ab[i].b; } sort(ab, ab + N); long sum = 0; for (int i = 0; i < N; i++) { sum += ab[i].b; if (sum >= K) { cout << ab[i].a << endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:16:5: error: expected initializer before 'long' 16 | long K; | ^~~~ a.cc:17:12: error: 'N' was not declared in this scope 17 | cin >> N >> K; | ^ a.cc:17:17: error: 'K' was not declared in this scope 17 | cin >> N >> K; | ^ a.cc:20:16: error: 'ab' was not declared in this scope; did you mean 'abs'? 20 | cin >> ab[i].a >> ab[i].b; | ^~ | abs a.cc:22:10: error: 'ab' was not declared in this scope; did you mean 'abs'? 22 | sort(ab, ab + N); | ^~ | abs
s443539757
p03721
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n, k; cin >> n >> k; vector<vector<int>>a(n, vector<long long>(2, 0)); for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; if (i > 1 && a[i][0] == a[i - 1][0]) { a[i][1] += a[i - 1][1]; a[i - 1][0] = 0; } } sort(a.begin(), a.end()); int c = 0; int d = 0; while (k != 0) { if (a[c][0] > 0) { if (k - a[c][1] > 0) { k -= a[c][1]; c++; d = 0; } else { if (a[c][0] > 0 && d != a[c][1]) { d++; k--; } } } else { c++; } } cout << a[c][0] << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:56: error: no matching function for call to 'std::vector<std::vector<int> >::vector(int&, std::vector<long long int>)' 11 | vector<vector<int>>a(n, vector<long long>(2, 0)); | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: a.cc:11:56: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<long long int>') 11 | vector<vector<int>>a(n, vector<long long>(2, 0)); | ^ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<int> >' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<int> >&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; value_type = std::vector<int>; allocator_type = std::allocator<std::vector<int> >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<long long int>' to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<int> >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<long long int>' to 'const std::vector<std::vector<int> >::allocator_type&' {aka 'const std::allocator<std::vector<int> >&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
s765824620
p03721
C++
#include <bits/stdc++.h> using namespace std; long long v[100000] int main() { long long n,k; cin >> n >> k; for(int i = 0;i < n;i++){ long long a,b; cin >> a >> b; v[a - 1] += b; } for(int i = 0;i < 100000;i++){ if(v[i] >= k){ cout << i + 1 << endl; return 0; } k -= v[i]; } return 0; }
a.cc:6:1: error: expected initializer before 'int' 6 | int main() { | ^~~
s082574968
p03721
C++
#include<cstdio> const int MAX = 100000; int main() { int N; int64_t K; scanf("%d %ld\n", &N, &K); int64_t num[MAX+1]; for (int i = 0; i < N; i++) { int a, b; scanf("%d %d", &a, &b); num[a] += b; } int64_t mid_sum = 0; int i = 1; while (true) { mid_sum += num[i]; if (mid_sum >= K) { printf("%d\n", i); break; } } }
a.cc: In function 'int main()': a.cc:6:9: error: 'int64_t' was not declared in this scope 6 | int64_t K; | ^~~~~~~ a.cc:2:1: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 1 | #include<cstdio> +++ |+#include <cstdint> 2 | const int MAX = 100000; a.cc:7:32: error: 'K' was not declared in this scope 7 | scanf("%d %ld\n", &N, &K); | ^ a.cc:9:16: error: expected ';' before 'num' 9 | int64_t num[MAX+1]; | ^~~~ | ; a.cc:15:17: error: 'num' was not declared in this scope; did you mean 'enum'? 15 | num[a] += b; | ^~~ | enum a.cc:18:16: error: expected ';' before 'mid_sum' 18 | int64_t mid_sum = 0; | ^~~~~~~~ | ; a.cc:21:17: error: 'mid_sum' was not declared in this scope 21 | mid_sum += num[i]; | ^~~~~~~ a.cc:21:28: error: 'num' was not declared in this scope; did you mean 'enum'? 21 | mid_sum += num[i]; | ^~~ | enum
s843062616
p03721
C++
#include <cstdio> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <vector> using namespace std; using ll = long long; #define FOR(i,a,b) for (ll i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(n) for (ll i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) int main(){ int N,a,b; longlong K; longlong num[100011] = {0}; scanf("%d",&N); scanf("%lld",&K); while(N--){ scanf("%d",&a); scanf("%d",&b); num[a] += b; } REP(N+1){ K -= num[i]; if(K<=0){ printf("%d\n",i); return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'longlong' was not declared in this scope 17 | longlong K; | ^~~~~~~~ a.cc:18:17: error: expected ';' before 'num' 18 | longlong num[100011] = {0}; | ^~~~ | ; a.cc:21:23: error: 'K' was not declared in this scope 21 | scanf("%lld",&K); | ^ a.cc:26:17: error: 'num' was not declared in this scope; did you mean 'enum'? 26 | num[a] += b; | ^~~ | enum a.cc:30:22: error: 'num' was not declared in this scope; did you mean 'enum'? 30 | K -= num[i]; | ^~~ | enum
s922027532
p03721
C
#include <iostream> #include <vector> using namespace std; long long v[100000]; int main() { long long n,k; cin >> n >> k; for(int i = 0; i < n; i++){ long long a,b; cin >> a >> b; v[a - 1] += b; } for(int i = 0;i < 100000;i++){ if(v[i] >= k){ cout << i + 1 << endl; return 0; } k -= v[i]; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s112617630
p03721
C
#include <iostream> #include <vector> using namespace std; long long v[100000]; int main() { long long n,k; cin >> n >> k; for(int i = 0; i < n; i++){ long long a,b; cin >> a >> b; v[a - 1] += b; } for(int i = 0;i < 100000;i++){ if(v[i] >= k){ cout << i + 1 << endl; return 0; } k -= v[i]; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s325441050
p03721
C
#include <bits/stdc++.h> using namespace std; long long v[100000]; int main() { long long n,k; cin >> n >> k; for(int i = 0; i < n; i++){ long long a,b; cin >> a >> b; v[a - 1] += b; } for(int i = 0;i < 100000;i++){ if(v[i] >= k){ cout << i + 1 << endl; return 0; } k -= v[i]; } return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s478362476
p03721
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long N,K,key=0; cin>>N>>K; vector<pair<int,int> >v(n); for(int i=0;i<N;i++){ cin>>v[i].first>>v[i].second; } sort(v.begin(),v.end()); for(int i=0;i<N;i++){ key+=v[i].second; if(key>=K){ cout<<v[i].first<<endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:7:27: error: 'n' was not declared in this scope 7 | vector<pair<int,int> >v(n); | ^
s685715865
p03721
C++
#include <iostream> #include <vector> using namespace std; int mainc() { int N, K; cin >> N >> K; vector<int> backet(N+1, 0); int a, b, i; for (i=0; i<N; i++) { cin >> a >> b; backet[b] += a; } for (i=1; K>0; i++) { K -= backet[i]; } cout << i << endl; }
a.cc: In function 'int mainc()': a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type] 18 | } | ^ /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
s744465265
p03721
C++
#include <iostream> using namespace std; using ll = long long; const int AMAX = 100000; ll cnt[AMAZ + 1]; int main(){ int N; ll K; cin >> N >> K; for(int i = 0; i < N; ++i){ int A, B; cnt[A] += B; } for(int ans = 1; ans <= AMAX; ++ans){ if(K <= cnt[ans]) { cout << ans << endl; break; } K -= cnt[ans]; } return 0; }
a.cc:5:8: error: 'AMAZ' was not declared in this scope; did you mean 'AMAX'? 5 | ll cnt[AMAZ + 1]; | ^~~~ | AMAX a.cc: In function 'int main()': a.cc:14:9: error: 'cnt' was not declared in this scope; did you mean 'int'? 14 | cnt[A] += B; | ^~~ | int a.cc:18:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 18 | if(K <= cnt[ans]) { | ^~~ | int a.cc:22:14: error: 'cnt' was not declared in this scope; did you mean 'int'? 22 | K -= cnt[ans]; | ^~~ | int
s024698591
p03721
Java
//package com.zhangyong.algorithm; import java.io.*; import java.util.StringTokenizer; public class Solution { FastScanner in; PrintWriter out; class FastScanner { BufferedReader br; StringTokenizer st; private FastScanner(File f) { try { br = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException e) { e.printStackTrace(); } } private FastScanner(InputStream f) { br = new BufferedReader(new InputStreamReader(f)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } static final int count = 100000; private void solve() { int n = in.nextInt(); long m = in.nextLong(); long arr[] = new long[count + 1]; int l; long r; for (int i = 0; i < n; i++) { l = in.nextInt(); r = in.nextLong(); arr[l] += r; } for (int i = 0; i <= count; i++) { if ((m -= arr[i]) <= 0) { out.print(i); break; } } } private void run() { in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } public static void main(String[] args) { new Solution().run(); } }
Main.java:6: error: class Solution is public, should be declared in a file named Solution.java public class Solution { ^ 1 error
s854304475
p03721
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<math.h> #include<vector> #include<map> #define int long long using namespace std;   map<int, int>a; signed main() { int b; cin >> b; int T; cin >> T; for (int c = 0; c < b; c++) { int d, e; cin >> d >> e; a[d] += e; } int sum = 0; for (auto i : a) { sum += i.second; if (sum >= T) { cout << i.first << endl; break; } } }
a.cc:9:1: error: extended character   is not valid in an identifier 9 |   | ^ a.cc:9:1: error: '\U000000a0' does not name a type 9 |   | ^ a.cc: In function 'int main()': a.cc:16:17: error: 'a' was not declared in this scope 16 | a[d] += e; | ^ a.cc:19:23: error: 'a' was not declared in this scope 19 | for (auto i : a) { | ^
s137403284
p03721
C
#include<stdio.h> long long k, j, b[100001] { 0}; int main(void){ int i; int a, b; int r; scanf("%d %lld", &n, &k); while(n--){ scanf("%d", &a); scanf("%d", &b); r[a] += b; } j = 0; for(i = 1; i < 100001; i++){ j += r[i]; if(j >= k){ printf("%d\n", i ); break; } } printf("\n"); }
main.c:2:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 2 | long long k, j, b[100001] { 0}; | ^ main.c: In function 'main': main.c:9:27: error: 'n' undeclared (first use in this function) 9 | scanf("%d %lld", &n, &k); | ^ main.c:9:27: note: each undeclared identifier is reported only once for each function it appears in main.c:14:18: error: subscripted value is neither array nor pointer nor vector 14 | r[a] += b; | ^ main.c:19:23: error: subscripted value is neither array nor pointer nor vector 19 | j += r[i]; | ^
s614700887
p03721
C++
using ll = long long; const int AMAX = 100000; ll cnt[AMAX + 1]; int main(void) { int N; ll K; cin >> N >> K; for(int i = 0; i < N; ++i){ int A, B; cin >> A >> B; cnt[A] += B; } for(int ans = 1; ans <= AMAX; ++ans){ if(K <== cnt[ans]){ cout << ans << endl; break; } K -= cnt[ans]; } return 0; }
a.cc: In function 'int main()': a.cc:9:9: error: 'cin' was not declared in this scope 9 | cin >> N >> K; | ^~~ a.cc:18:24: error: expected primary-expression before '=' token 18 | if(K <== cnt[ans]){ | ^ a.cc:19:25: error: 'cout' was not declared in this scope 19 | cout << ans << endl; | ^~~~ a.cc:19:40: error: 'endl' was not declared in this scope 19 | cout << ans << endl; | ^~~~
s642260123
p03721
C++
#define ll long long #define rep(i,n) for (int i=0;i<(n);i++) #include<iostream> #include<iomanip> #include<algorithm> #include<map> #define SIZE 100001 #define MOD 1000000007 #define INF 100000000 using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; ll k; cin >> n >> k; int a,b; map<int, int> mp; rep(i,n){ cin >> a >> b; mp[a] = b; } rep(i,n){ k -= mp[a[i]]; if(k <= 0){ cout << int(a[i]) << endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:26:34: error: invalid types 'int[int]' for array subscript 26 | k -= mp[a[i]]; | ^ a.cc:28:46: error: invalid types 'int[int]' for array subscript 28 | cout << int(a[i]) << endl; | ^
s835444716
p03721
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <vector> #include <cmath> using namespace std; #define FOR(i,s,e) for (int i = int(s); i < int(e); i++) #define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define ISEQ(c) (c).begin(), (c).end() int main(){ int N long long int K; cin >> N >> K; struct comp { int val; int num; bool operator<(const comp& another) const { return val < another.val; } }; vector<comp> c; FOR(i,0,N){ comp cc; cin >> cc.val >> cc.num; c.push_back(cc); } sort(c.begin(),c.end()); long long int css = 0; int ret = 0; for(comp co : c){ css += co.num; ret = co.val; if (css >= K) break; cout << co.val << " " << co.num << endl; } cout << ret << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:9: error: expected initializer before 'long' 19 | long long int K; | ^~~~ a.cc:20:16: error: 'N' was not declared in this scope 20 | cin >> N >> K; | ^ a.cc:20:21: error: 'K' was not declared in this scope 20 | cin >> N >> K; | ^
s175307167
p03721
C++
#include <bits/stdc++.h> using namespace std; #define N 100000 int main() { int n; long long int k; cin>>n>>k; long long int hoge[N]={}; int a,b; for(int i=0;i<n;i++){ cin>>a>>b; hoge[a-1]+=b; } for(int i=0;i<N;i++){ k=k-a[i] if(k<=0){ cout<<i+1<<endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:16:22: error: invalid types 'int[int]' for array subscript 16 | k=k-a[i] | ^
s052394155
p03721
C++
using namespace std; int main() { long long int n; int k; cin>>n>>k; vector<long long int> hoge; long long int a[n]; long long int b[n]; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; for(int j=0;j<b[i];j++){ hoge.push_back(a[i]); } } sort(hoge.begin(),hoge.end()); cout<<hoge[k-1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:6:9: error: 'cin' was not declared in this scope 6 | cin>>n>>k; | ^~~ 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:7:9: error: 'vector' was not declared in this scope 7 | vector<long long int> hoge; | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | using namespace std; a.cc:7:16: error: expected primary-expression before 'long' 7 | vector<long long int> hoge; | ^~~~ a.cc:13:25: error: 'hoge' was not declared in this scope 13 | hoge.push_back(a[i]); | ^~~~ a.cc:16:14: error: 'hoge' was not declared in this scope 16 | sort(hoge.begin(),hoge.end()); | ^~~~ a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(hoge.begin(),hoge.end()); | ^~~~ | short a.cc:17:9: error: 'cout' was not declared in this scope 17 | cout<<hoge[k-1]<<endl; | ^~~~ a.cc:17:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:17:26: error: 'endl' was not declared in this scope 17 | cout<<hoge[k-1]<<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;
s816935733
p03721
C++
#include <iostream> #include <map> #include <algorithm> #include <vector> using namespace std; typedef long long ll; int N, K; typedef pair <int,int> P; vector<P> array; int main() { cin >> N >> K; for(int i = 0; i < N; i++) { int a, b; cin >> a >> b; array.push_back(P(a,b)); } sort(array.begin(), array.end()); ll sum = 0; int i = 0; for(; i < N; i++) { sum += array[i].second; if(K <= sum) break; } cout << array[i].first <<endl; }
a.cc: In function 'int main()': a.cc:18:5: error: reference to 'array' is ambiguous 18 | array.push_back(P(a,b)); | ^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:10:11: note: 'std::vector<std::pair<int, int> > array' 10 | vector<P> array; | ^~~~~ a.cc:21:8: error: reference to 'array' is ambiguous 21 | sort(array.begin(), array.end()); | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:10:11: note: 'std::vector<std::pair<int, int> > array' 10 | vector<P> array; | ^~~~~ a.cc:21:23: error: reference to 'array' is ambiguous 21 | sort(array.begin(), array.end()); | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:10:11: note: 'std::vector<std::pair<int, int> > array' 10 | vector<P> array; | ^~~~~ a.cc:26:12: error: reference to 'array' is ambiguous 26 | sum += array[i].second; | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:10:11: note: 'std::vector<std::pair<int, int> > array' 10 | vector<P> array; | ^~~~~ a.cc:30:11: error: reference to 'array' is ambiguous 30 | cout << array[i].first <<endl; | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:10:11: note: 'std::vector<std::pair<int, int> > array' 10 | vector<P> array; | ^~~~~
s196125796
p03721
C++
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <pair> using namespace std; int main(void){ int n,k;scanf("%d%d",&n,&k); vector <pair<int,int> > v; for(int i=0; i<n; i++){ int a,b;scanf("%d%d",&a,&b); v.push_back(make_pair(a,b)); } sort(v.begin(), v.end()); int index=0; whlie(true){ k-=v[index].second; if(k<0){ cout << v[index].first; }else{ index++; } } return 0; }
a.cc:5:10: fatal error: pair: No such file or directory 5 | #include <pair> | ^~~~~~ compilation terminated.
s487310974
p03721
C++
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include<cmath> #include<cstdio> #include<vector> #include<algorithm> #include<iostream> #include<queue> typedef long long i64; using namespace std; int main() { int n; i64 k; vector<pair<i64, i64>> vec; scanf("%d%lld", &n, &k); for (int i = 0; i < n; ++i) { i64 a, b; scanf("%lld%lld", &a, &b); vec.push_back({ a,b }); } sort(vec.begin(), vec.end()); i64 cnt = 0; for (int i = 0; i < n; ++i) { if (cnt + vec[i].second >= k) { printf("%lld", vec[i].first); return 0; } else { cnt += vec[i].second; } } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s861553661
p03721
C++
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <cstdint> using namespace std; using elem_t = pair<int_least32_t, int_least32_t>; int main() { int_least32_t n; int_least64_t k; cin >> n >> k; vector<elem_t> v( n ); for(auto& x : v) { cin >> x.first >> x.second; } sort(v.begin(), v.end(), [](elem_t x, elem_t y){ return x.first < y.first; } ); int_least32_t result; int_least64_t count = 0; for(auto i = 0; count < k; ++i) { result = v[i].first; count += v[i].second; } cout << result << endl; }
a.cc:24:9: error: extended character   is not valid in an identifier 24 | int_least32_t result; | ^ a.cc: In function 'int main()': a.cc:24:9: error: 'int_least32_t\U00003000result' was not declared in this scope 24 | int_least32_t result; | ^~~~~~~~~~~~~~~~~~~~~ a.cc:27:17: error: 'result' was not declared in this scope 27 | result = v[i].first; | ^~~~~~ a.cc:31:17: error: 'result' was not declared in this scope 31 | cout << result << endl; | ^~~~~~
s504250431
p03721
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct St { int a; int b; bool operator<( const St& right ) const { return a == right.a ? a < right.a : a < right.a; } }; int main() { int N; long long int K; cin >> N >> K; vector<St> st(N); for( int i = 0; i < N; ++i ){ cin >> st[i].a >> st[i].b; } sort(st.begin(), st.end()); for( int i = 0; i < N; ++i ){ cnt += st[i].b; if( K <= cnt ){ cout << st[i].a << endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:19:5: error: expected initializer before 'long' 19 | long long int K; | ^~~~ a.cc:20:12: error: 'N' was not declared in this scope 20 | cin >> N >> K; | ^ a.cc:20:17: error: 'K' was not declared in this scope 20 | cin >> N >> K; | ^ a.cc:30:9: error: 'cnt' was not declared in this scope; did you mean 'int'? 30 | cnt += st[i].b; | ^~~ | int
s199300587
p03721
Java
import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); long long int D = 0; long long int N = sc.nextInt(); long long int K = sc.nextInt(); int c[] = new int[100000]; for(long long int i = 0; i<N; i++){ long long int a = sc.nextInt(); long long int b = sc.nextInt(); c[a-1] = c[a-1] + b; } long long int j = 0; while(K>0){ D = j + 1; K = K - c[j]; j++; } System.out.println(D); } }
Main.java:7: error: not a statement long long int D = 0; ^ Main.java:7: error: ';' expected long long int D = 0; ^ Main.java:7: error: not a statement long long int D = 0; ^ Main.java:7: error: ';' expected long long int D = 0; ^ Main.java:8: error: not a statement long long int N = sc.nextInt(); ^ Main.java:8: error: ';' expected long long int N = sc.nextInt(); ^ Main.java:8: error: not a statement long long int N = sc.nextInt(); ^ Main.java:8: error: ';' expected long long int N = sc.nextInt(); ^ Main.java:9: error: not a statement long long int K = sc.nextInt(); ^ Main.java:9: error: ';' expected long long int K = sc.nextInt(); ^ Main.java:9: error: not a statement long long int K = sc.nextInt(); ^ Main.java:9: error: ';' expected long long int K = sc.nextInt(); ^ Main.java:14: error: not a statement for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: ';' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: '.class' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: '.class' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: > or ',' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: not a statement for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: ';' expected for(long long int i = 0; i<N; i++){ ^ Main.java:15: error: not a statement long long int a = sc.nextInt(); ^ Main.java:15: error: ';' expected long long int a = sc.nextInt(); ^ Main.java:15: error: not a statement long long int a = sc.nextInt(); ^ Main.java:15: error: ';' expected long long int a = sc.nextInt(); ^ Main.java:16: error: not a statement long long int b = sc.nextInt(); ^ Main.java:16: error: ';' expected long long int b = sc.nextInt(); ^ Main.java:16: error: not a statement long long int b = sc.nextInt(); ^ Main.java:16: error: ';' expected long long int b = sc.nextInt(); ^ Main.java:22: error: not a statement long long int j = 0; ^ Main.java:22: error: ';' expected long long int j = 0; ^ Main.java:22: error: not a statement long long int j = 0; ^ Main.java:22: error: ';' expected long long int j = 0; ^ 31 errors
s817951148
p03721
Java
import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); long long int D = 0; long long int N = sc.nextlong long int(); long long int K = sc.nextlong long int(); long long int c[] = new long long int[100000]; for(long long int i = 0; i<N; i++){ long long int a = sc.nextlong long int(); long long int b = sc.nextlong long int(); c[a-1] = c[a-1] + b; } long long int j = 0; while(K>0){ D = j + 1; K = K - c[j]; j++; } System.out.prlong long intln(D); } }
Main.java:7: error: not a statement long long int D = 0; ^ Main.java:7: error: ';' expected long long int D = 0; ^ Main.java:7: error: not a statement long long int D = 0; ^ Main.java:7: error: ';' expected long long int D = 0; ^ Main.java:8: error: not a statement long long int N = sc.nextlong long int(); ^ Main.java:8: error: ';' expected long long int N = sc.nextlong long int(); ^ Main.java:8: error: not a statement long long int N = sc.nextlong long int(); ^ Main.java:8: error: ';' expected long long int N = sc.nextlong long int(); ^ Main.java:8: error: ';' expected long long int N = sc.nextlong long int(); ^ Main.java:8: error: not a statement long long int N = sc.nextlong long int(); ^ Main.java:8: error: ';' expected long long int N = sc.nextlong long int(); ^ Main.java:8: error: not a statement long long int N = sc.nextlong long int(); ^ Main.java:8: error: ';' expected long long int N = sc.nextlong long int(); ^ Main.java:9: error: not a statement long long int K = sc.nextlong long int(); ^ Main.java:9: error: ';' expected long long int K = sc.nextlong long int(); ^ Main.java:9: error: not a statement long long int K = sc.nextlong long int(); ^ Main.java:9: error: ';' expected long long int K = sc.nextlong long int(); ^ Main.java:9: error: ';' expected long long int K = sc.nextlong long int(); ^ Main.java:9: error: not a statement long long int K = sc.nextlong long int(); ^ Main.java:9: error: ';' expected long long int K = sc.nextlong long int(); ^ Main.java:9: error: not a statement long long int K = sc.nextlong long int(); ^ Main.java:9: error: ';' expected long long int K = sc.nextlong long int(); ^ Main.java:11: error: not a statement long long int c[] = new long long int[100000]; ^ Main.java:11: error: ';' expected long long int c[] = new long long int[100000]; ^ Main.java:11: error: not a statement long long int c[] = new long long int[100000]; ^ Main.java:11: error: ';' expected long long int c[] = new long long int[100000]; ^ Main.java:11: error: '[' expected long long int c[] = new long long int[100000]; ^ Main.java:11: error: '.class' expected long long int c[] = new long long int[100000]; ^ Main.java:11: error: ']' expected long long int c[] = new long long int[100000]; ^ Main.java:11: error: not a statement long long int c[] = new long long int[100000]; ^ Main.java:14: error: not a statement for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: ';' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: '.class' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: '.class' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: > or ',' expected for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: not a statement for(long long int i = 0; i<N; i++){ ^ Main.java:14: error: ';' expected for(long long int i = 0; i<N; i++){ ^ Main.java:15: error: not a statement long long int a = sc.nextlong long int(); ^ Main.java:15: error: ';' expected long long int a = sc.nextlong long int(); ^ Main.java:15: error: not a statement long long int a = sc.nextlong long int(); ^ Main.java:15: error: ';' expected long long int a = sc.nextlong long int(); ^ Main.java:15: error: ';' expected long long int a = sc.nextlong long int(); ^ Main.java:15: error: not a statement long long int a = sc.nextlong long int(); ^ Main.java:15: error: ';' expected long long int a = sc.nextlong long int(); ^ Main.java:15: error: not a statement long long int a = sc.nextlong long int(); ^ Main.java:15: error: ';' expected long long int a = sc.nextlong long int(); ^ Main.java:16: error: not a statement long long int b = sc.nextlong long int(); ^ Main.java:16: error: ';' expected long long int b = sc.nextlong long int(); ^ Main.java:16: error: not a statement long long int b = sc.nextlong long int(); ^ Main.java:16: error: ';' expected long long int b = sc.nextlong long int(); ^ Main.java:16: error: ';' expected long long int b = sc.nextlong long int(); ^ Main.java:16: error: not a statement long long int b = sc.nextlong long int(); ^ Main.java:16: error: ';' expected long long int b = sc.nextlong long int(); ^ Main.java:16: error: not a statement long long int b = sc.nextlong long int(); ^ Main.java:16: error: ';' expected long long int b = sc.nextlong long int(); ^ Main.java:22: error: not a statement long long int j = 0; ^ Main.java:22: error: ';' expected long long int j = 0; ^ Main.java:22: error: not a statement long long int j = 0; ^ Main.java:22: error: ';' expected long long int j = 0; ^ Main.java:30: error: not a statement System.out.prlong long intln(D); ^ Main.java:30: error: ';' expected System.out.prlong long intln(D); ^ Main.java:30: error: ';' expected System.out.prlong long intln(D); ^ Main.java:30: error: not a statement System.out.prlong long intln(D); ^ Main.java:30: error: ';' expected System.out.prlong long intln(D); ^ 64 errors
s336256881
p03721
C
#include <stdio.h> int main(void) { int N, K; scanf("%d %d", &N, &K); int a, b; for (int n = 0; n < N; n++) { scanf("%d %d", &a, &b); K -= b; if (K <= 0) break } printf("%d", a); }
main.c: In function 'main': main.c:11:26: error: expected ';' before '}' token 11 | if (K <= 0) break | ^ | ; 12 | } | ~
s808560170
p03721
C++
#include<iostream> #include <cstdlib> #include<list> #include<stdio.h> #include<algorithm> #include<string> #include<stack> using namespace std; int main() { int n, k, a[1000001] = { 0 }; cin >> n >> k; k--; for (int i = 0; i < n; i++) { int b, c; cin >> b >> c; a[b-1] += c; }int i=0; while(1) { if (k - a[i]>=0) { k -= a[i];cout<<k<<endl; } else { cout << i+1; break; }i++; }   }
a.cc:25:1: error: extended character   is not valid in an identifier 25 |   | ^ a.cc: In function 'int main()': a.cc:25:1: error: '\U000000a0' was not declared in this scope 25 |   | ^
s301329812
p03721
C++
#include<algorithm> #include<stdio.h> using namespace std; struct node { long long int nu,cou; }; struct node nod[1000010]; bool comp(struct node p1, struct node p2) { if(p1.num>p2.num) return false; if(p1.num<=p2.num) return true; } int main() { long long int n,i,k; scanf("%lld %lld",&n,&k); for(i=0; i<n; i++) { long long int x,y; scanf("%lld%lld",&x,&y); nod[i].nu =x; nod[i].cou = y; } sort(nod,nod+n,comp); for(i=0; i<n; i++) { k=k-nod[i].cou; if(k<=0) { printf("%lld\n",nod[i].nu); return 0; break; } } return 0; }
a.cc: In function 'bool comp(node, node)': a.cc:11:15: error: 'struct node' has no member named 'num'; did you mean 'nu'? 11 | if(p1.num>p2.num) return false; | ^~~ | nu a.cc:11:22: error: 'struct node' has no member named 'num'; did you mean 'nu'? 11 | if(p1.num>p2.num) return false; | ^~~ | nu a.cc:12:15: error: 'struct node' has no member named 'num'; did you mean 'nu'? 12 | if(p1.num<=p2.num) return true; | ^~~ | nu a.cc:12:23: error: 'struct node' has no member named 'num'; did you mean 'nu'? 12 | if(p1.num<=p2.num) return true; | ^~~ | nu a.cc:13:1: warning: control reaches end of non-void function [-Wreturn-type] 13 | } | ^
s662293038
p03721
Java
import java.util.Scanner; public class Atcoder061c { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int D = 0; int N = sc.nextInt(); int K = sc.nextInt(); int c[] = new int[100000]; for(int i = 0; i<N; i++){ int a = sc.nextInt(); int b = sc.nextInt(); c[a-1] = c[a-1] + b; } int j = 0; while(K>0){ D = j + 1; K = K - c[j]; j++; } System.out.println(D); } }
Main.java:3: error: class Atcoder061c is public, should be declared in a file named Atcoder061c.java public class Atcoder061c { ^ 1 error
s802960095
p03721
C
#include <cstdio> #include <queue> using namespace std; struct t { int x,y; }a[1001],b; struct cmp { bool operator()(const struct t &a,const struct t &b) { return a.x>b.x; } }; int main() { int n,i,j,k,l; scanf("%d%d",&n,&k); for(i=0;i<n;i++) scanf("%d%d",&a[i].x,&a[i].y); priority_queue <t,vector<t>,cmp> q(a,a+n); while(k!=0) { b=q.top(); q.pop(); if(k-b.y>0) k-=b.y; else if(k-b.y==0) {k=0; l=b.x;} else if(k-b.y<0&&k!=0) {k=0; l=b.x;} } printf("%d\n",l); return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s924236857
p03721
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int N,K,ans,x=0; cin>>N>>K; int a[N],b[N]; long long big[10000000000]; bool ansDefined=false; //N=number of times putting the value //ans=Kth smallest number for(int i=0;i<N;i++){ cin>>a[i]>>b[i]; } for(int g=0;g<N;g++){ for(int r=0;r<b[g];r++){ big[x]=a[g]; x++; } std::sort(big,big+x); cout<<big[K-1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:26:2: error: expected '}' at end of input 26 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s766600779
p03721
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> #define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++) #define REP(i,n) for (int i=0;i<(n);i++) #define pb push_back #define all(a) (a).begin(),(a).end() //greater<int>() #define ll long long using namespace std; int main(){ int N,i,j,a,b,v1,v2; ll K int cnt=0; cin>>N>>K; vector<int> A,B; REP(i,N){ cin>>a>>b; A.pb(a); B.pb(b); } FOR(i,1,N){ v1=A[i]; v2=B[i]; j=i-1; while(j>=0 && A[j]>v1){ A[j+1]=A[j]; B[j+1]=B[j]; j--; } A[j+1]=v1; B[j+1]=v2; } REP(i,N){ cnt+=B[i]; if(cnt>=K){ cout<<A[i]<<endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: expected initializer before 'int' 15 | int cnt=0; | ^~~ a.cc:16:17: error: 'K' was not declared in this scope 16 | cin>>N>>K; | ^ a.cc:40:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 40 | cnt+=B[i]; | ^~~ | int
s336088084
p03721
Java
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import util.Utils; public class Main { public static void main(String args[]) { try (Scanner in = new Scanner(System.in)) { int N = in.nextInt(); int K = in.nextInt(); int[] a = new int[N]; int[] b = new int[N]; for (int i = 0; i < N; i++) { a[i] = in.nextInt(); b[i] = in.nextInt(); } ArrayList<Pair<Integer, Integer>> numberAndCountPairs = new ArrayList<>(); for (int i = 0; i < N; i++) { numberAndCountPairs.add(new Pair<Integer, Integer>(a[i], b[i])); } Collections.sort(numberAndCountPairs); int sum = 0; for (int i = 0; i < numberAndCountPairs.size(); i++) { sum += numberAndCountPairs.get(i).second; if (sum >= K) { System.out.println(numberAndCountPairs.get(i).first); return; } } throw new AssertionError(); } } } class Pair<T extends Comparable<T>, S> implements Comparable<Pair<T, S>> { public T first; public S second; public Pair(T t, S s) { this.first = t; this.second = s; } private int hash = 0; @Override public int hashCode() { if (hash == 0) { final int prime = 31; int result = 1; result = prime * result + ((first == null) ? 0 : first.hashCode()); result = prime * result + ((second == null) ? 0 : second.hashCode()); hash = result; } return hash; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Pair<T, S> other = (Pair<T, S>) obj; if (first == null) { if (other.first != null) return false; } else if (!first.equals(other.first)) return false; if (second == null) { if (other.second != null) return false; } else if (!second.equals(other.second)) return false; return true; } @Override public int compareTo(Pair<T, S> o) { return first.compareTo(o.first); } }
Main.java:5: error: package util does not exist import util.Utils; ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s429956333
p03721
C++
#include<bits/stdc++.h> #define LL long long using namespace std; LL hash[100050]; int main(){ // freopen("input.txt","r",stdin); LL n,k; scanf("%I64d%I64d",&n,&k); for(int i=1;i<=n;i++){ LL a,b; scanf("%I64d%I64d",&a,&b); hash[a]+=b; } for(int i=1;i<=100050;i++){ if(hash[i]) k-=hash[i]; if(k<=0){ printf("%d\n",i); break; } } return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: reference to 'hash' is ambiguous 12 | hash[a]+=b; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:4:4: note: 'long long int hash [100050]' 4 | LL hash[100050]; | ^~~~ a.cc:15:12: error: reference to 'hash' is ambiguous 15 | if(hash[i]) k-=hash[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:4:4: note: 'long long int hash [100050]' 4 | LL hash[100050]; | ^~~~ a.cc:15:24: error: reference to 'hash' is ambiguous 15 | if(hash[i]) k-=hash[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:4:4: note: 'long long int hash [100050]' 4 | LL hash[100050]; | ^~~~
s527107046
p03721
C++
/ #include <iostream> //#include <algorithm> using namespace std; void QuickSort(int array[],int b[], int begin, int end) { int i = begin; int j = end; int pivot; int temp; pivot = array[(begin + end) / 2]; while (1) { while (array[i] < pivot) { ++i; } while (array[j] > pivot) { --j; } if (i >= j)break; temp = array[i]; array[i] = array[j]; array[j] = temp; temp = b[i]; b[i] = b[j]; b[j] = temp; i++; j--; } if (begin < i - 1) { QuickSort(array, b, begin, i - 1); } if (j + 1 < end) { QuickSort(array, b, j + 1, end); } } int main() { int n, k, bs=0; int a[100001] = { 0 }, b[100001] = { 0 }; cin >> n >> k; int i, j = 0; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; } QuickSort(a, b, 0, n-1); for (i = 0; i < n; i++) { bs += b[i]; if (bs >= k) { cout << a[i] << endl; break; } } return 0; }
a.cc:1:1: error: expected unqualified-id before '/' token 1 | / | ^ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 179 | _GLIBCXX_NODISCARD in
s806400445
p03721
C++
#include <iostream> #include <algorithm> #include <unordered_map> using namespace std; int main() { int operate_num, k; cin >> operate_num >> k; unordered_map<int, int> map; for (int i = 0; i < operate_num; i++) { int num, push_num; cin >> num >> push_num; map[num] += push_num; } vector<int> keys; for (auto itr = map.begin(); itr != map.end(); ++itr) { keys.push_back(itr->first); } sort(keys.begin(), keys.end()); int order = 0; for (auto i : keys) { order += map[i]; // cout << i << " : " << map[i] << ", " << order << endl; if (order >= k) { cout << i << endl; return 0; } } }
a.cc: In function 'int main()': a.cc:16:3: error: 'vector' was not declared in this scope 16 | vector<int> keys; | ^~~~~~ a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 3 | #include <unordered_map> +++ |+#include <vector> 4 | using namespace std; a.cc:16:10: error: expected primary-expression before 'int' 16 | vector<int> keys; | ^~~ a.cc:18:5: error: 'keys' was not declared in this scope 18 | keys.push_back(itr->first); | ^~~~ a.cc:21:8: error: 'keys' was not declared in this scope 21 | sort(keys.begin(), keys.end()); | ^~~~
s744442342
p03721
C++
#include<bits/stdc++.h> using namespace std; int hash[100050]; int main(){ // freopen("input.txt","r",stdin); int n,k; scanf("%d%d",&n,&k); for(int i=1;i<=n;i++){ int a,b; scanf("%d%d",&a,&b); hash[a]+=b; } for(int i=1;i<=100050;i++){ if(hash[i]) k-=hash[i]; if(k<=0){ printf("%d\n",i); break; } } return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: reference to 'hash' is ambiguous 11 | hash[a]+=b; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:3:5: note: 'int hash [100050]' 3 | int hash[100050]; | ^~~~ a.cc:14:12: error: reference to 'hash' is ambiguous 14 | if(hash[i]) k-=hash[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:3:5: note: 'int hash [100050]' 3 | int hash[100050]; | ^~~~ a.cc:14:24: error: reference to 'hash' is ambiguous 14 | if(hash[i]) k-=hash[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:3:5: note: 'int hash [100050]' 3 | int hash[100050]; | ^~~~
s644626139
p03721
C++
#include<bits/stdc++.h> using namespace std; int hash[100050]; int main(){ // freopen("input.txt","r",stdin); int n,k; scanf("%d%d",&n,&k); for(int i=1;i<=n;i++){ int a,b; scanf("%d%d",&a,&b); hash[a]+=b; } for(int i=1;i<=100050;i++){ if(hash[i]) k-=hash[i]; if(k<=0){ printf("%d",i); break; } } return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: reference to 'hash' is ambiguous 11 | hash[a]+=b; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:3:5: note: 'int hash [100050]' 3 | int hash[100050]; | ^~~~ a.cc:14:12: error: reference to 'hash' is ambiguous 14 | if(hash[i]) k-=hash[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:3:5: note: 'int hash [100050]' 3 | int hash[100050]; | ^~~~ a.cc:14:24: error: reference to 'hash' is ambiguous 14 | if(hash[i]) k-=hash[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:3:5: note: 'int hash [100050]' 3 | int hash[100050]; | ^~~~
s741177491
p03721
C++
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <stack> #include <queue> #include <cctype> #include <cmath> #include <map> #include <set> #define rep(i, m, n) for(int i = m;i < n;i++) #define repr(i, n) for(int i = n;i >= 0;i--) #define ll long long #define ull unsigned long long #define push(a) push_back(a) #define pop(a) pop_back(a) #define debug(x) cout<<#x<<": "<<x<<endl #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define INF 999999999 #define PI 3.14159265358979 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; int main(){ ull n,k,sum=0,a[100009]={},b[100009]={}; cin>>n>>k; rep(i,0,n)cin>>a[i]>>b[i]; sum=b[0]; rep(i,1,n){ if(b[i-1]<k&&k<=sum){ cout<<a[i]<<endl; return 0; } sum+=b[i];z } }
a.cc: In function 'int main()': a.cc:41:15: error: 'z' was not declared in this scope 41 | sum+=b[i];z | ^
s948876042
p03721
C++
# coding: utf-8 x={} n,k=map(int,input().split()) for i in range(n): a,b=map(int,input().split()) if a in x: x[a]+=b else: x[a]=b sorted(x) a=0 for i in x.items(): a+=i[1] if(a>=k): print(i[0]) break;
a.cc:1:3: error: invalid preprocessing directive #coding 1 | # coding: utf-8 | ^~~~~~ a.cc:2:1: error: 'x' does not name a type 2 | x={} | ^ a.cc:3:1: error: 'n' does not name a type 3 | n,k=map(int,input().split()) | ^
s907200627
p03721
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; int main(void){ int N,K; cin >> N >> K; vector<int> val[N]; for(int i = 0;i < N;++i){ int tmp; cin >> tmp; val.push_back(tmp); } sort(val.begin(),val.end()); if(val.size() <= K){ cout << val[N-1] << endl; }else{ cout << val[K-1] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: request for member 'push_back' in 'val', which is of non-class type 'std::vector<int> [N]' 17 | val.push_back(tmp); | ^~~~~~~~~ a.cc:19:12: error: request for member 'begin' in 'val', which is of non-class type 'std::vector<int> [N]' 19 | sort(val.begin(),val.end()); | ^~~~~ a.cc:19:24: error: request for member 'end' in 'val', which is of non-class type 'std::vector<int> [N]' 19 | sort(val.begin(),val.end()); | ^~~ a.cc:21:10: error: request for member 'size' in 'val', which is of non-class type 'std::vector<int> [N]' 21 | if(val.size() <= K){ | ^~~~ a.cc:22:10: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<int>') 22 | cout << val[N-1] << endl; | ~~~~ ^~ ~~~~~~~~ | | | | | std::vector<int> | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<int>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Tra
s458905156
p03721
C++
#include <iostream> #include <vector> using namespace std; struct AB { int a; int b; bool operator<( const AB& right ) const { return a == right.a ? a < right.a : b < right.b; } }; int main() { int N, K; cin >> N >> K; vector<AB> ab(N); for( int i = 0; i < N; ++i ){ int tmpa, tmpb; cin >> tmpa >> tmpb; ab[i].a = tmpa; ab[i].b = tmpb; } sort(ab.begin(), ab.end()); int ans; long int cnt = 0; for( auto itr = ab.begin(); itr != ab.end(); ++itr ){ cnt += itr->b; if( (long int)K <= cnt ){ ans = itr->a; break; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:5: error: 'sort' was not declared in this scope; did you mean 'short'? 28 | sort(ab.begin(), ab.end()); | ^~~~ | short
s426099293
p03721
Java
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = Long.parseLong(sc.next()); long K = Long.parseLong(sc.next()); long a = 0; long cnt = 0; for(long i=0;i<N;i++){ a = Long.parseLong(sc.next()); cnt += Long.parseLong(sc.next()); if(cnt >= K) { System.out.print(c); break; } } System.out.println(); } }
Main.java:20: error: cannot find symbol System.out.print(c); ^ symbol: variable c location: class Main 1 error
s091628619
p03721
C++
#include<iostream> using namespace std; int main() { int N; unsigned long long K; unsigned long long j = 0; int a[100000], b[100000]; int Array[100000]; cin >> N >> K; for (int i = 0; i < N; i++) { cin >> a[i] >> b[i]; } for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { for (int*p_Array = Array; p_Array < p_Array + (int)p_b; p_Array++) { *p_Array = *p_a; } } cout << Array[K - 1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:27: error: expected unqualified-id before 'int' 19 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~ a.cc:19:26: error: expected ';' before 'int' 19 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~~ | ; a.cc:19:49: error: expected ')' before ';' token 19 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ~ ^ | ) a.cc:19:51: error: 'p_a' was not declared in this scope 19 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~ a.cc:19:58: error: 'p_b' was not declared in this scope 19 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~
s144475541
p03721
C++
#include<iostream> using namespace std; int main() { int N; unsigned long long K; unsigned long long j = 0; int a[100000], b[100000]; int Array[100000]; cin >> N >> K; for (int i = 0; i < N; i++) { cin >> a[i] >> b[i]; } #if 0 for (int i = 0; i < N; i++) { for (; j < b[i]; j++) { Array[j] = a[i]; } } #else for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { for (int*p_Array = Array; p_Array < p_Array + (int)p_b; p_Array++) { *p_Array = *p_a; } } #endif cout << Array[K - 1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:29:27: error: expected unqualified-id before 'int' 29 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~ a.cc:29:26: error: expected ';' before 'int' 29 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~~ | ; a.cc:29:49: error: expected ')' before ';' token 29 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ~ ^ | ) a.cc:29:51: error: 'p_a' was not declared in this scope 29 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~ a.cc:29:58: error: 'p_b' was not declared in this scope 29 | for (int*p_a = a, int*p_b = b; p_a<p_a+N; p_a++, p_b++) { | ^~~
s899359520
p03721
Java
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = Long.parseLong(sc.next()); long W = Long.parseLong(sc.next()); int c; long cnt = 0; for(int i=0;i<N;i++){ c = Integer.parseLong(sc.next()); cnt += Integer.parseLong(sc.next()); if(cnt >= W) { //System.out.print(cnt); System.out.print(c); break; } } System.out.println(); } }
Main.java:18: error: cannot find symbol c = Integer.parseLong(sc.next()); ^ symbol: method parseLong(String) location: class Integer Main.java:19: error: cannot find symbol cnt += Integer.parseLong(sc.next()); ^ symbol: method parseLong(String) location: class Integer 2 errors
s562590615
p03721
C++
#include<iostream> #include<stdio.h> #include<vector> #include<utility> #include<algorithm> using namespace std; int main(){ int n,k; cin>>n>>k; vector< pair<int,int> > a(n); for(int i=0;i<n;i++){ cin>>a[i].first; cin>>a[i].second; } pair<int,int> temp; /*sort for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(a[j].first<a[i].first){ temp=a[j]; a[j]=a[i]; a[i]=temp; } } }*/ sort(a,a.length()); long long int hoge=0; for(int i=0;;i++){ if((k<=hoge)){ cout<<a[i-1].first<<endl; break; }else{ hoge+=a[i].second; //cout<<hoge<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:29:14: error: 'class std::vector<std::pair<int, int> >' has no member named 'length' 29 | sort(a,a.length()); | ^~~~~~
s092341590
p03721
Java
package beginner061; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; public class ProbC { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); List<Integer> list = new ArrayList<>(); Map<Integer, Integer> map = new HashMap<>(); for(int i = 0; i < n; i++){ int a = scan.nextInt(); int b = scan.nextInt(); list.add(a); if(map.containsKey(a)){ map.put(a, map.get(a) + b); }else{ map.put(a, b); } } list.sort(Comparator.naturalOrder()); for(int i = 0; i < list.size(); i++){ int num = list.get(i); k -= map.get(num); if(k <= 0){ System.out.println(num); break; } } } }
Main.java:10: error: class ProbC is public, should be declared in a file named ProbC.java public class ProbC { ^ 1 error
s580838456
p03721
C++
#include <iostream> #include <vector> using namespace std; struct Data { int no; int a; int b; bool operator<( const Data& right ) const { return a == right.a ? no < right.no : a < right.a; } }; int main() { int N, K; int a, b; cin >> N >> K; vector<Data> d(N); for(int i = 0; i < N; i++) { cin >> d[i].a >> d[i].b; d[i].no = i+1; } sort(d.begin(), d.end()); for(int i = 0; i < N; i++) { K -= d[i].b; if(K <= 0) { cout << d[i].a << endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'? 24 | sort(d.begin(), d.end()); | ^~~~ | short
s202906657
p03721
C++
//#include<bits/stdc++.h> #include<iostream> #include<algorithm> using namespace std; unsigned int ruio[1000001]; int main() { memset(ruio, 0, sizeof(ruio)); unsigned int N, K; cin >> N >> K; unsigned int sum = 1; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; if (a >= ruio[sum - 1]) { for (int j = 0; j < b; j++) { if (j > K)break; ruio[sum] = a; sum++; } } else { for (int j = 0; j < sum; j++) { if (j > K)break; if (ruio[j] > a) { for (int z = sum + b; z > j; z--) { ruio[z] = ruio[z - 1]; } ruio[j] = a; sum += b; break; } } } } cout << ruio[K] << endl; }
a.cc: In function 'int main()': a.cc:7:9: error: 'memset' was not declared in this scope 7 | memset(ruio, 0, sizeof(ruio)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s112410285
p03721
C
#include<stdio.h> int main(void){ int n, k; int a, b; int array[10001] = {0}; int i; int cnt, ans; scanf("%d%d",&n, &k)k; for(i = 0;i < n; ++i){ scanf("%d%d", &a, &b); array[a] += b; } ans = 0; cnt = 0; for(i = 0; cnt < k; ++i){ ans = i; cnt += array[i]; } printf("%d\n", ans); return 0; }
main.c: In function 'main': main.c:9:29: error: expected ';' before 'k' 9 | scanf("%d%d",&n, &k)k; | ^ | ;
s299941603
p03721
C++
//#include<bits/stdc++.h> #include<iostream> #include<algorithm> using namespace std; unsigned int ruio[1000001]; int main() { memset(ruio, 0, sizeof(ruio)); unsigned int N, K; cin >> N >> K; unsigned int sum = 1; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; if (a >= ruio[sum - 1]) { for (int j = 0; j < b; j++) { ruio[sum] = a; sum++; } } else { for (int j = 0; j < sum; j++) { if (ruio[j] > a) { for (int z = sum + b; z > j; z--) { ruio[z] = ruio[z - 1]; } ruio[j] = a; sum += b; break; } } } } cout << ruio[K] << endl; }
a.cc: In function 'int main()': a.cc:7:9: error: 'memset' was not declared in this scope 7 | memset(ruio, 0, sizeof(ruio)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s003656049
p03721
C++
//#include<bits/stdc++.h> #include<iostream> #include<algorithm> using namespace std; unsigned int unsigned ruio[1000001]; int main() { memset(ruio, 0, sizeof(ruio)); unsigned int N, K; cin >> N >> K; unsigned int sum = 1; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; if (a >= ruio[sum - 1]) { for (int j = 0; j < b; j++) { ruio[sum] = a; sum++; } } else { for (int j = 0; j < sum; j++) { if (ruio[j] > a) { for (int z = sum + b; z > j; z--) { ruio[z] = ruio[z - 1]; } ruio[j] = a; sum += b; break; } } } } cout << ruio[K] << endl; }
a.cc:6:6: error: duplicate 'unsigned' 6 | int unsigned ruio[1000001]; | ^~~~~~~~ | -------- a.cc: In function 'int main()': a.cc:8:9: error: 'memset' was not declared in this scope 8 | memset(ruio, 0, sizeof(ruio)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s208699720
p03721
C
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef struct { int a; int b; } ab; int cmp( const void *p, const void *q ) { return ((ab*)p)->a - ((ab*)q)->a; } int main (){ int i; int n,k; ab lst[10050] = {0}; int ans = 0; scanf("%d",&n); scanf("%d",&k); for(i=0;i<n;i++){ scanf("%d %d",&lst[i].a,&lst[i].b); } qsort( lst, n, sizeof(ab), cmp );//aが小さい順 i=0; while(1){ ans += lst[i].b; if(ans >= k){ printf("%d\n",lst[i].a); break; } i++; } /*for(i=0;i<n;i++){ printf("%d %d\n",lst[i].a,lst[i].b); }*/ return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s204460875
p03721
C++
#include <bits/stdc++.h> using namespace std; typedef pair<ll, ll> ii; ii v[10000050]; ll n, k,x; int main(){ scanf("%lld%lld", &n, &k); for(int i=0;i<n;i++){ scanf("%lld%lld", &(v[i].first), &(v[i].second)); } sort(v, v + n); for(int i=0;i<n;i++){ x += v[i].second; if(x >= k) {printf("%lld\n", v[i].first); break;} } }
a.cc:3:14: error: 'll' was not declared in this scope 3 | typedef pair<ll, ll> ii; | ^~ a.cc:3:18: error: 'll' was not declared in this scope 3 | typedef pair<ll, ll> ii; | ^~ a.cc:3:20: error: template argument 1 is invalid 3 | typedef pair<ll, ll> ii; | ^ a.cc:3:20: error: template argument 2 is invalid a.cc:5:1: error: 'll' does not name a type 5 | ll n, k,x; | ^~ a.cc: In function 'int main()': a.cc:7:22: error: 'n' was not declared in this scope; did you mean 'yn'? 7 | scanf("%lld%lld", &n, &k); | ^ | yn a.cc:7:26: error: 'k' was not declared in this scope 7 | scanf("%lld%lld", &n, &k); | ^ a.cc:9:30: error: request for member 'first' in 'v[i]', which is of non-class type 'ii' {aka 'int'} 9 | scanf("%lld%lld", &(v[i].first), &(v[i].second)); | ^~~~~ a.cc:9:45: error: request for member 'second' in 'v[i]', which is of non-class type 'ii' {aka 'int'} 9 | scanf("%lld%lld", &(v[i].first), &(v[i].second)); | ^~~~~~ a.cc:13:5: error: 'x' was not declared in this scope 13 | x += v[i].second; | ^ a.cc:13:15: error: request for member 'second' in 'v[i]', which is of non-class type 'ii' {aka 'int'} 13 | x += v[i].second; | ^~~~~~ a.cc:14:39: error: request for member 'first' in 'v[i]', which is of non-class type 'ii' {aka 'int'} 14 | if(x >= k) {printf("%lld\n", v[i].first); break;} | ^~~~~
s940544643
p03721
C++
#include<algorithm> #include<vector> #include<list> #include<iostream> #include<utility> #include<string> #include<set> #include<queue> #include<stack> #include<iterator> #include<map> #include<limits> #include<iomanip> #include<ctime> #include<cmath> const int INF=2147483647; const long long MOD=1e9+7; using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; long long k cin>>n>>k; vector<long long> vi(100001,0); for(int i=1; i<=n; i++){ int x,y; cin>>x>>y; //cout<<x<<vi[x]<<endl; vi[x]+=y; } long long ct=0; for(int i=0; ct<k; i++){ ct+=vi[i]; if(ct>=k){ cout<<i; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:32:5: error: expected initializer before 'cin' 32 | cin>>n>>k; | ^~~ a.cc:42:21: error: 'k' was not declared in this scope 42 | for(int i=0; ct<k; i++){ | ^
s111843402
p03721
C++
#include<iostream> #include<cstdint> #include<map> #include<vector> using namespace std; #define MAX 100000 int main() { int N, a, b; int64_t K; cin >> N >> K; vector<pair<int, int> > add(N); for (int i = 0;i < N;i ++) { cin >> a >> b; add[i] = make_pair(a, b); } sort(add.begin(), add.end()); for (int i = 0;i < N;i ++) { K -= add[i].second; if (K <= 0) { cout << add[i].first; break; } } }
a.cc: In function 'int main()': a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(add.begin(), add.end()); | ^~~~ | short
s436181175
p03721
C++
#include <iostream> #include <vector> using namespace std; int main(int argc, const char * argv[]) { long long n, k; long long a, b; pair<long long, long long> p; vector<pair<long long, long long>> v; long long cnt, ans; cin >> n >> k; for (int i = 0; i < n; i++) { //入力 cin >> a >> b; p.first = a; p.second = b; v.push_back(p); } sort(v.begin(), v.end()); cnt = 0; for (int i = 0; ; i++) { cnt += v[i].second; if (cnt>=k) { ans = v[i].first; break; } } cout << ans << endl; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:23:5: error: 'sort' was not declared in this scope; did you mean 'short'? 23 | sort(v.begin(), v.end()); | ^~~~ | short
s756500953
p03721
C++
#include <string.h> #include <string> #include <vector> #include <deque> #include <list> #include <stack> #include <queue> #include <map> #include <set> #include <iterator> #include <functional> #include <algorithm> #include <numeric> #include <iostream> #include <sstream> #include <iomanip> #include <cmath> #include <cstdlib> #include <cstdio> using namespace std; #define sz(a) int((a).size()) #define all(a) a.begin(), a.end() #define pb push_back #define mp make_pair #define CLR(a) memset((a), 0, sizeof(a)) #define INF (1 << 31) - 1 const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1}; const int dw[8] = {0, 0, 1, -1,1,-1,1,-1}; typedef long long ll; typedef pair<double, double> p; typedef vector <int> VI; typedef vector <string> VS; int main(){ int n, k; cin >> n; cin >> k; VI ans(10001, 0); for(int i = 0; i < n; i++){ int a,b; cin >> a; cin >> b; ans[a] += b; } for(int i = 1; i < 10001; i++){ k -= ans[i]; if(k <= 0){ cout << i << endl; break 0; } } return 0; }
a.cc: In function 'int main()': a.cc:53:12: error: expected ';' before numeric constant 53 | break 0; | ^~ | ;
s360382063
p03721
C++
#include <cstdio> #include <algorithm> #include <iostream> #include <vector> #include <cstring> #include <set> #include <utility> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <string> #include <map> #define ll long long #define read(x) scanf("%d",&x); #define readll(x) cin>>x; #define FOR(x,a,b) for(int x=a;x<b;x++) #define MP make_pair #define PB push_back #define pii pair<int,int> #define piii pair<int,pair<int,int> > #define readN(N,X) for(int i=0;i<N;i++) scanf("%d",&X[i]); using namespace std; ll K; int N; pii kagi[100005]; int main(){ read(N); cin>>k>>endl; FOR(i,0,N){ int a, b; read(a); read(b); kagi[i] = make_pair(a,b); } sort(kagi, kagi + N); for (int i=0;i<N;i++){ K -= kagi[i].second; if (K < 1){ printf("%d\n", kagi[i].first); return 0; } } }
a.cc: In function 'int main()': a.cc:30:14: error: 'k' was not declared in this scope 30 | cin>>k>>endl; | ^
s884353273
p03721
Java
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main { void solve() { int N = sc.nextInt(); long K = sc.nextLong(); int[] a = new int[N]; int[] b = new int[N]; for (int i = 0; i < N; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); } long lo = 0; long hi = 1L << 58; while (hi - lo > 1) { int mi = (hi + lo) / 2; if (f(a, b, mi) < K) lo = mi; else hi = mi; } out.println(hi); } long f(int[] a, int[]b, int x) { long res = 0; for (int i = 0; i < a.length; i++) { if (a[i] <= x) res += b[i]; } return res; } static void tr(Object... os) { System.err.println(deepToString(os)); } static void tr(int[][] as) { for (int[] a : as) tr(a); } void print(int[] a) { out.print(a[0]); for (int i = 1; i < a.length; i++) out.print(" " + a[i]); out.println(); } public static void main(String[] args) throws Exception { new Main().run(); } MyScanner sc = null; PrintWriter out = null; public void run() throws Exception { sc = new MyScanner(System.in); out = new PrintWriter(System.out); for (;sc.hasNext();) { solve(); out.flush(); } out.close(); } class MyScanner { String line; BufferedReader reader; StringTokenizer tokenizer; public MyScanner(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public void eat() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { line = reader.readLine(); if (line == null) { tokenizer = null; return; } tokenizer = new StringTokenizer(line); } catch (IOException e) { throw new RuntimeException(e); } } } public String next() { eat(); return tokenizer.nextToken(); } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public boolean hasNext() { eat(); return (tokenizer != null && tokenizer.hasMoreElements()); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } } }
Main.java:20: error: incompatible types: possible lossy conversion from long to int int mi = (hi + lo) / 2; ^ 1 error
s000574986
p03721
C++
#include <iostream> #include <tuple> #include <string> #include <map> #include <algorithm> #include <list> #include <vector> #include <set> #include <stdio.h> #include <queue> #include <stack> #include <deque> #include <math.h> #include <sstream> #include <stdlib.h> #include <functional> using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define rrep(i,a,n) for(int i = a; i < n; i++) #define INF (1<<29) #define INFL 0x3f3f3f3f3f3f3f3fLL #define MOD 1000000007 #define fi first #define se second #define pb push_back #define PI 3.14159265358979323846 #define all(o) (o).begin(), (o).end() #define rall(x) x.rbegin(),x.rend() typedef double ld; typedef vector<int> vi; typedef vector< vi > vvi; typedef vector<string> vs; typedef vector<char> vc; typedef vector<ld> vd; typedef vector < vc > vvc; typedef long long ll; typedef pair<int, int> pii; typedef unsigned long long int ulli; const int dx[] = { 1, 0, -1, 0 }; const int dy[] = { 0, 1, 0, -1 }; template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } const ld eps = 1e-10, pi = acos(-1.0); #define MAX_N 100001 // combination ll fact[MAX_N], factinv[MAX_N]; ll mod_pow(ll n, ll p, ll m) { ll a = n; ll x = 1; while (p) { if (p & 1) x = (x * a) % m; a = (a * a) % m; p >>= 1; } return x; } int extgcd(int a, int b, int& x, int&y) { int d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } int mod_inverse(int a, int m) { int x, y; extgcd(a, m, x, y); return (m + x % m) % m; } ll inv(ll n) { return mod_pow(n, MOD - 2, MOD); } void combInit() { fact[0] = 1; rrep(i, 1, MAX_N) fact[i] = fact[i - 1] * i % MOD; factinv[MAX_N - 1] = inv(fact[MAX_N - 1]); for (int i = MAX_N - 2; i >= 0; i--) factinv[i] = factinv[i + 1] * (i + 1) % MOD; } // ダイクストラ /* struct edge { int to, cost; }; vector < vector < edge > > G; vi d; void dijkstra(int s) {priority_queue<pii, vector< pii >, greater<pii> > que;d[s] = 0;que.push(pii(0, s));while (!que.empty()) {pii p = que.top(); que.pop();int v = p.second;if (d[v] < p.first) continue;rep(i, G[v].size()) {edge e = G[v][i];int cost = e.cost;if (d[v] + cost < d[e.to]) {d[e.to] = d[v] + e.cost;que.push(pii(d[e.to], e.to));}}}} */ // Union-Find木 int par[MAX_N], rnk[MAX_N], unionSize[MAX_N]; // はじめは全ての頂点が根 void UnionFindTreeInit(int n) { rep(i, n) { par[i] = i; rnk[i] = 0; unionSize[i] = 1; } } //木の根元を求める int root(int x) { if (par[x] == x) return x; // 根を返す else return par[x] = root(par[x]); } // 連結成分の大きさを取得 int componentSize(int x) { return unionSize[root(x)]; } // xとyが同じ集合に属するか否か bool same(int x, int y) { return root(x) == root(y); } // xとyの属する集合を併合 void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; unionSize[y] += unionSize[x]; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; unionSize[x] += unionSize[y]; } } //----------------------------------------------------------------- //int dx[8] = { -1, 1, 0, 0, 1, 1, -1, -1 }; //int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 }; struct edge { int to, cost; }; vector < vector < edge > > G; vi d; void dijkstra(int s) { priority_queue<pii, vector< pii >, greater<pii> > que; d[s] = 0; que.push(pii(0, s)); while (!que.empty()) { pii p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; rep(i, G[v].size()) { edge e = G[v][i]; int cost = e.cost; if (d[v] + cost < d[e.to]) { d[e.to] = d[v] + e.cost; que.push(pii(d[e.to], e.to)); } } } } int main() { ios::sync_with_stdio(0); cin.tie(0); ll n,k; vector < vector < ll > > dh(100005); cin >> n >> k; rep(i,n) { ll a , b; cin >> a >> b; dh[a] += b; } rrep(i, 1, 100001) { dh[i] += dh[i-1]; } cout << lower_bound(all(dh), k) - dh.begin() << endl; return 0; }
a.cc: In function 'int main()': a.cc:182:23: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and 'll' {aka 'long long int'}) 182 | dh[a] += b; a.cc:186:23: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'}) 186 | dh[i] += dh[i-1]; In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<std::vector<long long int>*, std::vector<std::vector<long long int> > >; _Value = const long long int]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<vector<long long int>*, vector<vector<long long int> > >; _Tp = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<vector<long long int>*, vector<vector<long long int> > >; _Tp = long long int]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:189:21: required from here 189 | cout << lower_bound(all(dh), k) - dh.begin() << endl; | ~~~~~~~~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::vector<long long int>' and 'const long long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const std::pair<_T1, _T2>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&,
s242731352
p03721
C++
#include <cstdio> #ifdef _MSC_VER #include <conio.h> #else #define getch() #endif #define LIMIT 100000 #define int long long int int main(){ int Data[LIMIT]={}; int N=0; int K=0; scanf(" %d %d",&N,&K); for(int i=0;i<N;i++){ int TempA=0; int TempB=0; scanf(" %d %d",&TempA,&TempB); Data[TempA-1]+=TempB; } for(int i=0;i<LIMIT;i++){ K-=Data[i]; if(K<=0){ printf("%d\n",i+1); break; } } getch(); }
a.cc:10:23: error: '::main' must return 'int' 10 | #define int long long int | ^~~ a.cc:12:1: note: in expansion of macro 'int' 12 | int main(){ | ^~~
s475643960
p03721
C++
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <tuple> #include <utility> #include <vector> using namespace std; using int64 = int64_t; constexpr int64 MOD = 1000000007; int main() { int N, int64 K; int64 count[100002]; fill(count, count+100002, 0); cin >> N >> K; for (int j = 0; j < N; ++j) { int a, b; cin >> a >> b; count[a] += b; } int64 acc = 0; for (int j = 0; j <= 100000; ++j) { acc += count[j]; if (acc >= K) { cout << j << endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:30:11: error: expected initializer before 'K' 30 | int64 K; | ^ a.cc:33:17: error: 'K' was not declared in this scope 33 | cin >> N >> K; | ^
s792447151
p03721
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int N, K; int num[100001]; memset(num, 0, sizeof(int) * 100001); cin >> N >> K; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; num[a] += b; } long long sum = 0; for (int i = 0; i < 100001; i++) { if (sum < K && K <= sum + num[i]) { printf("%d\n", i); break; } sum += num[i]; } }
a.cc: In function 'int main()': a.cc:10:9: error: 'memset' was not declared in this scope 10 | memset(num, 0, sizeof(int) * 100001); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s136670518
p03721
C
#include<stdio.h> long count[100001]; int main(int argc, char const *argv[]){ long i,n,k,c=0; scanf("%ld %ld",&n,&k); for(i=0;i<n;i++){ scanf("%ld %ld",&a,&b); count[a]+=b; } for(i=1;i<=100000;i++){ c+=count[i]; if(c>=k){ printf("%ld\n",i); break; } } return 0; }
main.c: In function 'main': main.c:7:34: error: 'a' undeclared (first use in this function) 7 | scanf("%ld %ld",&a,&b); | ^ main.c:7:34: note: each undeclared identifier is reported only once for each function it appears in main.c:7:37: error: 'b' undeclared (first use in this function) 7 | scanf("%ld %ld",&a,&b); | ^
s452214079
p03721
C
#include<stdio.h> long count[100001]; int main(int argc, char const *argv[]){ long i,n,k,c=0; scanf("%ld %ld",&n,&k); for(i=0;i<n;i++){ scanf("%ld %ld",a,b); count[a]+=b; } for(i=1;i<=100000;i++){ c+=count[i]; if(c>=k){ printf("%ld\n",i); break; } } return 0; }
main.c: In function 'main': main.c:7:33: error: 'a' undeclared (first use in this function) 7 | scanf("%ld %ld",a,b); | ^ main.c:7:33: note: each undeclared identifier is reported only once for each function it appears in main.c:7:35: error: 'b' undeclared (first use in this function) 7 | scanf("%ld %ld",a,b); | ^
s380736436
p03721
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> P; signed main(){ int n; cin>>n; P p[n]; for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second; int k; cin>>k; sort(p.begin(),p.end()); for(int i=0;i<n;i++){ if(k>p[i].second) k-=p[i].second; else{ cout<<p[i].first<<endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:12:10: error: request for member 'begin' in 'p', which is of non-class type 'P [n]' {aka 'std::pair<long long int, long long int> [n]'} 12 | sort(p.begin(),p.end()); | ^~~~~ a.cc:12:20: error: request for member 'end' in 'p', which is of non-class type 'P [n]' {aka 'std::pair<long long int, long long int> [n]'} 12 | sort(p.begin(),p.end()); | ^~~
s192843452
p03721
C++
#include <iostream> #include <fstream> #include <cassert> #include <typeinfo> #include <vector> #include <stack> #include <cmath> #include <set> #include <map> #include <string> #include <algorithm> #include <cstdio> #include <queue> #include <iomanip> #include <cctype> #include <random> #define syosu(x) fixed<<setprecision(x) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; typedef pair<double,double> pdd; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<P,int> pip; typedef vector<pip> vip; const int inf=1<<29; const ll INF=1ll<<60; const double pi=acos(-1); const double eps=1e-8; const ll mod=1e9+7; const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; ll n,k; int main(){ cin>>n>>k; ll res for(int i=0;i<n;i++){ ll A,B; cin>>A>>B; k-=B; if(k<=0){ res=A; break; } } cout<<res<<endl; }
a.cc: In function 'int main()': a.cc:52:9: error: expected initializer before 'for' 52 | for(int i=0;i<n;i++){ | ^~~ a.cc:52:21: error: 'i' was not declared in this scope; did you mean 'vi'? 52 | for(int i=0;i<n;i++){ | ^ | vi a.cc:61:15: error: 'res' was not declared in this scope 61 | cout<<res<<endl; | ^~~
s107150896
p03722
Java
import java.util.*; import java.io.*; public class Main{ private static final int mod =(int)1e9+7; public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int n=sc.nextInt(); long m=sc.nextLong(); pair []aa=new pair[m]; for(int i=0;i<m;i++) { int x=sc.nextInt()-1; int y=sc.nextInt()-1; long c=sc.nextLong(); c=-1l*c; pair p=new pair(x,y,c); aa[i]=p; } long dis[]=new long[n]; Arrays.fill(dis,Long.MAX_VALUE); dis[0]=0; for(int i=0;i<n-1;i++) { for(int j=0;j<m;j++) { int src=aa[j].src; int des=aa[j].des; long wt=aa[j].val; if(dis[des]>dis[src]+wt) { dis[des]=dis[src]+wt; } } } boolean negative=false; for(int j=0;j<m;j++) { int src=aa[j].src; int des=aa[j].des; long wt=aa[j].val; if(dis[des]!=Long.MAX_VALUE&&dis[des]>dis[src]+wt) { dis[des]=dis[src]+wt; negative=true; break; } } System.out.println(negative==true?"inf":-dis[n-1]); } static long gcd(long a, long b) { if (a == 0) return b; return gcd(b % a, a); } static long nCr(int n,int r) { int dp[][]=new int[2001][2001]; for(int i=0;i<2001;i++) { dp[0][i]=0; } for(int i=0;i<2001;i++) { dp[i][0]=1; } for(int i=1;i<2001;i++) { for(int j=1;j<2001;j++) { if(i==j) { dp[i][j]=1; }else { dp[i][j]=dp[i-1][j-1]+dp[i][j-1]; } } } return dp[n][r]; } } class pair { int src; int des; long val; pair(int src,int des,long val){ this.src=src; this.des=des; this.val=val; } // @Override // public int compareTo(pair o) { // // return this.wt-o.wt; // } }
Main.java:12: error: incompatible types: possible lossy conversion from long to int pair []aa=new pair[m]; ^ 1 error
s530632780
p03722
C++
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i < (n+1); ++i) const double PI =3.141592653589793238463; using namespace std; using ll = long long; const ll INF = +10010010000; typedef pair<int,int> P; const int mod = 1e9+7; struct mint{ ll x; mint(ll x=0):x((x%mod+mod)%mod){} mint& operator+=(const mint a){ (x+=a.x)%=mod; return *this; } mint& operator-=(const mint a){ (x-=mod-a.x)%=mod; return *this; } mint& operator*=(const mint a){ (x *= a.x)%= mod; return *this; } mint operator+(const mint a)const{ mint res(*this); return res+=a; } mint operator-(const mint a)const{ mint res(*this); return res-=a; } mint operator*(const mint a)const{ mint res(*this); return res*=a; } mint pow(ll t) const { if(!t)return 1; mint a = pow(t>>1); a*=a; if(t%1)a*=*this; return a; } // for prime mod mint inv() const { return pow(mod-2); } mint& operator/=(const mint a){ return (*this) *= a.inv(); } mint operator/(const mint a)const{ mint res(*this); return res/=a; } }; struct combination{ vector<mint> fact, ifact; combination(int n):fact(n+1),ifact(n+1){ fact[0] = 1; for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i; ifact[n] = fact[n].inv(); for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i; } mint operator()(int n, int k){ if(k<0 || k>n)return 0; return fact[n] * ifact[k] + ifact[n-k]; } }; const int NMAX = 1000; const int MMAX = 2000; int a[MMAX], b[MMAX]; ll c[MMAX]; ll dist[NMAX]; const ll INF = 1LL << 50; int main(){ int n,m; cin >> n>> m; rep(i,m){ cin>>a[i]>>b[i]>>c[i]; a[i]--;b[i]--; c[i]*=-1; } rep(i,n)dist[i]=INF; dist[0] = 0; // this upper loop is to make while loop rep(loop,n-1){ // this loop actually check all given data rep(i,m){ // this means, so far, any data arrived to this ball if(dist[a[i]]==INF)continue; if(dist[b[i]] > dist[a[i]]+c[i]){ dist[b[i]] =dist[a[i]]+c[i]; } } } ll ans = dist[n-1]; // check whether close or not /* if closed, loops decrease the value of ans. So how to decide the number of loops required? The link bellow articulate it and it says, 1 loop with updating the value to -inf; http://sigma1113.hatenablog.com/entry/2019/08/12/130042 */ bool neg[NMAX]; rep(i,n)neg[i]=false; rep(loop,n){ // this loop actually check all given data rep(i,m){ // this means, so far, any data arrived to this ball if(dist[a[i]]==INF)continue; if(dist[b[i]] > dist[a[i]]+c[i]){ dist[b[i]] = dist[a[i]]+c[i]; neg[b[i]] = true; } if(neg[a[i]])neg[b[i]]=true; } } if(neg[n-1])cout<<"inf"<<endl; else cout << -ans << endl; return 0; } // int n,m; // int const MAX_N = 1000; // struct edge{ll from,to,cost; }; // vector<edge> G[MAX_N]; // // vector<edge> G; // ll d[MAX_N]; // void bfs(){ // queue<edge> q; // q.push(edge{0,0,0}); // while(!q.empty()){ // edge st = q.front() ;q.pop(); // bool update = false; // // check st's to prop // for(int i=0;i<G[st.from].size();i++){ // edge ds = G[st.from][i]; // // printf("from:%d, to:%d, d:%d\n",st.to,ds.to,d[st.to]+ds.cost); // // printf("%d, %d\n",d[st.to],ds.cost); // if(d[st.to]+ds.cost < d[ds.to]){ // printf("from:%d, to:%d, d:%d\n",i,ds.to,d[st.to]+ds.cost); // d[ds.to] = d[st.to]+ds.cost; // printf("%d, %d\n",d[st.to],ds.cost); // update = true; // q.push(ds); // } // } // if(!update){ // break; // } // } // } // int main(){ // // init // cin >> n >> m; // rep(i,m){ // ll a,b,c; // cin >> a >> b >> c; // a--;b--; // G[a].push_back(edge{a,b,-1*c}); // // G.push_back(edge{a,b,-1*c}); // } // rep(i,m)d[i]=INF; // d[0] = 0; // bfs(); // cout << d[n-1]<<endl; // return 0; // }
a.cc:79:10: error: redefinition of 'const ll INF' 79 | const ll INF = 1LL << 50; | ^~~ a.cc:8:10: note: 'const ll INF' previously defined here 8 | const ll INF = +10010010000; | ^~~
s233453241
p03722
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pop() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(),a.end()),a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int,vector<int>,greater<int>> #define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(),(a).end() #define elif else if int low(V<int> &a,int b){ auto c=lower_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } int upp(V<int> &a,int b){ auto c=upper_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int gcm(int a,int b){ if(a%b==0) return b; return gcm(b,a%b); } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; for(int i=3;i<=sqrt(a)+1;i+=2){ if (a%i==0) return false; } return true; } struct Union{ vector<int> par; Union(int a){ par=vector<int>(a,-1); } int find(int a){ if(par[a]<0) return a; else return par[a]=find(par[a]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } bool fe(int a,int b){ a%=10; b%=10; if(a==0) a=10; if(b==0) b=10; if(a>b) return true; else return false; } int INF=1000000007; struct edge{int s,t,d; }; V<int> mojisyu(string a){ V<int> b(26,0); fo(i,a.sz){ b[a[i]-'a']++; } return b; } int wa2(int a){ if(a%2==1) return a/2; return a/2-1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n,int r){ int a=1; r=min(r,n-r); for(int i=n;i>n-r;i--){ a*=i; a/=n-i+1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a){ int b=1; fo(i,a) b*=i+1; return b; } int nPr(int a,int b){ if(a<b) return 0; if(b==0) return 1; int c=1; for(int i=a;i>a-b;i--){ c*=i; c%=INF; } return c; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } int lcm(int a,int b){ int c=modinv(gcm(a,b),INF); return ((a*c)%INF)*(b%INF)%INF; } int MOD=INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 //先にCOMinit()で前処理をする //ABC145D void COMinit() { fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i<1000010;i++){ fac[i]=fac[i-1]*i%MOD; inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; finv[i]=finv[i-1]*inv[i]%MOD; } } // 二項係数計算 int COM(int n,int k){ if(n<k) return 0; if(n<0||k<0) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } bool naka(int a,int b,V<V<char>> c){ return (a>=0&&b>=0&&a<c.sz&&b<c[0].sz); } V<P<int,int>> mawari8={{0,-1},{0,1},{1,0},{-1,0},{-1,-1},{1,1},{1,-1},{-1,-1}}; int inf=1000000000000000007; V<P<int,int>> mawari4={{0,-1},{0,1},{1,0},{-1,0}}; //最短経路の表 a(全部INFで初期化) //縦横 x,y //迷路 f //スタートsx,sy //ゴールgx,gy //文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a){ V<int> b(a.sz); for(int i=1,j=0;i<a.sz;i++){ if(i+b[i-j]<j+b[j]) b[i]=b[i-j]; else{ int c=max<int>(0,j+b[j]-i); while(i+c<a.sz&&a[c]==a[i+c]) c++; b[i]=c; j=i; } } b[0]=a.sz; return b; } //各頂点ごとにどこに辺が出てるかの表がc //各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する //aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ V<int> color(200005); bool nibu_hantei(int a,int b,V<V<int>> c){ color[a]=b; fo(i,c[a].sz){ if(b==color[c[a][i]]) return false; if(color[c[a][i]]==0&&!nibu_hantei(c[a][i],-b,c)) return false; } return true; } //aは頂点数 //nibu_hanteiの上にcolorを用意する //各頂点ごとにどこに辺が出てるかの表がc bool renketujanai_nibu_hantei(int a,V<V<int>> c){ fo(i,a){ if(color[i]==0){ if(!nibu_hantei(i,1,c)) return false; } } return true; } struct segmin{ vector<int> seg; int b; segmin(V<int> a){ b=1; while(b<a.sz) b*=2; seg=vector<int>(2*b-1,inf); fo(i,a.sz){ seg[i+b-1]=a[i]; } for(int i=b-2;i>=0;i--){ seg[i]=min(seg[2*i+1],seg[2*i+2]); } } void update(int i,int a){ i+=b-1; seg[i]=a; while(i){ i=(i-1)/2; seg[i]=min(seg[2*i+1],seg[2*i+2]); } } //最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで //l,rは探すところ int getmin(int x,int y,int a,int l,int r){ if(r==INF) r=b; if(r<=x||y<=l) return INF; if(x<=l&&r<=y) return seg[a]; int a1=getmin(x,y,2*a+1,l,(l+r)/2); int a2=getmin(x,y,2*a+2,(l+r)/2,r); return min(a1,a2); } }; struct segadd{ vector<int> seg; int b; segadd(V<int> a){ b=1; while(b<a.sz) b*=2; seg=vector<int>(2*b-1,0); fo(i,a.sz){ seg[i+b-1]=a[i]; } for(int i=b-2;i>=0;i--){ seg[i]=seg[2*i+1]+seg[2*i+2]; } } void update(int i,int a){ i+=b-1; seg[i]=a; while(i){ i=(i-1)/2; seg[i]=seg[2*i+1]+seg[2*i+2]; } } //最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで //l,rは探すところ int getadd(int x,int y,int a,int l,int r){ if(r==INF) r=b; if(r<=x||y<=l) return 0; if(x<=l&&r<=y) return seg[a]; int a1=getadd(x,y,2*a+1,l,(l+r)/2); int a2=getadd(x,y,2*a+2,(l+r)/2,r); return a1+a2; } }; struct sege{ vector<P<int,V<int>>> seg; int b; sege(string a){ b=1; while(b<a.sz) b*=2; seg=vector<P<int,V<int>>>(2*b-1); fo(i,a.sz){ seg[i+b-1].fi=1; seg[i+b-1].se.pb(a[i]-'a'); } for(int i=b-2;i>=0;i--){ V<int> d=seg[2*i+1].se; fo(j,seg[2*i+2].se.sz){ d.pb(seg[2*i+2].se[j]); } Sort(d); uni(d); seg[i].se=d; seg[i].fi=d.sz; } } V<int> mu; void update(int i,char a){ i+=b-1; seg[i].se=mu; seg[i].se.pb(a-'a'); seg[i].fi=1; while(i){ i=(i-1)/2; V<int> d=seg[2*i+1].se; fo(j,seg[2*i+2].se.sz){ d.pb(seg[2*i+2].se[j]); } Sort(d); uni(d); seg[i].se=d; seg[i].fi=d.sz; } } void unko(){ fo(i,2*b-1) cout<<seg[i].fi<<' '; } //最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで //l,rは探すところ P<int,V<int>> gete(int x,int y,int a,int l,int r){ if(r==INF) r=b; if(r<=x||y<=l) return {0,mu}; if(x<=l&&r<=y) return seg[a]; P<int,V<int>> a1=gete(x,y,2*a+1,l,(l+r)/2); P<int,V<int>> a2=gete(x,y,2*a+2,(l+r)/2,r); fo(i,a2.se.sz) a1.se.pb(a2.se[i]); Sort(a1.se); uni(a1.se); return {a1.se.sz,a1.se}; } };/* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ //aのb乗mod c int kurikaesijijou(int a,int b,int c){ a%=c; b%=c; if(b==0) return 1; if(b%2==0){ int d=kurikaesijijou(a,b/2,c); d%=c; return d*d%c; } return a*kurikaesijijou(a,b-1,c)%c; } int waINF(int a){ if(a>=0) return a%INF; return (a+INF*INF)%INF; } /*void soinsuu_init(int a){ }*/ int a,b,c; int e=0; V<V<int>> g(50,V<int>(4)); void unko(V<int> d){ if(d.sz==a){ int f=0; fo(i,c){ f+=g[i][3]*((d[g[i][1]-1]-d[g[i][0]-1]==g[i][2])); } e=max(e,f); } if(d.sz){ for(int i=d[d.sz-1];i<=b;i++){ d.pb(i); unko(d); d.pop(); } } else{ fo(i,b){ d.pb(i+1); unko(d); d.pop(); } } } //aは辺のvector,bは最短距離の表 bool find_negative_roop(V<P<P<int,int>,int>> &a,V<int> &b){ fo(i,b.sz){ fo(j,a.sz){ P<P<int,int>,int> c=b[j]; if(b[c.fs]>b[c.ff]+c.se){ b[c.fs]=b[c.ff]+c.se; if(i==b.sz-1) return 1; } } } return 0; } signed main(){ int a,b; cin>>a>>b; V<P<P<int,int>,int>> c(b); fo(i,b){ cin>>c[i].ff>>c[i].fs>>c[i].se; } V<int> d(a); if(find_negative_roop(c,d)){ cout<<"inf"<<endl; return 0; } fo(i,a) d[i]=inf; d[0]=0; while(1){ int e=1; fo(i,b){ P<P<int,int>,int> f=c[i]; if(d[f.fs]>d[f.ff]+f.se){ e=0; d[f.fs]=d[f.ff]+f.se; } } if(e) break; } cout<<d[a-1]<<endl; }
a.cc: In function 'bool find_negative_roop(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >&, std::vector<long long int>&)': a.cc:559:30: error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to non-scalar type 'std::pair<std::pair<long long int, long long int>, long long int>' requested 559 | P<P<int,int>,int> c=b[j]; | ^
s665944583
p03722
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) typedef pair<int,int> P; typedef long long ll; const int INF = 1001001001; const ll INFL = 1e17; const int MOD = 1e9+7; struct edge{ll from,to,cost;}; vector<bool> negative(1010,false); bool Bellman_Ford(int s, int V, vector<ll>& dist, vector<edge>& G){ fill(dist.begin(),dist.end(),INFL); dist[s] = 0; for(int loop = 0; loop < V*2; loop++){ bool update = false; for(int i=0; i<int(G.size()); i++){ edge e = G[i]; if(dist[e.from] != INFL && dist[e.to] > dist[e.from] + e.cost){ dist[e.to] = dist[e.from] + e.cost; update = true; if(loop >= V){ negative[e.to] = true; } if(loop == 2*v-1){ return true; } } } if(!update) break; } return false; } int main(){ int V,E; cin >> V >> E; vector<ll> dist(V); vector<edge> G; rep(i,E){ int a,b,c; cin >> a >> b >> c; --a; --b; c = -c; G.push_back(edge{a,b,c}); } if(Bellman_Ford(0,V,dist,G)){ cout << "inf" << endl; }else{ cout << -dist[V-1] << endl; } return 0; }
a.cc: In function 'bool Bellman_Ford(int, int, std::vector<long long int>&, std::vector<edge>&)': a.cc:26:30: error: 'v' was not declared in this scope 26 | if(loop == 2*v-1){ | ^