Submission #862792

# Submission time Handle Problem Language Result Execution time Memory
862792 2023-10-19T03:31:39 Z AOrdinary Tarifa (COCI16_tarifa) C++14
50 / 50
0 ms 600 KB
#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

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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct