Problem:
Problem C
  Medical Checkup
Students of the university have to go for a medical checkup, consisting of lots of checkup items, numbered 1, 2, 3, and so on.
Students are now forming a long queue, waiting for the checkup to start. Students are also numbered 1, 2, 3, and so on, from the top of the queue. They have to undergo checkup items in the order of the item numbers, not skipping any of them nor changing the order. The order of students should not be changed either.
Multiple checkup items can be carried out in parallel, but each item can be carried out for only one student at a time. Students have to wait in queues of their next checkup items until all the others before them finish.
Each of the students is associated with an integer value called
health condition
. For a student with the health condition $h$, it takes $h$ minutes to finish each of the checkup items. You may assume that no interval is needed between two students on the same checkup item or two checkup items for a single student.
Your task is to find the items students are being checked up or waiting for at a specified time $t$.
Input
The input consists of a single test case in the following format.
$n$ $t$
$h_1$
...
$h_n$
$n$ and $t$ are integers. $n$ is the number of the students ($1 \leq n \leq 10^5$). $t$ specifies the time of our concern ($0 \leq t \leq 10^9$). For each $i$, the integer $h_i$ is the health condition of student $i$ ($1 \leq h_ \leq 10^9$).
Output
Output $n$ lines each containing a single integer. The $i$-th line should contain the checkup item number of the item which the student $i$ is being checked up or is waiting for, at ($t+0.5$) minutes after the checkup starts. You may assume that all the students are yet to finish some of the checkup items at that moment.
Sample Input 1
3 20
5
7
3
Sample Output 1
5
3
2
Sample Input 2
5 1000000000
5553
2186
3472
2605
1790
Sample Output 2
180083
180083
180082
180082
180082

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

const ll INF = 1e18;
ll mod = 998244353;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if (argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll n, t;
    cin >> n >> t;
    ll a = 0, b = 0;
    for (int i = 0; i < n; i++) {
        ll h;
        cin >> h;
        chmax(a, h);
        b += h;
        cout << max((t - b + a) / a, 0LL) + 1 << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3584
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

const ll INF = 1e18;
ll mod = 998244353;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if (argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll n, t;
    cin >> n >> t;
    ll a = 0, b = 0;
    for (int i = 0; i < n; i++) {
        ll h;
        cin >> h;
        chmax(a, h);
        b += h;
        cout << max((t - b) / a + 1, 0LL) + 1 << endl;
    }

    return 0;
}
accuracy: 0.26666666666666666
time_ms: 40
memory_kb: 3584
final_rank: 14

code_snippet: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <set>

using namespace std;

const int maxN = 1e5 + 10;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long
#define BIT(x, i) ((x >> i) & 1)

int res[maxN], n, t;

int main() {
    cin >> n >> t;
    LL s = 0; int maxa = 0;
    FORU(i, 1, n) {
        int x; cin >> x;
        maxa = max(maxa, x);
        if (t >= s) {
            LL q = (t - s) / maxa;
            LL r = (((t - s) % maxa) + maxa) % maxa;
            res[i] = q + (r >= x) + 1;
        }
        else res[i] = 1;
        s += x;
    }
    FORU(i, 1, n) cout << res[i] << endl;
}
accuracy: 1
time_ms: 90
memory_kb: 3868
final_rank: 8

code_snippet: #include<cstdio>
#include<algorithm>
int n, t;
long long pre, ans=0;
int main() {
    scanf("%d %d", &n, &t);
    for(int i=1; i<=n; i++) {
        long long x;
		scanf("%lld", &x);
        pre+=x;
        ans=std::max(ans, x);
        if(t<pre) {
            printf("1\n");
        }
        else printf("%lld\n", 2+(t-pre)/ans);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 2952
final_rank: 1

code_snippet: #include<cstdio>
#include<cmath>
int n, t;
long long a, b;
int main() {
	scanf("%d %d", &n, &t);
	long long cnt=0, pre=0;
	for(int i=1; i<=n; i++) {
		int x;
		scanf("%d", &x);
		if(x>=pre) pre=x, a=x, b=cnt;
		else b=cnt-(pre-x), a=pre;
		cnt+=x;
		long long now=(t-b)/a+1;
		if(now<0) printf("1\n");
		else printf("%lld\n", now);
	}
}
accuracy: 0.26666666666666666
time_ms: 10
memory_kb: 2956
final_rank: 12

code_snippet: #include<bits/stdc++.h>
#define int long long
using namespace std;
int n, t, k, tot, h;

signed main(){
	ios::sync_with_stdio(0);
	cin >> n >> t;
	while(n--){
		cin >> h;
		tot += h;
		if(h > k)
			k = h;
		const int b = tot - k;
		cout << (t - b) / k + 1 << endl;
	}
	return 0;
}
accuracy: 0.26666666666666666
time_ms: 70
memory_kb: 3428
final_rank: 15

code_snippet: #include <iostream>
#define int long long
using namespace std;
signed main(){
	int n,t;
	cin>>n>>t;
	int maxx;
	cin>>maxx;
	int res=t/maxx+1;
	cout<<res<<endl;
	int left=t-(res-1)*maxx;
	int tot=0;
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		tot+=x;
		if(x<=left){
			left-=x;
			cout<<res<<endl;
		}else{
			if(x>maxx){
				maxx=x;
				left=t-tot-(t-tot+x)/x*x;
				res=(t-tot+x)/x+1;
				cout<<res<<endl;
			}else{
				left=left+maxx-x;
				res--;
				cout<<res<<endl;
			}
		}
	}
}
accuracy: 0.1
time_ms: 70
memory_kb: 3436
final_rank: 19

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,s,n) for(ll i = (ll)s;i < (ll)n;i++)
#define rrep(i,l,r) for(ll i = r-1;i >= l;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  ll n,t;cin >> n >> t;
  vi res(n);
  ll mx = 0,S = 0;
  rep(i,0,n){
    ll h;cin >> h;
    chmax(mx,h);
    if(t <= S)res[i] = 1;
    else{
      if(h < mx){
        if((t-S)%mx < h)res[i] = (t-S)/mx + 1;
        else res[i] = (t-S)/mx + 2;
      }else{
        res[i] = (t-S)/h + 1;
      }
    }
    S += h;
  }
  rep(i,0,n)cout << res[i] << endl;
  

  return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3812
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; ++i)
#define loop(i, a, b) for(ll i = a; i <= b; ++i)
constexpr ll INF = 9009009009009009009LL;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> health(n);
    rep(i, n){
        cin >> health[i];
    }
    ll offset = 0;
    ll nowmax = 0;
    rep(i, n){
        nowmax = max(nowmax,health[i]);
        ll kiriage = (((t - offset) * 2 + 1) + (nowmax * 2) - 1) / (nowmax * 2);
        ll kirisute = ((t - offset) * 2 + 1) / (nowmax * 2);

        ll temp = ((t - offset) * 2 + 1) - kirisute * nowmax * 2;
        if(health[i] * 2 <= temp)cout << max(1LL,kiriage + 1) << endl;
        else cout << max(1LL,kiriage) << endl;

        // cout << (((t - offset) * 2 + 1) + (nowmax * 2) - 1) / (nowmax * 2)  << endl;
        offset += health[i];
    }
}
accuracy: 1
time_ms: 90
memory_kb: 3904
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; ++i)
#define loop(i, a, b) for(ll i = a; i <= b; ++i)
constexpr ll INF = 9009009009009009009LL;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> health(n);
    rep(i, n){
        cin >> health[i];
    }
    ll offset = 0;
    ll nowmax = 0;
    rep(i, n){
        nowmax = max(nowmax,health[i]);
        ll kiriage = (((t - offset) * 2 + 1) + (nowmax * 2) - 1) / (nowmax * 2);
        ll kirisute = ((t - offset) * 2 + 1) / (nowmax * 2);

        ll temp = ((t - offset) * 2 + 1) - kirisute * nowmax * 2;
        if(health[i] * 2 <= temp)cout << kiriage + 1 << endl;
        else cout << kiriage << endl;

        // cout << (((t - offset) * 2 + 1) + (nowmax * 2) - 1) / (nowmax * 2)  << endl;
        offset += health[i];
    }
}
accuracy: 0.26666666666666666
time_ms: 80
memory_kb: 3876
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; ++i)
#define loop(i, a, b) for(ll i = a; i <= b; ++i)
constexpr ll INF = 9009009009009009009LL;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> health(n);
    rep(i, n){
        cin >> health[i];
    }
    ll offset = 0;
    ll nowmax = 0;
    rep(i, n){
        nowmax = max(nowmax,health[i]);
        ll kiriage = (((t - offset) * 2 + 1) + (nowmax * 2) - 1) / (nowmax * 2);
        ll kirisute = ((t - offset) * 2 + 1) / (nowmax * 2);

        ll temp = (t - offset) - kirisute * nowmax;
        if(health[i] <= temp)cout << kiriage + 1 << endl;
        else cout << kiriage << endl;

        // cout << (((t - offset) * 2 + 1) + (nowmax * 2) - 1) / (nowmax * 2)  << endl;
        offset += health[i];
    }
}
accuracy: 0.26666666666666666
time_ms: 80
memory_kb: 3904
final_rank: 18

code_snippet: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <set>

using namespace std;

const int maxN = 1e5 + 10;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long
#define BIT(x, i) ((x >> i) & 1)

int res[maxN], a[maxN], n, t;

int main() {
    cin >> n >> t;
    int s = 0;
    int p = 0;
    int maxa = 0;
    int ss = 0;
    FORU(i, 1, n) {
        cin >> a[i];
        int m = ((t - s) / a[i]) + 1;
        s += a[i];
        if (a[i] > maxa) {
            res[i] = m;
            p = s - a[i];
            ss = 0;
            maxa = a[i];
        }
        else {
            ss += a[i];
            int k = max(0, t - p - ss) / maxa;
            res[i] = k + 1;
        }
    }
    FORU(i, 1, n) cout << res[i] << endl;
}
accuracy: 0.26666666666666666
time_ms: 70
memory_kb: 4216
final_rank: 16

code_snippet: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

typedef long long int LLI;
typedef pair<int,int> PII;

#define _ ios_base::sync_with_stdio(0);
#define debug
#define x first
#define y second
#define MXN 100005

const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8; 


int main() { _
    int n, t, k, mx;
    LLI sum;
    while (cin >> n >> t) {
        mx = -1;
        sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> k;
            mx = max(mx, k);
            sum += k;
            cout << 1+1LL*ceil(((double)t+0.5 - sum)/mx) << "\n";
        }
    }

    return 0;
}
accuracy: 0.06666666666666667
time_ms: 110
memory_kb: 3488
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n;
long long t,h,sum,s;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>h;
        sum+=h;
        if(h>s) s=h;
        if(t<=sum) cout<<1<<"\n";
        else cout<<(t-sum)/s+2<<"\n";
    }
    return 0;
}
accuracy: 0.6
time_ms: 10
memory_kb: 3444
final_rank: 11

code_snippet: #include<bits/stdc++.h>
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define all(v) begin(v),end(v)
using namespace std;
using ll = long long;
bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int n; cin >> n;
    ll t; cin >> t;
    vector<ll> h(n);
    rep(i,0,n) cin >> h[i];

    ll nowmax = 0;
    vector<ll> nows;
    vector<pair<ll,vector<ll>>> data(0);
    ll ret = 0;
    ll valret = 0;
    rep(i,0,n) {
        if (chmax(nowmax, h[i])) {
            if (!nows.empty()) {
                data.push_back(pair(valret, nows));
            }
            nows.clear();
            valret = ret;
        }
        ret += h[i];
        nows.push_back(h[i]);
    }
    if (!nows.empty()) {
        data.push_back(pair(valret, nows));
    }

    ll cnt = 0;
    vector<ll> ans(n);
    rep(i,0,(int)data.size()) {
        ll kijun = data[i].first;
        ll nushi = data[i].second.front();

        for (ll x: data[i].second) {
            ll nokori = t - kijun;
            if (nokori < 0) {
                ans[cnt] = 1;
            }else {
                ll v = nokori / nushi;
                ll w = nokori % nushi;
                if (w < x) {
                    ans[cnt] = v + 1;
                }else {
                    ans[cnt] = v + 2;
                }
            }

            kijun += x;
            cnt++;
        }
    }

    for (ll x: ans) {
        cout<<x<<'\n';
    }
}
accuracy: 1
time_ms: 10
memory_kb: 12160
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define all(a) (a).begin(), (a).end()

int main(){
    ll n;
    cin>>n;
    ll t;
    cin>>t;
    ll a=0;
    ll mx=0;
    vector<ll> z(n);
    rep(i,0,n){
        cin>>z[i];
    }
    rep(i,0,n){
        mx=max(mx,z[i]);
        if(a>t)cout<<1<<endl;
        else {
            ll cr=(t-a)/mx+1;
            ll crst=(t-a)/mx*mx+a;
            if(t-crst>=z[i])cout<<(t-a)/mx+2<<endl;
            else cout<<(t-a)/mx+1<<endl;
        }
        a+=z[i];
    }
}
accuracy: 1
time_ms: 50
memory_kb: 4096
final_rank: 5

code_snippet: #include <bits/extc++.h>

using ll = long long;
using namespace std;
#define REP(i, n) for (ll i = 0; i < (n); i++)

template <class T>
bool chmax(T& x, const T& v) {
  if (x < v) {
    x = v;
    return true;
  } else {
    return false;
  }
}

template <class T>
bool chmin(T& x, const T& v) {
  if (x > v) {
    x = v;
    return true;
  } else {
    return false;
  }
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
  for (T& x : v) is >> x;
  return is;
}

void solve() {
  ll N, T;
  cin >> N >> T;
  vector<ll> H(N);
  REP(i, N) { cin >> H[i]; }

  vector<ll> Ans(N, -1);

  ll mx = -1, sum = 0;

  REP(i, N) {
    sum += H[i];
    mx = max(mx, H[i]);

    if (T < sum) {
      Ans[i] = 1;
      continue;
    }

    ll t = T - sum;
    ll a = t / mx;
    a += 2;
    Ans[i] = a;
  }

  REP(i, N) { cout << Ans[i] << endl; }
}

int main() { solve(); }
accuracy: 1
time_ms: 80
memory_kb: 4668
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long N, T;
    cin >> N >> T;
    vector<long long> H(N), sm(N + 1, 0);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
        sm[i + 1] = sm[i] + H[i];
    }

    vector<long long> ans(N);
    vector<long long> finish(N);
    long long mx = 0;
    for(int i = 0; i < N; i++) {
        if(H[i] > mx) {
            long long t = T - sm[i];
            ans[i] = max(0LL, t / H[i]);
            finish[i] = ans[i] * H[i] + sm[i];
            mx = H[i];
        }
        else {
            if(finish[i - 1] + H[i] <= T) {
                ans[i] = ans[i - 1];
                finish[i] = finish[i - 1] + H[i];
            }
            else {
                ans[i] = max(0LL, ans[i - 1] - 1);
                finish[i] = finish[i - 1] - mx + H[i];
            }
        }
        cout << ans[i] + 1 << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 6252
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long N, T;
    cin >> N >> T;
    vector<long long> H(N), sm(N + 1, 0);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
        sm[i + 1] = sm[i] + H[i];
    }

    vector<long long> ans(N);
    vector<long long> finish(N);
    long long mx = 0;
    for(int i = 0; i < N; i++) {
        if(H[i] > mx) {
            long long t = T - sm[i];
            ans[i] = t / H[i];
            finish[i] = ans[i] * H[i] + sm[i];
            mx = H[i];
        }
        else {
            if(finish[i - 1] + H[i] <= T) {
                ans[i] = ans[i - 1];
                finish[i] = finish[i - 1] + H[i];
            }
            else {
                ans[i] = ans[i - 1] - 1;
                finish[i] = finish[i - 1] - mx + H[i];
            }
        }
        cout << ans[i] + 1 << "\n";
    }

    return 0;
}
accuracy: 0.26666666666666666
time_ms: 10
memory_kb: 6276
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(v) v.begin(),v.end()
#define dbg(x) cerr << #x << ": " << (x) << endl;

int main() {
    int n,t;
    cin >> n >> t;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    int ma = 0;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        ma = max(ma, h[i]);
        
        if (t - sum < 0) {
            cout << 1 << '\n';
            sum += h[i];
            continue;
        }
        int ans = (t - sum) / ma + 1;
        ans += ((t - sum) % ma < h[i] ? 0 : 1);
        cout << ans << '\n';

        sum += h[i];
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3672
final_rank: 2