solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
from __future__ import division, print_function
def main():
from sys import stdin
from math import ceil
from bisect import bisect_left as bl
input = stdin.readline
# def greater(num, arr):
# ind = bl(arr, num)
# return arr[ind]
for test in range(int(input())):
n, m =... | 13 | PYTHON3 |
import sys
from bisect import bisect_left
input = sys.stdin.readline
def solve():
n, m = map(int,input().split())
a = list(map(int,input().split()))
p = [0]*(n+1)
M = [0]*(n+1)
for i in range(n):
p[i+1] = p[i] + a[i]
M[i+1] = max(M[i], p[i+1])
s = p[-1]
ans = []
#print(p,M)
for x in map(int,input().split... | 13 | PYTHON3 |
#include <bits/stdc++.h>
using ll = long long;
char df = '\n';
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
ll A[n], ar[n], mx[n];
for (int i = 0; i < n; i++) cin >> A[i];
ar[0] = A[0];
for (int i = 1; i < n; i++) ar[i] = A[i]+ar[i-1];
mx[0] = ar[0];
for (int i = 1; i < ... | 13 | CPP |
import bisect
def main():
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = list(map(int, input().split()))
p = []
pts = []; M = 0; d = {}; suma = 0
for i in range(n):
suma += a[i]
... | 13 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10,M=1e9+7,OO=0x3f3f3f3f;
int n;
int arr[N];
ll pre[N];
ll seg[4*N];
void build(int si=0,int ss=0,int se=n-1){
if(ss==se){
seg[si]=pre[ss];
return;
}
int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
build(lf... | 13 | CPP |
import bisect
from collections import defaultdict
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
arr = [int(i) for i in input().split()]
ops = [int(i) for i in input().split()]
prefix_sum = [0 for i in range(n)]
prefix_sum[0] = arr[0]
for i in range(1, n):
prefix_s... | 13 | PYTHON3 |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i <= (int)n; ++i)
#define forin(i, a, b) for (int i = a; i <= (int)b; ++i)
#define rofin(i, a, b) for (int i = a; i >= b; --i)
#define all(x) (x).begin(), (x).end()
#define sync \
ios::syn... | 13 | CPP |
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);cout<<setprecision(25);
#define pb push_back
typedef long long int ll;
ll M=1000000007;
using namespace std;
int main()
{
IOS;
ll T;
cin>>T;
while(T--)
{
ll n,m,i,sum=0;
cin>>n>>m;
ll a[n],mx[n],pref[n];
... | 13 | CPP |
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+200;
typedef long long ll;
ll a[N],b[N];
ll sum[N];
int main()
{
int T;scanf("%d",&T);
while(T--)
{
ll mx=-1e18;memset(sum,0,sizeof sum);
int n,m;scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
for(int i=1;i<=n;i++){sum[i]=sum[i-1]+a... | 13 | CPP |
/*
** Author: Kartikey Tewari
** Time: 02-04-2021 17:40:25
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll tt;
cin >> tt;
for (ll yy=0;yy<=tt-1;yy++)
{
ll n,m;
cin >> n >> m;
vector<... | 13 | CPP |
import sys
input=sys.stdin.readline
from bisect import bisect_left
from math import ceil
t=int(input())
for _ in range(t):
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=list(map(int,input().split()))
max_cycle_sum=-float('inf')
cycle_sum=0
pos_max_cycle_sum=[]
for i in ra... | 13 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n,m;
long long sum;
long long a[N];
vector<pair<long long,int>> v;
int minp[N];
long long solve(long long x){
long long maxv = v[v.size() - 1].first;
if(maxv < x && sum <= 0) return -1;
if(x <= maxv){
... | 13 | CPP |
/// vonat1us
#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>; ... | 13 | CPP |
import sys,functools,collections,bisect,math
input = sys.stdin.readline
#print = sys.stdout.write
t = int(input())
for _ in range(t):
n,m = map(int,input().strip().split())
a = list(map(int,input().strip().split()))
x = list(map(int,input().strip().split()))
for i in range(1,n):
a[i] += a[i-1]
... | 13 | PYTHON3 |
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005
using namespace std;
void solve()
{
ll n, m;
cin >> n >> m;
... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
while(*sdbg!=',')cerr<<*sdbg++;
cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define ff first
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define nn "\n"
#define sci(x) scanf("%d", &x)
#define LL_INF (1LL << 62)
#d... | 13 | CPP |
from bisect import *
from math import ceil
for _ in range(int(input())):
n,m = map(int,input().split())
a = list(map(int,input().split()))
x = list(map(int,input().split()))
prefMax=[a[0]]*n
prefSum=[a[0]]*n
for i in range(1,n):
prefSum[i] = prefSum[i-1]+a[i]
prefMax[i] = max(pre... | 13 | PYTHON3 |
from os import path
import sys,time
# mod = int(1e9 + 7)
# import re
from math import ceil, floor,gcd,log,log2 ,factorial,sqrt
from collections import defaultdict ,Counter , OrderedDict , deque
# from itertools import combinations
# from string import ascii_lowercase ,ascii_uppercase
# from bisect import *
from functoo... | 13 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fr first
#define sc second
#define pii pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define rep(i,a,b) for(ll i=a;i<b;i++)
// const ll mod = 10... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef ve... | 13 | CPP |
from collections import Counter
from bisect import bisect_right, bisect_left
from math import ceil
def solve(b,total,x,n):
if len(b) == 0:
return -1
if (x > b[-1] and total<=0):
return -1
if x <= b[-1]:
return bisect_left(b,x)
c = ceil((x-b[-1])/total)
idx = bisect_left(b,x-... | 13 | PYTHON3 |
#------------------Important Modules------------------#
from sys import stdin,stdout
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import *
input=stdin.readline
prin=stdout.write
from random import sample
t=int(input())
#t=1
from collections import Counter,deque
from math import... | 13 | PYTHON3 |
from sys import stdin
input=stdin.buffer.readline
import math
def func(dp,start,end,x):
pos=-1
while start<=end:
mid=(start+end)//2
if dp[mid][0]>=x:
pos=mid
end=mid-1
else:
start=mid+1
return pos
t=int(input())
for i in range(t):
... | 13 | PYTHON3 |
from bisect import *
import math
a=int(input())
for i in range(a):
n,m=map(int,input().split())
z=list(map(int,input().split()))
x=list(map(int,input().split()))
for i in range(1,len(z)):
z[i]+=z[i-1]
maxa=[]
for i in range(len(z)):
if(i==0):
maxa.append(z[0])
... | 13 | PYTHON3 |
from bisect import bisect_left
for i in range(int(input())):
n, m = map(int,input().split());a = list(map(int,input().split()));p = [0]*(n+1);M = [0]*(n+1)
for i in range(n):p[i+1] = p[i] + a[i];M[i+1] = max(M[i], p[i+1])
s = p[-1];ans = []
for x in map(int,input().split()):
r = 0
if s > 0:t = max((x-M[-1]+s-1)... | 13 | PYTHON3 |
#!/usr/bin/python3.6
import sys
input = sys.stdin.readline
from collections import Counter
import bisect
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]
cumsum = [0]
cummax = [0]
for ite... | 13 | PYTHON3 |
import sys
max_int = 2147483648 # 2^31
min_int = -max_int
t = int(input())
for _t in range(t):
n, m = map(int, sys.stdin.readline().split())
a = map(int, sys.stdin.readline().split())
x = map(int, sys.stdin.readline().split())
mx = 0
s = 0
maxs = []
for i, aa in enumerate(a):
s +=... | 13 | PYTHON3 |
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
#define maxn 3e5+10
#define inf32 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int,int>pii;
const int MOD=1e9... | 13 | CPP |
import sys
input = sys.stdin.readline
from collections import *
def judge(i):
return S*c+gain[i]>=xi
def binary_search():
l, r = 0, n-1
while l<=r:
m = (l+r)//2
if judge(m):
r = m-1
else:
l = m+1
return l
for _ in range(int(input... | 13 | PYTHON3 |
import sys
import bisect
input=lambda: sys.stdin.readline().strip("\r\n")
from math import log
sa=lambda :input()
sb=lambda:int(input())
sc=lambda:input().split()
sd=lambda:list(map(int,input().split()))
se=lambda:float(input())
sf=lambda:list(input())
flsh=lambda: sys.stdout.flush()
mod=10**9+7
def hnbhai():
n,m=s... | 13 | PYTHON3 |
import bisect
t=int(input())
for i in range(t):
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=list(map(int,input().split()))
pre=[0]*n
pre[0]=a[0]
cur=a[0]
for j in range(1,n):
cur+=a[j]
pre[j]=max(cur,pre[j-1])
ans=[0]*m
for j in range(m):
if cur<=0:
if pre[-1]<x[j]:
ans[j]=-1... | 13 | PYTHON3 |
import sys
from sys import stdin
import bisect
tt = int(stdin.readline())
for loop in range(tt):
n,m = map(int,stdin.readline().split())
a = list(map(int,stdin.readline().split()))
xlis = list(map(int,stdin.readline().split()))
s = 0
inds = []
sums = []
for i in range(n):
s += ... | 13 | PYTHON3 |
"""
Author - Satwik Tiwari .
16th Feb , 2021 - Tueday
"""
#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import Bytes... | 13 | PYTHON3 |
/*
*
* Author: Hsueh-
* Date: 2021-03-05 21:34:52
*
* */
#include <bits/stdc++.h>
using namespace std;
#define dbg(x...) \
do { \
cout << #x << " -> "; ... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int lim=1e6;int inf=1e8;
ll mod = 1e9+7;
#define ln '\n'
#define forstl(it,v) for(auto &it: v)
#define fi first
#define se second
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterato... | 13 | CPP |
//**sn0wrus**//
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cout.tie(NULL); \
cin.tie(NULL);
#define write(a) \
for (auto x : a) \
{ \
cout <... | 13 | CPP |
####################################################
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in fil... | 13 | PYTHON3 |
import heapq
def solve(n, a, x):
delta = sum(a)
if delta <= 0:
q = []
for i in range(len(x)):
heapq.heappush(q, (x[i], i))
s = 0
res = [-1] * len(x)
for i in range(n):
s += a[i]
while q and s >= q[0][0]:
res[q[0][1]] =... | 13 | PYTHON3 |
from collections import defaultdict
from itertools import accumulate
import sys
import bisect
input = sys.stdin.readline
'''
for CASES in range(int(input())):
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
sys.stdout.write(" ".join(map(str,ANS))+"\n")
'''
inf =... | 13 | PYTHON3 |
from math import ceil
def bina(a):
global array
low,high = 0,len(array)
while low<high:
mid = low+((high-low)//2)
if array[mid]>=a:
high = mid
else:
low = mid+1
return high
for _ in range(int(input())):
global array
n,m = map(int,input().split())
... | 13 | PYTHON3 |
import sys
input = sys.stdin.readline
from collections import Counter
from itertools import accumulate
import bisect
for _ in range(int(input())):
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pre = 0
cur = 0
C = [(0, -1)]
for i, a... | 13 | PYTHON3 |
from bisect import bisect_left
for i in range(int(input())):
n, m = map(int,input().split());a = list(map(int,input().split()));p = [0]*(n+1);M = [0]*(n+1)
for i in range(n):p[i+1] = p[i] + a[i];M[i+1] = max(M[i], p[i+1])
s = p[-1];ans = []
for x in map(int,input().split()):
r = 0
if s > 0:t = max((x-M[-1]+s-1)... | 13 | PYTHON3 |
from bisect import bisect_left
import math
def main():
cases = int(input())
ans_list = []
for _ in range(cases):
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
sums = []
cur = 0
max_sum = flo... | 13 | PYTHON3 |
import os
import sys
from io import BytesIO, IOBase
import math
import itertools
import bisect
import heapq
def main():
pass
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.m... | 13 | PYTHON3 |
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
#include<unordered_map>
#in... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=2e9;
const int maxn=2e5+10;
int t,n,m;
ll tot;
ll a[maxn],sum[maxn];
ll tw[maxn];
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>t;
while (t--)
{
cin>>n>>m;tot=0;tw[0]=-inf;
for (int i=1;i<=n;i++)
{
cin>>a[i];
t... | 13 | CPP |
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode... | 13 | PYTHON3 |
#include <iostream>
#include <vector>
using namespace std;
class MergeSortTree {
private:
int n;
vector<vector<long long> > t;
inline int left(int i) {return i << 1;}
inline int right(int i) {return (i << 1) + 1;}
void merge(int idx) {
const vector<long long> &a = t[left(idx)];
... | 13 | CPP |
from collections import defaultdict,OrderedDict,Counter
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
# import numpy as np
from queue import Queue,PriorityQueue
from heapq import heapify,heappop,heappush
from statistics import median,mean
from math import gcd,sqrt,floor,factorial,ceil,log2,lo... | 13 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 200010;
int n, m;
LL a[N], s[N];
//
int cnt;
LL val[N];
int id[N];
//
LL ans[N];
void solve()
{
//printf("one Test\n");
//input
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%lld", &a[i]), s[i] = s[i - 1... | 13 | CPP |
#include <bits/stdc++.h>
#include <unordered_map>
//Author: Maximilian Paris
using namespace std;
typedef long long ll;
vector<pair<ll, ll>> prefix_sorted;
ll compare = 1e18;
struct sort_pred {
bool operator()(const std::pair<int, int>& left, const std::pair<int, int>& right) {
return left.second < right... | 13 | CPP |
from collections import defaultdict,OrderedDict,Counter
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
# import numpy as np
from queue import Queue,PriorityQueue
from heapq import heapify,heappop,heappush
from statistics import median,mean
from math import gcd,sqrt,floor,factorial,ceil,log2,lo... | 13 | PYTHON3 |
import math,sys,bisect,heapq,os
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
from functools import lru_cache
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
def input(): return sys.stdin.readline().rstrip('\r\n')
#input = iter(sys.stdin.buffer.read().decode().... | 13 | PYTHON3 |
#include<bits/stdc++.h>
#define read(arr, n) vector<int> arr(n); for(int i=0; i<n; i++) cin>>arr[i];
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fr(i, m, n) for(int i=m;i<n;i++)
#define frr(i, a, b) for(int i=a; i>b; i--)
#define w(tt) int tt; cin>>tt; while(tt--)
#define w1... | 13 | CPP |
import bisect
for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0]*n
check_point = []
cnt = 0
for i in range(n):
if i==0:
dp[i] = a[i]
else:
dp[i] = dp[i-1] + a... | 13 | PYTHON3 |
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int inf=1000000000;
int g[300000],q[300000],w[300000];
long long h[300000],v[300000];
int i,k,m,n,o,t,l,r,mid;
long long M;
inline bool cmp(int x,int y)
{
return q[x]<q[y];
}
int main()
{
scanf("%d",&t);
for (o=1;o<=t;o++)
{
... | 13 | CPP |
import sys
import math
import collections
import bisect
import itertools
import decimal
import heapq
# sys.setrecursionlimit(10000001)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353
def ni(): return int(sys.stdin.buffer.readline())
def ns(): return map(int, sys.stdin.buffer.readline().split())
def na(): return ... | 13 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
int main()
{
int t; scanf("%d",&t);
while(t--)
{
int n,m; scanf("%d %d",&n,&m);
ll a[n]; for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int b[m]; for(int i=0;i<m;i++) scanf("%d",&b[i]);
vector<... | 13 | CPP |
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998244353
# ------------------------------warmup----------... | 13 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define lp3(i,s,n) for(int i = s;i < int(n); ++i)
#define lp(i, n) lp3(i,0,n)
#define pb push_back
#define debug(x) cout<<"[" << #x << " is: " << x << "] "<<endl;
#define file freopen("input.in","r",stdin);
#define fastIO std::ios::sy... | 13 | CPP |
from sys import stdin
from math import ceil
from bisect import bisect_left as bl
input = stdin.readline
def greater(num, arr):
ind = bl(arr, num)
return arr[ind]
for test in range(int(input())):
n, m = map(int, input().strip().split())
lst = list(map(int, input().strip().split()))
x = list(map(... | 13 | PYTHON3 |
import sys,os,io ; from sys import stdin
from bisect import bisect_left , bisect_right
if(os.path.exists('input.txt')):
sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w")
else:
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
si = lambda : input()
ii = lambda : int(input())
li ... | 13 | PYTHON3 |
import bisect
t = int(input())
for _ in range(t):
n,m = map(int,input().split())
A = list(map(int,input().split()))
X = list(map(int,input().split()))
upd = [0]
updl = [0]
m = 0
cum = 0
for i,a in enumerate(A):
cum += a
if m < cum:
m = cum
upd.appe... | 13 | PYTHON3 |
import bisect
import math
for _ in range(int(input())):
n,m=map(int,input().split())
lis=list(map(int,input().split()))
x=list(map(int,input().split()))
prefix=[]
dic={}
sum1=0
for i in range(len(lis)):
sum1+=lis[i]
if prefix and sum1<prefix[-1]:
continue
... | 13 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
string to_string(char x) {
string re;
re += '\'';
re += x;
re += '\'';
return re;
}
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, ... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;
ll ar[Max];
ll pos[Max];
ll x[Max];
void Solve() {
ll n, m;
cin >> n >> m;
ll sum = 0, mx = -Inf;
for (ll i = 1; i <= n; i++) {
cin >>... | 13 | CPP |
//To debug : g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators
//do not forget to change the sizes of arrays and value of contants and other t... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ps push
#define in insert
#define f first
#define s second
#define ca(v) for(auto i:v) cout<<i<<" ";
#define nl cout<<"\n"
#define gcd(a, b) __gcd(a, b)
#define lcm(a, ... | 13 | CPP |
from bisect import bisect_left
for i in range(int(input())):
n, m = map(int,input().split())
a = list(map(int,input().split()))
p = [0]*(n+1)
M = [0]*(n+1)
for i in range(n):
p[i+1] = p[i] + a[i]
M[i+1] = max(M[i], p[i+1])
s = p[-1]
ans = []
for x in map(int,input().split()):
r = 0
if s > 0:
t = max(... | 13 | PYTHON3 |
from bisect import bisect_left
import math
for _ in range(int(input())):
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=list(map(int,input().split()))
curSum=0
mx=[]
mxindx=[]
for i in range(n):
curSum+=a[i]
if mx==[] or mx[-1]<curSum:
mx.append(c... | 13 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n, m;
cin >> n >> m;
vector<ll> a(n);
ll allSum = 0;
vector<ll> pref;
vector<int> ind;
int curInd = 0;
for (ll &e : a) {
cin >> e;
allSum += e;
if (pref.empty() || allSum > pref.back()) {
pref.push... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#defi... | 13 | CPP |
#include<bits/stdc++.h>
using namespace std;
//https://blog.csdn.net/Phoenix_ZengHao/article/details/113833938
typedef long long LL;
const int maxn=2e5+50;
LL n,m,T;
LL a[maxn],sum[maxn],maxx[maxn],ans[maxn];
int main()
{
cin>>T;
while(T--)
{
cin>>n>>m;
memset(maxx,0,sizeof(maxx));
for(int i=1;i<=n;i++)
{
... | 13 | CPP |
#include<bits/stdc++.h>
using namespace std;
#define Fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite freopen ("out.txt","w",stdout);
#define TC int t;cin >> t;FOR(tc,1,t)
#define LL long long
#define ULL unsigned long lo... | 13 | CPP |
#include <bits/stdc++.h>
// #include <atcoder/all>
//using namespace atcoder;
//tabaicho see https://boostjp.github.io/tips/multiprec-int.html
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// cpp_int
// int128_t
// int256_t
// int512_t
// int1024_t
// uint128_t
// uin... | 13 | CPP |
from bisect import *
from collections import *
from math import gcd,ceil,sqrt,floor,inf
from heapq import *
from itertools import *
from operator import add,mul,sub,xor,truediv,floordiv
from functools import *
#------------------------------------------------------------------------
import os
import sys
from io impo... | 13 | PYTHON3 |
import sys, math, itertools, random, bisect
from collections import defaultdict
INF = sys.maxsize
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
mod = 10**9 + 7
for _ in... | 13 | PYTHON3 |
from itertools import accumulate
import bisect
def solve():
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = list(map(int, input().split()))
p = list(accumulate(a))
s = p[-1]
max_val = max(p)
for i in range(1, n):
p[i] = max(p[i], p[i-1])
res = []
f... | 13 | PYTHON3 |
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <set>
#include <limits>
#include <random>
#include <functional>... | 13 | CPP |
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main()
{
int t; cin >> t;
int vivod = 0;
for (int i = 0; i < t; ++i){
int n, m; cin >> n >> m;
vector<pair<long long, long long>> prirost;
vector <long long> mas(n);
long long prirost_max = 0, prir... | 13 | CPP |
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define lui long unsigned int
const int N =2e5+5;
const int MOD = 998244353;
const ll M = 1e18;
ll qpow(ll a, ... | 13 | CPP |
import sys
import math
from collections import defaultdict,Counter,deque
import bisect
# input=sys.stdin.readline
# def print(x):
# sys.stdout.write(str(x)+"\n")
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.f... | 13 | PYTHON3 |
/*
Author: Manish Kumar
Username: manicodebits
created: 23:43:03 16-02-2021
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589
#define MOD 1000000007
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(0)
#define deb(x) cout<<"[ "<<#x<<" = "<<x<<"] "
v... | 13 | CPP |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << "[" << H << "]";
debug_out(T...);
}
#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debu... | 13 | CPP |
from os import path
import sys,time
from math import ceil, floor,gcd,log,log2 ,factorial
from collections import defaultdict ,Counter , OrderedDict , deque
from heapq import heapify , heappush , heappop
from bisect import *
# from functools import reduce
from operator import mul
from itertools import permutations
maxx,... | 9 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vec... | 9 | CPP |
//#pragma GCC optimize ("Ofast")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdarg>
#include <cassert>
#include <climits>
#include <cstring>
#include <complex>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <set>
#include <m... | 9 | CPP |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
const ll mod = 1000000007;
vector<ll> cnt(200005);
void preprosy(){
vector<ll> mp(10, 0); mp[9] = 1;
for(ll i = 0; i < 200005; i++){
vector<ll> t = mp;
for(ll j = 0; j < 10; j++){
cnt[i] = (cnt[i] + mp[j]) % mod;
mp[j] = ... | 9 | CPP |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vec vector <int>
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i = x; i >= x; i--)
#define all(c) c.begin()... | 9 | CPP |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define all(x) (x).begin(), (x).end()
#define len(s) (int)((s).size())
#define str(ch) string(1, ch)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using graph = vector<vector<int>>;
long long calc[200... | 9 | CPP |
from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353... | 9 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
#define f(i,k,n) for(ll i=k;i<n;i++)
#define all(s) s.begin(),s.end()
#define vec vector<ll>
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const ll maci=200002;
const ll mod=1e9+7;
ll dp[10][maci];
i... | 9 | CPP |
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define _USE_MATH_DEFINES
# define M_PI 3.14159265358979323846 /* pi */
#define ll long long
#define ld long double
#define vbe(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v... | 9 | CPP |
import sys
import os.path
from collections import *
import math
import bisect
if (os.path.exists('input.txt')):
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
else:
input = sys.stdin.readline
dp = [0] * (2 * 10**5 + 10)
for i in range(10):
dp[i] = 1
N = 2 * 10**5 + 10
mod = 1... | 9 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
ll t;
cin>>t;
ll cnt[10];
ll dp[200005];
dp[0] = 1;
cnt[9] = 1;
for(ll i=0;i<9;i++)
{
cnt[i] = 0;
}
for(ll i=1;i<=200000;i++)
{
... | 9 | CPP |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[200005][11];
ll ans[200005][11];
ll g[11];
const ll mod=1e9+7;
void solve(){
for(int i=0;i<=9;i++){
for(int j=0;j<=9;j++) f[0][j]=0;
f[0][i]=1;
for(int j=1;j<=200000;j++){
for(int k=2;k<=9;k++)
f[j][k]=f[j-1][k-1];
f[j][1]=(f[j-1][... | 9 | CPP |
import sys
input = sys.stdin.readline
dp = []
M = 10 ** 9 + 7
for i in range(200010):
if i < 10:
dp.append(1)
else:
dp.append((dp[i - 9] + dp[i - 10]) % M)
for _ in range(int(input())):
n, m = input().split()
m = int(m)
ans = 0
for i in n:
ans = (ans + dp[m + int(i)]) ... | 9 | PYTHON3 |
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
using namespace std;
const int mod=1e9+7;
// const int mod=99... | 9 | CPP |
from sys import stdin
input=stdin.readline
mod=10**9+7
def add(a,b):return ((a%mod) + (b%mod))%mod
dp=[1]*(2*(10**5) + 10)
for i in range(10,2* (10**5) + 10):
dp[i]=add(dp[i-9],dp[i-10])
def answer():
ans=0
for i in str(n):
ans=add(ans,dp[m+int(i)])
return ans
for T in r... | 9 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.