# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862792 | AOrdinary | Tarifa (COCI16_tarifa) | C++14 | 0 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ld long double
#define ss second
#define ff first
#define int long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define ll long long
#define rall(x) x.rbegin(), x.rend()
#define sz(a) (int)a.size()
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define sp(x) fixed << setprecision(x)
#define ms multiset
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y);
#define mll map<ll,ll>
using namespace std;
const string YES = "YES";
const string NO = "NO";
const long long MOD = 1e9 + 7;
const int N = 1e5 + 5;
const long long inf = 9e18;
const int M = 3e3 + 5;
const double EPS = 1e-6;
const ll neg = -1;
const string imp = "impossible";
void setIO(string name = "") {
if (sz(name)) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void boost(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
}
void solve(){
ll k,n; cin >> k >> n;
ll a[n + 1];
for(ll i=0;i<n;i++){
cin >> a[i];
}
ll sum = 0;
for(ll i = 0;i<n;i++){
if(a[i] <k){
sum+=(k-a[i]);
}else{
sum-= abs(k-a[i]);
}
}
cout << sum+k;
}
signed main(){
boost();
ll test = 1;
//cin >> test;
while(test--) solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |