Submission #3009595


Source Code Expand

#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll N; cin >> N;
	ll tmp,N2 = N;
	prique<ll> que;
	rep(i,N){
		cin >> tmp; que.push(tmp);
	}
	while((tmp = que.top()) >= N2){
		que.pop();
		ll d = (tmp - N2) / N + 1;
		//cout << tmp << ' ' << d << endl;
		que.push(tmp - d * (N + 1));
		N2 -= d;
	}
	esc(N - N2);
}

Submission Info

Submission Time
Task E - Decrease (Judge ver.)
User jell
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1392 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 5
AC × 35
Set Name Test Cases
Sample example0, example1, example2, example3, example4
All example0, example1, example2, example3, example4, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, maxrand5, maxrand6, maxrand7, maxrand8, maxrand9, rand0, rand1, rand2, rand3, rand4, rand5, rand6, rand7, rand8, rand9, small0, small1, small2, small3, small4, small5, small6, small7, small8, small9
Case Name Status Exec Time Memory
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
example3 AC 1 ms 256 KB
example4 AC 1 ms 256 KB
maxrand0 AC 1 ms 256 KB
maxrand1 AC 3 ms 256 KB
maxrand2 AC 1 ms 256 KB
maxrand3 AC 3 ms 256 KB
maxrand4 AC 1 ms 256 KB
maxrand5 AC 3 ms 256 KB
maxrand6 AC 1 ms 256 KB
maxrand7 AC 3 ms 256 KB
maxrand8 AC 1 ms 256 KB
maxrand9 AC 3 ms 256 KB
rand0 AC 1 ms 256 KB
rand1 AC 1 ms 256 KB
rand2 AC 2 ms 256 KB
rand3 AC 2 ms 256 KB
rand4 AC 1 ms 256 KB
rand5 AC 1 ms 256 KB
rand6 AC 1 ms 256 KB
rand7 AC 2 ms 256 KB
rand8 AC 1 ms 256 KB
rand9 AC 1 ms 256 KB
small0 AC 1 ms 256 KB
small1 AC 1 ms 256 KB
small2 AC 1 ms 256 KB
small3 AC 1 ms 256 KB
small4 AC 1 ms 256 KB
small5 AC 1 ms 256 KB
small6 AC 1 ms 256 KB
small7 AC 1 ms 256 KB
small8 AC 1 ms 256 KB
small9 AC 1 ms 256 KB