source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
exec_outcome
stringclasses
1 value
#include <iostream> using namespace std; #define ll long long #define ld long double int main() { ll n; cin>>n; ll count = 1; ll xs=0,ys=0; while(n--) { ll a,b; cin>>a>>b; ll temp = 0; count += max(temp,min(a,b)-max(xs,ys)+(xs!=ys)); xs = a; ys = b; } cout<<count<<endl; }
C++
5b84295330fa07a9b42570766012990b
123a6f2e75480f91ce9b0f3a201f8809
1,400
PASSED
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <math.h> #include <queue> #include <string> #include <string.h> #include <map> #include <vector> #include <fstream> using namespace std; #define N 301022 #define M 1001000 //#define MAXN 1125899906842624L #define MAXVAL 1e15L #defi...
C++
5b84295330fa07a9b42570766012990b
1edbe376f56a3dfdc3d38073951ed2b5
1,400
PASSED
#include<iostream> #include<algorithm> using namespace std; int main() { int scoreboard; int drow = 0; int rr = 0, q1 = 0, q2 = 0, q3 = 0, w = -1, r = -1, a = 0, c = 0; cin >> scoreboard; for (int i = 0; i < scoreboard; i++) { a = w; c = r; cin >> w >> r; drow += std::max(0, std::min(w, ...
C++
5b84295330fa07a9b42570766012990b
e8cfcb744149e28a06a0345cbcefca5e
1,400
PASSED
#include<iostream> #include<algorithm> using namespace std; int main() { int scoreboard; int drow = 0; int rr = 0, q1 = 0, q2 = 0, q3 = 0, w = -1, r = -1, a = 0, c = 0; cin >> scoreboard; for (int i = 0; i < scoreboard; i++) { a = w; c = r; cin >> w >> r; drow += std::max(0, std::min(w, ...
C++
5b84295330fa07a9b42570766012990b
5f97946260a9c33aeee62b84d731e103
1,400
PASSED
#include<iostream> #include<algorithm> using namespace std; int main() { int n; long long x,y,a,b; int num=1; cin>>n; cin>>a>>b; n--; num=num+min(a,b); for(int i=0;i<n;i++) { cin>>x>>y; if(b<a&&y>=a) { num+=min(x,y)-a+1; /* if(x>y) ...
C++
5b84295330fa07a9b42570766012990b
34ad3454f1129dcface664d036a3468a
1,400
PASSED
def main(): n = int(input()) a1, b1 = 0, 0 ans = 1 for i in range(n): a2, b2 = map(int, input().split()) if a2 == a1 and b2 == b1: continue ans += max(0, min(a2, b2) - max(a1, b1) + 1) if a1 == b1: ans -= 1 a1 = a2 b1 = b2 print...
Python
5b84295330fa07a9b42570766012990b
f9aa930988e75e8042681043b661ff8d
1,400
PASSED
def func(x,y,newx,newy): sma=min(x,y) big=max(x,y) ns=min(newx,newy) nb=max(newx,newy) if ns<big: return 0 if ns<nb: return ns-big+1 return nb-big+1 def main(): count=int(input()) x=0 y=0 tie=1 for _ in range(count): test=input().split...
Python
5b84295330fa07a9b42570766012990b
e64c074751132386a98874d193d475d6
1,400
PASSED
n = int(input()) scores = [[0,0]] for i in range(n): tm = [int(_) for _ in input().split(' ')] scores.append(tm) a,b=0,0 res = 1 for i in range(1,n+1): res += max(0, min(scores[i]) - max(a,b)+1) if a == b: res -= 1 a,b=scores[i] print(res)
Python
5b84295330fa07a9b42570766012990b
5d9dc7e161e60fa3685c4027873c6be8
1,400
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 200002; const ll INF = 999999999999; ll n, k, ans = 0, arr[MAX_N]; ll cost[MAX_N], buf = 0; int main() { cin >> n >> k; for(int i = 0; i < n; i++) cin >> arr[i]; arr[n] = INF; sort(arr, arr + n, greater<int>())...
C++
676729309dfbdf4c9d9d7c457a129608
28d9c816b515ef38f2eb7b0bcc53c5a3
1,600
PASSED
#include<bits/stdc++.h> using namespace std; #define lli long long int int main() { lli n,k,i,max=INT_MIN,min=INT_MAX; cin>>n>>k; vector<lli> h(n); vector<lli> temp(n); for(i=0;i<n;++i) { cin>>h[i]; temp[i]=h[i]; if(h[i]>max) max=h[i]; if(h[i]<min) min=h[i]; }...
C++
676729309dfbdf4c9d9d7c457a129608
f523765b932736b98591419fd1295a37
1,600
PASSED
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <string> #include <stdio.h> #include <algorithm> #include <set> #include <map> #include <math.h> #include <cmath> #include <queue> #include <iomanip> #include <bitset> #include <unordered_map> #include <stack> #include <memory.h> #define ll...
C++
676729309dfbdf4c9d9d7c457a129608
912850dc7bf5bc9c77fe177901b7fb9c
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int const maxn = 2e5 + 10; int n, k, h[maxn]; int main() { scanf("%d%d", &n, &k); for(int i = 0; i < n; i++) scanf("%d", &h[i]); int sum = 0, ans = 0; sort(h, h+n); for(int i = maxn; i >= 0; i--) { int s = n - (lower_bound(h, h+n, i) - h); if(s == n) ...
C++
676729309dfbdf4c9d9d7c457a129608
a638f7630f92beb2f6ca95cbd54b7da3
1,600
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long int Int; int const maxn = 2e5 + 10; Int n, cnt[maxn], a[maxn]; Int k, h[maxn], pre[maxn]; set<Int> S; int main() { scanf("%lld%lld", &n, &k); Int maxi = 0, mini = maxn; for(int i = 1; i <= n; i++) { scanf("%lld", &h[i]); cnt[h[i]]++; ...
C++
676729309dfbdf4c9d9d7c457a129608
00107da8744b6732f29f3a5216fd145b
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int const maxh = 2e5 + 10; int n, k, s[maxh]; int main() { scanf("%d%d", &n, &k); int h; for(int i = 0; i < n; i++) scanf("%d", &h), s[h]++; for(int i = maxh-1; i >= 1; i--) s[i-1] += s[i]; int sum = 0, ans = 0; for(int i = maxh-1; i >= 1; i--) { if(s[i...
C++
676729309dfbdf4c9d9d7c457a129608
23521e86b2e39941b276188c43aabfaf
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int const maxh = 2e5 + 10; int n, k, s[maxh]; int main() { scanf("%d%d", &n, &k); int h; for(int i = 1; i <= n; i++) { scanf("%d", &h); s[h]++; } for(int i = maxh-1; i >= 1; i--) s[i-1] += s[i]; int sum = 0, ans = 0; for(int i = maxh-1; i >= 1; i...
C++
676729309dfbdf4c9d9d7c457a129608
2539d70a838beefef5e4dfbfd0419e7f
1,600
PASSED
#include <bits/stdc++.h> using namespace std; long long int t, n, m, l, da[300000]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> da[i]; } sort(da, da + n); reverse(da, da + n); long long int sum = 0, last = 0, maxx = da[0], ans = 0, minn = da[0]; for (int i = 0; ...
C++
676729309dfbdf4c9d9d7c457a129608
4ae5f4595c0ae8c809de26dca7cfcf7c
1,600
PASSED
#include <bits/stdc++.h> using namespace std; #define F first #define S second typedef long long ll; typedef long double ld; typedef pair <int,int> ii; const int N=200100; ll n,k,cum[N],mx,mn=1e9,curr,ans,pos=-1; int main() { scanf("%lld%lld",&n,&k); for(int i=0;i<n;i++) { ll x; scanf("%...
C++
676729309dfbdf4c9d9d7c457a129608
bab62334b8af15501496b75f68e8b204
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define MP make_pair #define pb push_back #define all(v) v.begin(),v.end() #define forr(i,a,b) for(int i=a;i<=b;i++) #define sz size() #define inp ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std ; const int N = 2e5+9 ,...
C++
676729309dfbdf4c9d9d7c457a129608
8b8a248fff6440e1d180e47f7e9c2ba6
1,600
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author ca...
Java
3d4df21eebf32ce15841179bb85e6f2f
cdee7c9b59d8fa3dc3239f6c28c018ca
1,400
PASSED
import java.util.*; import java.io.*; public class coloring{ public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); Scanner scan = new Scanner(System.in); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.o...
Java
3d4df21eebf32ce15841179bb85e6f2f
7b82eb711cb5d8f6c05765177fe843ed
1,400
PASSED
import java.util.*; import java.io.*; //import javafx.util.Pair; public class Solution implements Runnable { class Pair implements Comparable <Pair> { long x,y; Pair(long x,long y) { this.x=x; this.y=y; } public int compareTo(Pair p) ...
Java
3d4df21eebf32ce15841179bb85e6f2f
9f142c1df55c0cc9dfc5f5623852a509
1,400
PASSED
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(), k = scan.nextInt(); int[] arr = new int[5001];Arrays.fill(arr, 0); Integer[][] arr1 = new Integer[n][2...
Java
3d4df21eebf32ce15841179bb85e6f2f
49b7af0fb791834c1d4071765819ebd5
1,400
PASSED
import java.util.*; import java.io.*; public class Main { public static void solve(InputReader in ) { int n = in.readInt(), k = in.readInt(); int a[] = new int[n]; int ans[] = new int[n]; int cnt[] = new int[50001]; for(int i = 0; i<n; i++) a[i] = in.readInt(); int Max = 0; for(int i =...
Java
3d4df21eebf32ce15841179bb85e6f2f
90498ab01bf5b0b099f42fa6a666c28c
1,400
PASSED
import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; import java.util.Set; public class ArrayKcoloring1102_B { public static void main(String[] args) { Scanner s=new Scanner (System.in); int n=s.nextInt(); int k=s.nextInt(); int[] array=new int[n]; HashMap<Integer,ArrayList<Inte...
Java
3d4df21eebf32ce15841179bb85e6f2f
a89ee530701578e0604524efb52b01fa
1,400
PASSED
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int k = scn.nextInt(); int a[] = new int[n]; HashMap<Integer, Integer> hm = new HashMap<>(); for (int i = 0; i < n; i++) { a[i...
Java
3d4df21eebf32ce15841179bb85e6f2f
55706d058c74c6975879b605ebf28fae
1,400
PASSED
//package com.company; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner s=new Scanner(...
Java
3d4df21eebf32ce15841179bb85e6f2f
ee4e1ce47846927a43c2e3216b5a0a41
1,400
PASSED
import java.util.*; public class Eighteen { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int k=s.nextInt(); int flag; int input[][]=new int[n][2]; for(int i=0;i<n;i++){ input[i][0]=s.nextInt(); } for(int i=1;i<=k;i++){ input[i-1][1]=i; } for(in...
Java
3d4df21eebf32ce15841179bb85e6f2f
eb26849f523a64d369c35a4881493961
1,400
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Arrays; import java.util.Map; import java.util.Scanner; import java.util.HashMap; import java.util.Comparator; import java.util.ArrayList; /** * Built using CHelper ...
Java
3d4df21eebf32ce15841179bb85e6f2f
5917298db70b107a7237feab7d9244ea
1,400
PASSED
#include<bits/stdc++.h> using namespace std; int main() { //char str[1000]; int k,count; string str; cin>>str; cin>>k; int value=str.length(); int cnt=0; for(int i=97;i<123;i++) { count=0; for(int j=0;j<value;j++) { if(str[j]==i) count++; } if(count>0) cnt++; } if(k>value)...
C++
bd5912fe2c5c37658f28f6b159b39645
f437f9aa77e221531a794a8c94845c6d
1,000
PASSED
#include<iostream> #include<stack> #include<cstdio> #include<queue> #include<cstring> using namespace std; int main() { string s; int n; int a[200]; while(cin >> s >> n){ int ck = 0; memset(a, 0, sizeof(a)); if(s.length() < n){ cout << "impossible" << endl; }...
C++
bd5912fe2c5c37658f28f6b159b39645
222054ab02bcf06a3d7d889a9cbff76a
1,000
PASSED
#include<iostream> #include<vector> #include<cstdio> #include<queue> #include<cstring> using namespace std; int main() { string s; int n; while(cin >> s >> n){ int ck = 0; vector <int> a(200); if(s.length() < n){ cout << "impossible" << endl; } else{ ...
C++
bd5912fe2c5c37658f28f6b159b39645
a50eaac4fac8d10f395295e3c77230a0
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int a[26]; int main() { int l; string s; getline(cin,s); cin>>l; int ln = s.length(); int sum=0,sm=0; if(l>ln) cout<<"impossible"<<endl; else{ for(int i=0; i<s.length(); i++){ ++a[s[i]-'a']; if(a[s[i]-'a...
C++
bd5912fe2c5c37658f28f6b159b39645
b6bd550f602ce9b6b08bc89e91ab45ef
1,000
PASSED
#include<iostream> #include<vector> #include<cstdio> #include<queue> #include<cstring> using namespace std; int main() { string s; int n; while(cin >> s >> n){ int ck = 0; vector <int> a(200, 0); if(s.length() < n){ cout << "impossible" << endl; } else{ ...
C++
bd5912fe2c5c37658f28f6b159b39645
cc43c8e4fa28e865eba0dbc1a98d11b4
1,000
PASSED
#include<iostream> #include<vector> #include<cstdio> #include<queue> #include<cstring> using namespace std; int main() { string s; int n; while(cin >> s >> n){ int ck = 0; vector <int> a(200, 0); if(s.length() < n){ cout << "impossible" << endl; } else{ ...
C++
bd5912fe2c5c37658f28f6b159b39645
2893a0452554fb5b04acb63b87cb97ef
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int a[1000]; int main() { int l; string s; getline(cin,s); cin>>l; int ln = s.length(); int sum=0,sm=0; if(l>ln) cout<<"impossible"<<endl; else{ for(int i=0; i<s.length(); i++){ ++a[s[i]]; if(a[s[i]]==1)...
C++
bd5912fe2c5c37658f28f6b159b39645
254acf89519b4c0cdf22c5034f50c8af
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); string s;cin>>s; int k;cin>>k; int *c = new int[26]; for(int i=0;i<26;i++)c[i]=0; int ans=0; if(s.size()<k)return cout<<"impossible",0; for(int i=0;i<s.size();i++){ if(c...
C++
bd5912fe2c5c37658f28f6b159b39645
5c145c715bedf5686037bf55766cb8c4
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int hash[26]={0}; int k; cin>>k; set<char>str; for(int i=0;i<s.length();i++) { hash[s[i]-'a']++; str.insert(s[i]); } int sum=0; int ct=0; for(int j=0;j<26;j++) { if (hash[j]>0) ct++; sum+=hash[j]; } if(s.length()<k) {...
C++
bd5912fe2c5c37658f28f6b159b39645
f76f691b0bc210e97370a024da7d3237
1,000
PASSED
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { string s; int n,coun=0,c1; cin>>s>>n; set<char>st; for(int i=0; i<s.size(); i++) st.insert(s[i]); if(st.size()<n) { coun=st.size(); c1=coun; st.clear(); for(int i=0; i<s.s...
C++
bd5912fe2c5c37658f28f6b159b39645
aba1d58f61284be6ed96e76fadf52e3e
1,000
PASSED
//#include "stdafx.h" #include <stdio.h> #define nmax 110 #define mmax 2010 int n, m, i, j, h, k, v, mn, kreb, vv, tt; int a[mmax]; int head[nmax], kol[nmax], time[nmax], up[nmax], p[nmax]; bool ok[mmax * 2]; int b[mmax * 2], e[mmax * 2], next[mmax * 2], prev[mmax * 2], obr[mmax * 2]; void addreb(int x, int y) { kol[...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
8bc307417f1b7112abf9f2c245cb3cef
2,300
PASSED
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cstdlib> #include <ctime> #include <string> #include <cmath> #include <climits> #include <vector> #include <map> #include <set> #include <iterator> #include <utility> #include <numeric> #include <memory> #include <stack> #include <d...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
dbe3f9f7281bf128990752eb10a9a9ae
2,300
PASSED
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cstdlib> #include <ctime> #include <string> #include <cmath> #include <climits> #include <vector> #include <map> #include <set> #include <iterator> #include <utility> #include <numeric> #include <memory> #include <stack> #include <d...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
2c0e77f8a8a8c38721bbbc0674bc5eae
2,300
PASSED
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <functional> #include <numeric> #include <vector> using namespace std; const int MAXN = 2507; struct Edge { int u,f,v; Edge() {} Edge(int u,int f,int v):u(u),f(f),v(v) {} }; int p[MAXN] = {0}; vector < int > adj[107]; boo...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
d916904b7e71a1cdfcee0d63896613ae
2,300
PASSED
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <functional> #include <numeric> #include <vector> using namespace std; const int MAXN = 2507; struct Edge { int u,f,v; Edge() {} Edge(int u,int f,int v):u(u),f(f),v(v) {} }; int p[MAXN*2] = {0}; vector < int > adj[MAXN]; ...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
ad2254d123f097e647e46c0d9b32b061
2,300
PASSED
#include<cstdio> #define For(i,x,y) for(int i=(int)x,_y=y;i<=_y;i++) const int N=100+10,M=2000+10; int ans[M],p[M],n,m; bool e[N][N]; void addedge(int u,int v){e[u][v]=e[v][u]=1;} bool dfs(int u,int dep,bool flag) { ans[dep]=u; if(dep==m)return flag; int v=flag?1:p[dep+1]; For(i,v,n)if(e[u][i]) { e[u][i]=e[i][u]...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
7c095d5e73a3efe7fee4176cba2d7ad6
2,300
PASSED
#include <vector> #include <list> #include <map> #include <set> #include <queue> #include <algorithm> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> using namespace std; #define f(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) f(i, 0, n) int n,...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
7b741c394a0a6ea8abaec902f31ce138
2,300
PASSED
/* * D. Wormhouse.cpp * * Created on: 2011-2-26 * Author: user */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cassert> using namespace std; const int MAX_N=100+10; const int MAX_M=3000; int ord[MAX_M]; struct Edge{ int src,dst; Edge(int _src,int _dst): src(...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
576ecbcb6c12b7ec6c160fcbee4a0ec0
2,300
PASSED
#include <iostream> #include <algorithm> #include <vector> #include <cstring> #include <cstdio> using namespace std; #define maxn 2010 int n, m; int in[maxn]; int ans[maxn]; vector <int> v[maxn]; bool mark[maxn][maxn]; bool flag; void Dfs(int cur,bool f) { if(cur>m&&ans[m]==ans[0]&&f) { flag=1; ...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
2431d1227585f0d4fb8e35adf297f3a3
2,300
PASSED
#include <iostream> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <vector> #include <string> #include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <sstream> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<stri...
C++
50a7fe83f2fb8d33b37e188332e2b2fa
b855cc13be52eea1ae12a5400e2fcf29
2,300
PASSED
#include<bits/stdc++.h> #define ff first #define ss second #define ll long long #define pb push_back #define EL printf("\n") #define pb push_back #define FOR(i,l,r) for (int i=l;i<=r;i++) #define FORD(i,r,l) for (int i=r;i>=l;i--) using namespace std; const int MX = 2e5 + 5, MOD = 1e9 + 7, base = 1e9; int n, a[MX], b[M...
C++
9d3ffe0063686bdcf567f025d8e4d998
1477f86b536485e33a7e83b0fd96c160
null
PASSED
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll t; cin >> t; while(t--) { ll n, k; cin >> n >> k; ll arr[n + 1]; map<ll,ll>mp, bp; ll Color; set<ll>st; for(ll i = 1; i <= n; i++) { cin >> arr[i]; st.inser...
C++
9d3ffe0063686bdcf567f025d8e4d998
e98d749430c47fbaa60c15f33410cfbc
null
PASSED
/* Author Kartik Shukla */ #include<bits/stdc++.h> using namespace std; typedef long long int ll; #define MOD 1000000007 void solve () { int n,k; cin>>n>>k; int i; int a[n]; for(i=0;i<n;i++) { cin>>a[i]; } int ans=n+10; for(int j=1;j<=100;j++) { int res=0; for(i=0;i<n;i++) {...
C++
9d3ffe0063686bdcf567f025d8e4d998
8392086c406fc72c731f645e9fabc910
null
PASSED
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define ll long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> ...
C++
9d3ffe0063686bdcf567f025d8e4d998
95fd5c25c19c382d73ae1921ca40d140
null
PASSED
#include <iostream> #include <vector> #include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T; cin>>T; while(T--) { int n,k,a=0,b=0; cin>>n>>k; int ans=n/k+1; vector<int> vec; f...
C++
9d3ffe0063686bdcf567f025d8e4d998
4677baf0d6647b3501a86bc80d97e374
null
PASSED
/*Knowing is not enough,we must apply!!*/ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007 #define boost ios_base::sync_with_stdio(false);cin.tie(NULL); int main(){ #ifndef ONLINE_JUDGE freopen(...
C++
9d3ffe0063686bdcf567f025d8e4d998
95e046eb9d91b3e6ecdffdee7371b6ed
null
PASSED
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { long long t; cin>>t; while(t--) { long long n,k; cin>>n>>k; long long arr[n]; for(long long i=0;i<n;i++) { cin>>arr[i]; } vector<long long>days; for(long long i=1;i<101;i++) { long long c=0,j=0; while(j<n) { if(arr[j]==...
C++
9d3ffe0063686bdcf567f025d8e4d998
f99b8ebb6bf906537ee7135cde2759d2
null
PASSED
#include <iostream> #include <bits/stdc++.h> using namespace std; #define pb push_back #define M 998244353 #define fr(i,n) for(int i=0;i<n;i++) #define M2 1000000007 #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pb push_back #define f first #define s second #define F(i,a,b) for(i=a;i<b;i++)...
C++
9d3ffe0063686bdcf567f025d8e4d998
2f675a7a7f05166a02e5d3f53c790e9b
null
PASSED
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ld long double #define ll long long #define pb push_back #define ff first #define ss second #define all(x) x.begin(), x.end() #define mp map<ll, ll> #define um unordered_map<ll, ll> #define st set<ll> #define us unordered_set<ll> #define vt v...
C++
9d3ffe0063686bdcf567f025d8e4d998
dd46e285259c47e8e5351e70f51ad962
null
PASSED
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ld long double #define ll long long #define pb push_back #define ff first #define ss second #define all(x) x.begin(), x.end() #define mp map<ll, ll> #define um unordered_map<ll, ll> #define st set<ll> #define us unordered_set<ll> #define vt v...
C++
9d3ffe0063686bdcf567f025d8e4d998
1d684e09db72d93238c3670aad062fa4
null
PASSED
#include <stdio.h> #include <iostream> #include <algorithm> #include <vector> #include <string> #include <queue> #include <map> #include <set> #include <cmath> #include <sstream> #include <stack> #include <cassert> #include <string.h> #define pb push_back #define mp make_pair #define PI 3.14159265358979323846264338327...
C++
a7cdb90a03447fc9285819ed059383b3
b1de8c4ed88342980d52c6fdc0906c89
2,100
PASSED
#include <cstdio> int N,S,a[5],ans,x; int main() { scanf("%d",&N); for (int i=1; i<=N; i++) scanf("%d",&x),a[x]++,S+=x; if (S<3||S==5) {puts("-1"); return 0;} ans=x=a[1]<a[2]?a[1]:a[2],a[1]-=x,a[2]-=x,a[3]+=x; if (a[1]) a[3]+=x=a[1]/3,a[1]%=3,ans+=2*x+(!a[1]?0:a[1]==1&&a[3]?1:2); if (a[2]) a[3]+=2*(x=a[2]/3),a[2]...
C++
a7cdb90a03447fc9285819ed059383b3
15a696ab3996eb3504718afa7012fc3a
2,100
PASSED
#include <iostream>; using namespace std; int destributeOne(int numberOfOne,int numberOfTree,int numberOfFour){ div_t divResult=div(numberOfOne,3); int quot=divResult.quot; int rem=divResult.rem; if(rem==1){ if((quot+numberOfTree)!=0){ return quot*2+1; } if(numberOf...
C++
a7cdb90a03447fc9285819ed059383b3
4091c59cffeea3ff69060b61b5c224a2
2,100
PASSED
#include<iostream> using namespace std; int main() { int a[5]={0}; int i,j,k,n; int ansr=0; cin>>n; while(n--) { int x; cin>>x; a[x]++; } if(a[2]>=a[1]) { ansr+=a[1]; a[2]-=a[1]; a[3]+=a[1]; a[1]=0; // 4 3 2 only // 2 2 2-> 3 3 ansr+=a[2]/3*2; a[3]+=a[2]/3*2; a[2]%=3; if(a[2]==0) ...
C++
a7cdb90a03447fc9285819ed059383b3
06643fc7493620e239454027ed1ffc71
2,100
PASSED
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector> using namespace std; const int inf = (int) 1e9; int a[5], b[5]; int n; int getMen (int take12, int * a) { int temp = min(a[1], take12); a[1] -= temp; take12 -= temp; int cnt = temp; if (take12 > 0) { cnt += take12 ...
C++
a7cdb90a03447fc9285819ed059383b3
d0535d81b5323d2a31234c22636dc5b7
2,100
PASSED
#include <iostream> using namespace std; #define fr(i,n) for(int i=0;i<n;i++) #define fru(i,a,b) for(int i=a;i<=b;i++) #define N 1000010 int n; int a[N]={0}; int c[5]={0}; int cnt=0; void GetData() { cin >> n; fru(i,1,n) { cin >> a[i]; c[a[i]]++; } } int main() { GetData(); ...
C++
a7cdb90a03447fc9285819ed059383b3
a90247b339fa2ab180d1265a0f6787f2
2,100
PASSED
#include <iostream> #include <algorithm> #include <set> #include <map> using namespace std; #define ll long long const double eps = 1e-9; const double PI = acos(-1.); const int INF = 1000000000; const double E = 2.7182818284590452353602874713527; #define sqr(x) ((x)*(x)) #define fr(i,n) for(int i=0;i<n;i++) #define f...
C++
a7cdb90a03447fc9285819ed059383b3
88374a958879fb1f50e39b4d4c979c1b
2,100
PASSED
#include <iostream> using namespace std; #define fr(i,n) for(int i=0;i<n;i++) #define fru(i,a,b) for(int i=a;i<=b;i++) #define frd(i,a,b) for(int i=a;i>=b;i--) #define N 1000010 int n; int a[N]={0}; int c[5]={0}; int cnt=0; void GetData() { cin >> n; fru(i,1,n) { cin >> a[i]; c[a[i]]++; ...
C++
a7cdb90a03447fc9285819ed059383b3
9f6c00b8c0b7c89dd8d5fda88a8d216b
2,100
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <stdio.h> #include <string.h> #include <cmath> #include <string> #include <queue> #include <stack> #include <iomanip> #include <set> #include <deque> #include <fstream> using namespace std; #define forn(i,a,b) for (int i = int(a); i <...
C++
a7cdb90a03447fc9285819ed059383b3
ce11151ca2fe60f4376e73e7dcc61801
2,100
PASSED
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include <string> #include <map> #define int64 long long #define rep(i,a,b) for (int i = a; i <= b; i++) #define repd(i,a,b) for (int i = a; i >= b; i--) #define mp make_pair using namespace std; int a[3000000], kol[5], ans, n; bool used[80]...
C++
a7cdb90a03447fc9285819ed059383b3
b454a6b08d41283aee1e351cab139179
2,100
PASSED
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <queue> #include <vector> #include <stack> #include <set> #include <map> #include <string> #include <cctype> #include <cstring> using namespace std; struct POINT{ int x,y; }P[8]; struct LINE{ POINT a,b; }; bool OK...
C++
a36fb51b1ebb3552308e578477bdce8f
1d579501dd1579857c815c97e02d825e
1,600
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; struct node { int x,y; }a[10]; double dist(node p1,node p2) { return (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y); } bool checkSq(node *rec) { node a1,a2,b1,b2,c1,c2; if(fabs(rec[0]...
C++
a36fb51b1ebb3552308e578477bdce8f
b8c489b2dbdf438d474e6d936b13a264
1,600
PASSED
#include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> using namespace std; #define abs(_a,_b) (_a>_b?(_a-_b):(_b-_a)) #define fill(a,b)memset(a,b,sizeof(a)) #define pause system("pause") const double eps=1e-6; int x[9],y[9];bool vis[9]; double sqr(double a){return(a*a);} double dis(i...
C++
a36fb51b1ebb3552308e578477bdce8f
92cb06da39fb0a6a969bd6d6b6388e58
1,600
PASSED
#include<cmath> #include<cstdio> #include<cctype> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> using namespace std; #define sqr(a) (a)*(a) #define cub(a) (a)*(a)*(a) #define for1(i,a,b) for(i=(a);i<(b);i++) #define for2(i,a,b) for(i=(a);i>(b);i--) #define same(a) memset((...
C++
a36fb51b1ebb3552308e578477bdce8f
e3b99d9ad1eb9579b0272bb9d804437f
1,600
PASSED
#include <iostream> #include <stdio.h> #include <cmath> using namespace std; struct point { int x, y; }; point a[8]; int f[4], r; double dist(point a, point b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } bool equal(double a, double b) { return (fabs(a - b) < 0.001); } bool...
C++
a36fb51b1ebb3552308e578477bdce8f
1abf7881f036de29e6181d9be394da05
1,600
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <cstdio> using namespace std; struct point { double x, y; }; point p[8]; int d[10]; vector <int> rect, squa, rRect, rSqua; bool haveSol = false; int drec[4], dsqua[4]; double dist(point a, point b) { return (pow(a.x - b.x, 2) + p...
C++
a36fb51b1ebb3552308e578477bdce8f
665ddb0d016511bd285fa0a4c576caa6
1,600
PASSED
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> using namespace std; #define file "file" #define sqr(x) ((x) * (x)) int d[9][9], a[9], b[9], x[9], y[9], i, j; int n, m = 1; int main () { //freopen(file ".in", "r", stdin); //freopen(file ".out", "w", stdo...
C++
a36fb51b1ebb3552308e578477bdce8f
aeb5dea35c50dcdb98be22588138b0cf
1,600
PASSED
#include <cstdio> #include <cstring> #include <string> #include <iostream> #include <algorithm> #include <map> #include <vector> #include <cmath> using namespace std; struct point { double x, y; } p[12]; int g[20], f[20], s[20]; int dblcmp( double x ) { if( fabs(x) < 1e-12 ) return 0; return x > 0 ? 1 : -1; } ...
C++
a36fb51b1ebb3552308e578477bdce8f
e629c12eeef3953ff8f435ac5abbe11c
1,600
PASSED
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <cmath> #include <vector> #include <map> #include <string> #include <set> #include <algorithm> using namespace std; int sqr(int a){ return a*a; } int x[10], y[10]; bool comp(int i1, int i2){ if (x[i1] == x[i2]) return y[i1] < y[i2]...
C++
a36fb51b1ebb3552308e578477bdce8f
e409751ee5943dc398c35b51ec27fb5b
1,600
PASSED
#include <stdio.h> #include <ctype.h> #include <iostream> #include <math.h> #include <string.h> #include <algorithm> #include <stdlib.h> #include <time.h> #include <queue> #include <set> #include <map> #include <string> #include <vector> #include <utility> #include <assert.h> #define MPI 3.141592653589793238462643 #def...
C++
a36fb51b1ebb3552308e578477bdce8f
863088c3b2d26db255a0bb8b4cde37a5
1,600
PASSED
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; int dis[17][19], dis1[17][19], a[17][10001], dp[17][(1 << 16) + 1], n, m, ans; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m; for (int i = 0; i < n; a[i++][m] = inf) for (int j = 0; j < m; ++j) cin >> a[i][j]; for (int i =...
C++
2e8b44efdd442f3ae5962ec637749708
a30709b09f3d15160df33efe303b3d17
2,000
PASSED
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; int dis[17][19], dis1[17][19], a[17][10001], dp[17][(1 << 16) + 1], n, m, ans; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m; for (int i = 0; i < n; a[i++][m] = 2 * inf) for (int j = 0; j < m; ++j) cin >> a[i][j]; for (int...
C++
2e8b44efdd442f3ae5962ec637749708
658fcd057eedaa941c4b19ebd3f8e279
2,000
PASSED
#include <bits/stdc++.h> #define maxm 17 #define maxn 10001 #define INF 1000000007 using namespace std; int m, n, a[maxm][maxn]; int g[maxm][maxm], g1[maxm][maxm]; int dis(int i,int j) { int kq=INF; for(int v=1;v<=n;++v) kq=min(kq,abs(a[i][v]-a[j][v])); return kq; } int nho[1<<maxm][maxm], dp[1<<maxm][...
C++
2e8b44efdd442f3ae5962ec637749708
718cdf5fbfacdde7d7a20f0c4acb8ed1
2,000
PASSED
#include <iostream> #include <queue> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <map> #include <algorithm> #include <set> #include <cmath> using namespace std; const int N = 16; int a[N][10010]; int flag[N][N], flag1[N][N]; bool dp[N][N][1 << N]; bool check(int n, int m, int m...
C++
2e8b44efdd442f3ae5962ec637749708
7fe936686882ea2295dc24450b36d6c0
2,000
PASSED
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <queue> #include <sstream> #include <vector> #include <map> #include <set> using namespace std; typedef pair<int, int> pii; typedef long l...
C++
2e8b44efdd442f3ae5962ec637749708
12b2a3c81fed146083aaf21f1e05db5f
2,000
PASSED
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN=20; const int MAXM=11000; const int MAXS=70000; int n, m; int a[MAXN][MAXM]; int c[MAXN]; int f[MAXN][MAXS]; bool chk1(int x, int y, int k) { for (int i=1; i<=m; i++) if (abs(a[x][i]-a[y][i])<k) return 0; return 1; } bool ...
C++
2e8b44efdd442f3ae5962ec637749708
c3605fde13cd2b950814e38923c1fa08
2,000
PASSED
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN=20; const int MAXM=11000; const int MAXS=70000; int n, m; int a[MAXN][MAXM]; int c[MAXN], f[MAXN][MAXS]; bool chk1(int x, int y, int k) { for (int i=1; i<=m; i++) if (abs(a[x][i]-a[y][i])<k) return 0; return 1; } bool chk2...
C++
2e8b44efdd442f3ae5962ec637749708
933d8a5a3d36aeda12e06295574e2aab
2,000
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int inf=0x7f7f7f7f; int dp[1<<20][20]; int n,m; int a[20][10005]; int chk[20][20],chk1[20][20]; int check(int i,int j)//计算当ij两行为上下行的时候能决定的最小的k { int minn=10001000000; for(int k=1;k<=m;k++) minn=min(minn,abs(a[i][k]-a[j][k])); r...
C++
2e8b44efdd442f3ae5962ec637749708
51e2e89cdab0bf13075f8a4935e41e24
2,000
PASSED
#include<bits/stdc++.h> using namespace std; #define inf 1e9 #define maxn 10007 #define pb push_back #define st first #define nd second typedef pair<int,int> ii; int n, m, p[18][maxn], p2[18][maxn], dp[18][66000], g[20][20]; int f(int u, int mask, int k, int beg) { if(mask == ((1<<n)-1)) return p2[u][beg] >= k; ...
C++
2e8b44efdd442f3ae5962ec637749708
ca517bcf731b3dc0077d6bd66e02a22c
2,000
PASSED
#pragma GCC target("avx") #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define Fast_cin ios::sync_with_stdio(false), cin.tie(0); #define rep(i, a, b) for(register int i = a; i <= b; i++) #define per(i, a, b) for(register int ...
C++
2e8b44efdd442f3ae5962ec637749708
fea3063ff026d307735d6aa004d8c6c1
2,000
PASSED
#include<iostream> #include<math.h> using namespace std; int main() { int x, y, *p, *t,z1=0,z2=0,f1=0,f2=0,c=0; cin >> x >> y; p = new int[x]; t = new int[y]; for (int i = 0; i < x; i++) cin >> p[i]; for (int i = 0; i < y; i++) cin >> t[i]; for (int i = 0; i < x; i++) if (p[i] % 2 == 0) z1++; else f1++; for...
C++
bc532d5c9845940b5f59485394187bf6
42b306f4218a7bbf966adb6321ca5a6b
800
PASSED
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int n,m; int numo1=0,numo2=0,nume1,nume2,x,y,ans; cin>>n>>m; vector<int>a(n),b(m); for(int i=0;i<n;i++){ cin>>a[i]; } for(int j=0;j<m;j++){ cin>>b[j]; } for(int i=0;i<n;i++){ ...
C++
bc532d5c9845940b5f59485394187bf6
760f4c2d4c0ac81bd2dc54ee6cb16456
800
PASSED
#include <iostream> #include <algorithm> using namespace std; int main() { int n, m, kq, temp; int chana = 0, chanb = 0, lea = 0, leb = 0; cin>>n>>m; for(int i=0;i<n;i++) { cin>>temp; if(temp%2 == 0) chana++; else lea++; } for(int i=0;i<m;i++) { cin>>temp...
C++
bc532d5c9845940b5f59485394187bf6
bb5c7d252192173de56f8097e1fb7aba
800
PASSED
#include <iostream> #include <algorithm> using namespace std; int main() { int n, m; cin >> n >> m; int temp; int nOdd = 0, nEven = 0; for(int i = 0; i < n; ++i) { cin >> temp; if(temp & 1) ++nOdd; else ++nEven; } int mOdd = 0, mEven = 0; for(int i = 0; i < m; ++i) { cin >> temp; if(temp ...
C++
bc532d5c9845940b5f59485394187bf6
b59641e98ad82fd5f9666b2346189df2
800
PASSED
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int a[100005]; int b[100005]; int main() { int i,j,m,n,t,ma1=0,mb1=0,k,ma2=0,mb2=0,sum1,sum2; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) { scanf("%d",&a[i]); if(a[i]%2!=0) { ma1++; } ...
C++
bc532d5c9845940b5f59485394187bf6
fce70e86c5848581487be9122731cb64
800
PASSED
#include <iostream> using namespace std; int main() { int m, n; cin >> n >> m; int ch = 0, nch = 0; // ���\����� int x; // ���� �������� � ������ int b; // ���� ������, ������ ��� �������� if (n > m) { b = m; } else { b = n; } for (int i = 0; i < n; i++) { cin >> x; if (x % 2 == 0) { ch++; } ...
C++
bc532d5c9845940b5f59485394187bf6
ac21af71bd50d97de54849c5dea373a6
800
PASSED
#include <iostream> #include <algorithm> using namespace std; int main() { int n, m; cin >> n >> m; int a1 = 0, a2 = 0; int b1 = 0, b2 = 0; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0)a2++; else a1++; } for (int i = 0; i < m; i++) { int x; cin >> x; if (x % 2 == 0)b2++; else b...
C++
bc532d5c9845940b5f59485394187bf6
f3196cd7a1cfe0d307fb54bcc5878ff7
800
PASSED
#include <iostream> using namespace std; int main() { int keys, chests; int k[100000]; int c[100000]; int odd_k_count = 0; int even_k_count = 0; int odd_c_count = 0; int even_c_count = 0; int res1; int res2; cin >> keys >> chests; for (int i = 0; i < chests; i++) { cin >> c[i]; if (c[i] % 2 != 0) od...
C++
bc532d5c9845940b5f59485394187bf6
c6a3fb03194c08b7efad236e09f4e1c9
800
PASSED
#include<iostream> #include<stdio.h> #include<algorithm> #include<cmath> #include<string> using namespace std; int a[100000], b[100000]; int main() { int n, m, even = 0, odd = 0, even1 = 0, odd1 = 0, sum = 0; cin >> n >> m; for ...
C++
bc532d5c9845940b5f59485394187bf6
4749df510f3a739d0250ef86413a427d
800
PASSED
#include <iostream> using namespace std; int min(int a, int b){ return (a<b)?a:b; } int main(int argc, char** argv) { int n , m, i, j, a, b, juft_son_a = 0, juft_son_b = 0, toq_son_a = 0, toq_son_b = 0; cin>>n>>m; for(i = 1;i<=n;i++){ cin>>a; if(a%2 == 0){ juft_son_a++; }else{ toq_son_a++; } } for...
C++
bc532d5c9845940b5f59485394187bf6
763228b9856255002bcbb306afcdbc50
800
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; const int maxn = 1e5 + 5; int src[maxn]; int main() { int n, s, t, i, cnt, flag; while (scanf("%d%d%d", &n, &s, &t) != EOF) { for (i = 1; i <= n; i++) scanf("%d", &src[i]); cnt = 0; flag = 1; while (s != t) ...
C++
b01602b51b9103c0f31c3f50b32aa88d
b3705c12024dd6d7cc6543550b034fec
1,200
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; const int maxn = 1e5 + 5; bool vis[maxn]; int src[maxn]; int main() { int n, s, t, i, cnt, flag; while (scanf("%d%d%d", &n, &s, &t) != EOF) { for (i = 1; i <= n; i++) scanf("%d", &src[i]); ...
C++
b01602b51b9103c0f31c3f50b32aa88d
e16ec058698f958d26bb1dd2347fac91
1,200
PASSED