Submission #862792

#TimeUsernameProblemLanguageResultExecution timeMemory
862792AOrdinaryTarifa (COCI16_tarifa)C++14
50 / 50
0 ms600 KiB
#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)

tarifa.cpp: In function 'void setIO(std::string)':
tarifa.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tarifa.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...