Problem:
ギャグ (Gag)
Segtree 君は $N$ 個の「ギャグ」を持っていて、それぞれに「できばえ」 $V_i$ という値が定まっています。
Segtree 君は自由な順番で全てのギャグを公開することにしました。
ここで、 $i$ 番目のギャグを $j$ 番目に公開した時に得られる「うれしさ」は $V_i - j$ と表されます。
Segtree 君が得られる「うれしさ」の和の最大値を求めてください。
入力
入力は以下の形式で標準入力から与えられる。
$N$
$V_1$ $V_2$ $\ldots$ $V_N$
出力
「うれしさ」の和の最大値を出力してください。ただし、値が 32bit 整数に収まるとは限りません。
最後には改行を入れること。
制約
$1 \leq N \leq 10^5$
$1 \leq V_i \leq 10^5$
入力は全て整数である。
入力例1
1
59549
出力例1
59548
入力例2
5
2 1 8 5 7
出力例2
8

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
#include <limits>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <unordered_set>
#include <tuple>
#include <map>
#include <bitset>

using namespace std;

int main()
{
	int N;
	cin >> N;

	vector<int> V(N);

	for (int i = 0; i < N; i++)
	{
		cin >> V[i];
	}

	sort(V.rbegin(), V.rend());

	long long happy = 0;

	for (int i = 0; i < N; i++)
	{
		happy += V[i] - (i + 1);
	}

	cout << happy << endl;


	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3628
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
    ll n,s1=0,s2=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        s1+=i;
    }
    for(ll i=0;i<n;i++){
        ll v;cin>>v;
        s2+=v;
    }
    cout<<s2-s1<<endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3416
final_rank: 1

code_snippet: #include<bits//stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i =0;i<n;i++)
int main(){
    ll n,sum = 0;cin >>n;vector<int> v(n);
    rep(i,n) {
        cin >> v[i];sum += v[i];
    }cout << sum - n*(n+1)/2<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3168
final_rank: 13

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long int ans = 0;
    for(int i=0; i<n; i++){
        long long int a;
        cin >> a;
        ans += a-i-1;
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3120
final_rank: 12

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
    	int a;
    	cin >> a;
    	ans += a-i-1;
    }
    cout << ans << endl;
    return 0;
}
accuracy: 0.21052631578947367
time_ms: 20
memory_kb: 3100
final_rank: 18

code_snippet: #include<iostream>
using namespace std;
signed main(){
    int64_t n;
    cin>>n;
    int64_t sum = 0ll;
    sum -= n*(n+1)/2;
    while(n--){
        int64_t ai;
        cin>>ai;
        sum += ai;
    }
    cout<< sum <<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3108
final_rank: 6

code_snippet: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long llong;
#define sum(N) ((N) * (N + 1) / 2)

int main() {
    llong n;
    llong v;
    llong ans = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v;
        ans += v;
    }

    ans -= sum(n);

    cout << ans << endl;

    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3096
final_rank: 3

code_snippet: #include<iostream>
using namespace std;
int main(){
    int n;
    long long a,cnt=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a;
        cnt += a-i;
    }
    cout << cnt << endl;
    return(0);
}
accuracy: 1
time_ms: 20
memory_kb: 3096
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {

  int N;
  cin>>N;
  int a[N];
  for(int i = 0; i < N; i++) cin>>a[i];

  sort(a, a+N);



  long long sum = 0;
  int count = 1;
  for(int i = N-1; i >= 0; i--) {
    sum += a[i] -count;
    count++;
  }

  cout<<sum<<endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3540
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {

  int N;
  cin>>N;
  int a[N];
  for(int i = 0; i < N; i++) cin>>a[i];

  sort(a, a+N);



  int sum = 0;
  int count = 1;
  for(int i = N-1; i >= 0; i--) {
    sum += a[i] -count;
    count++;
  }

  cout<<sum<<endl;
  return 0;
}
accuracy: 0.21052631578947367
time_ms: 20
memory_kb: 3484
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;

#define M 100000
int main(){
  int n,g[M],i,j;
  long long a=0;
  cin>>n;
  for(i=0;i<n;i++){
      cin>>g[i];
  }
  sort(g,&g[n]);
  for(i=0;i<n;i++){
    a+=g[i]-(i+1);
  }
  cout<<a<<endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3552
final_rank: 15

code_snippet: #include <bits/stdc++.h>

using namespace std;

int main() {
	int n; cin >> n;
	long long ans=0;
	for(int i=0;i<n;++i) {
		int v; cin >> v;
		ans+=v-i-1;
	}
	cout << ans << endl;
	
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3100
final_rank: 5

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main(){
	long long sum=0,n;	cin>>n;
	for(long long i=1;i<=n;i++){
		long long v;	cin>>v;
		sum+=v-i;
	}
	cout<<sum<<endl;


	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3116
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    ll n;cin>>n;
    ll a[n];
    ll sum=0;
    rep(i,0,n-1){
        cin>>a[i];
        sum+=a[i];
        sum-=(i+1);
    }
    cout<<sum<<endl;
    
    
    
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3880
final_rank: 17

code_snippet: #include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	long long int n; std::cin >> n;
	long long int sum = 0;
	for (auto i = 0; i < n; ++i) {
		int v; std::cin >> v;
		sum += v;
	}
	std::cout << sum - n * (n + 1) / 2 << std::endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3116
final_rank: 10

code_snippet: //
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    ll n;
    cin >> n;
    ll x,t=0;
    rep(i,n){
        cin >> x;
        t+=x;
    }
    cout << t-n*(n+1)/2 << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3112
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    int64_t ans = 0;
    for(int i=0; i<N; i++){
        int v;
        cin >> v;
        ans += v-i-1;
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3108
final_rank: 6

code_snippet: #include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin >> N;
    ll res = 0;
    REP(i,N)
    {
        int a;
        cin >> a;
        res += a - i - 1;
    }

    cout << res << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3088
final_rank: 2

code_snippet: #include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;
    int res = 0;
    REP(i,N)
    {
        int a;
        cin >> a;
        res += a - i - 1;
    }

    cout << res << endl;
    return 0;
}
accuracy: 0.21052631578947367
time_ms: 20
memory_kb: 3112
final_rank: 19

code_snippet: #include<iostream>
using namespace std;
long n,v,s;
main()
{
    cin>>n;
    s=-n*(n+1)/2;
    for(int i=0;i<n;i++)cin>>v,s+=v;
    cout<<s<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3112
final_rank: 8