Submission #926142

#TimeUsernameProblemLanguageResultExecution timeMemory
926142Chal1kStove (JOI18_stove)C++14
0 / 100
0 ms348 KiB
#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; 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(){ int 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{ int 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 (stderr)

stove.cpp: In function 'void solve()':
stove.cpp:42:13: warning: unused variable 'sum' [-Wunused-variable]
   42 |         int sum = 0;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...