Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef pair<ll, ll> pii;
- #define se second
- #define fi first
- #define pb push_back
- #define mp make_pair
- int main() {
- ios::sync_with_stdio(false);
- ll n,m,k,x,y;
- cin>>n>>m>>k>>x>>y;
- if(n==1 || n == 2) {
- ll maxi = 0,tot = n*m;
- maxi += (k/tot);
- ll rmd = k%tot;
- if(rmd > 0) {
- maxi ++;
- }
- ll mini = k/tot;
- ll base = k/tot;
- if(rmd >= (x-1)*m+y) {
- base++;
- }
- cout<<maxi<<" "<<mini<<" "<<base<<endl;
- return 0;
- }
- ll maxi = 0;
- ll tot = 2*(n-1)*m;
- ll rounds = k/tot;
- maxi += 2*rounds;
- ll rmd = k%tot;
- if(rmd>m) {
- maxi++;
- }
- if(rmd > n*m) {
- maxi++;
- }
- ll mini =rounds;
- //mini += tot;
- if(rmd >= n*m) {
- mini++;
- }
- ll base = rounds;
- if(x!=1 && x!=n) {
- base +=rounds;
- }
- if(x==1) {
- if(y <= rmd) {
- base++;
- }
- }
- else if(x==n) {
- if(y <= rmd-(n-1)*m) {
- base++;
- }
- } else {
- if(rmd > n*m) {
- base++;
- x = n-x;
- rmd -= (n-1)*m;
- } else {
- x--;
- }
- if(x*m + y <=rmd) {
- base++;
- }
- }
- cout<<maxi<<" "<<mini<<" "<<base<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement