Submission #926141

# Submission time Handle Problem Language Result Execution time Memory
926141 2024-02-12T15:34:14 Z Chal1k Stove (JOI18_stove) C++14
0 / 100
0 ms 344 KB
#include<bits/stdc++.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define  SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
#define ull unsigned long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define F first
#define S second
#define len(a) a.size()
#define sz(v) (int)(v.size())
#define pii pair<int,int>
const int N = 2e3 + 1;
const int md = 998244353;
const int mod = 1e9 + 7;
const int mega = 1e6 + 3;
const int inf=1e18;
long long gcd(long long int a, long long int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
long long lcm(int a, int b)
{
    return (a / gcd(a, b)) * b;
}
void solve(){
    ll n , k;
    cin >> n >> k;
    int a[n+1];
    for(int i = 1; i <= n; ++i)cin >> a[i];
    if(n == k){
        cout << n;
    }
    else{
        ll sum = 0;
        if(k == 1){
            cout << a[n];
        }
        else{
            int kol = 0;
            for(int i = 1; i <= n; ++i){
                if(i + (n/k) - 1 <= n)kol += (a[i + (n/k) - 1]) - a[i] + 1,i+= n/k;
                else {kol += a[n]+1 - a[i] ; break;}
            }
            cout << kol + (n/k+1);
        }
    }
}
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    SPEED;
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
}

Compilation message

stove.cpp:23:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   23 | const int inf=1e18;
      |               ^~~~
stove.cpp: In function 'void solve()':
stove.cpp:43:12: warning: unused variable 'sum' [-Wunused-variable]
   43 |         ll sum = 0;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -