Submission #516231

#TimeUsernameProblemLanguageResultExecution timeMemory
516231MohamedAliSaidaneBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms296 KiB
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
#define pb push_back
#define popb pop_back
#define all(v) (v).begin(),(v).end()
 
#define ff first
#define ss second
 
const ll INF=  1e18 ;
const ll MOD = 1e9 + 7;
 
int n, k, l;
vi A;
ll delivery(int N, int K, int L, int positions[])
{
    n = N, k = K, l = L;
    ll ans = 0ll;
    ll maxt = 0ll;
    for(int i=  0; i< N; i ++)
    {
        int e=  positions[i];
        ans += (ll)(min(e,l-e));
    }
    return 2ll*ans;
}
/*
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int N, K, L;
    vi positions;
    cin >> N >> K >> L;
    for(int i = 0; i <N; i ++)
    {
        int x; cin >> x;
        positions.pb(x);
    }
    cout << delivery(N,K,L,positions);
}*/
 

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:33:8: warning: unused variable 'maxt' [-Wunused-variable]
   33 |     ll maxt = 0ll;
      |        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...