Submission #7950593
Source Code Expand
#pragma GCC optimize("O3") #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <fstream> #include <functional> #include <bitset> using namespace std; using ll = long long; using P = pair<int, int>; using T = tuple<int, int, int>; template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;} template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;} constexpr int MOD = 1e9 + 7; constexpr int inf = 1e9; constexpr long long INF = 1e18; constexpr double pi = acos(-1); constexpr double EPS = 1e-10; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; vector<ll> a(n); for(int i=0; i<n; i++) cin>>a[i]; ll ans = 0; while(1){ ll amax = 0; int maxid = -1; for(int i=0; i<n; i++){ if(amax <= a[i]){ amax = a[i]; maxid = i; } } if(amax <= n - 1) break; ll cnt = amax / n; a[maxid] -= cnt * n; for(int i=0; i<n; i++){ if(i == maxid) continue; a[i] += cnt; } ans += cnt; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Decrease (Judge ver.) |
User | rodea0952 |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 1649 Byte |
Status | AC |
Exec Time | 6 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
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 | 6 ms | 256 KB |
maxrand2 | AC | 1 ms | 256 KB |
maxrand3 | AC | 6 ms | 256 KB |
maxrand4 | AC | 1 ms | 256 KB |
maxrand5 | AC | 6 ms | 256 KB |
maxrand6 | AC | 1 ms | 256 KB |
maxrand7 | AC | 6 ms | 256 KB |
maxrand8 | AC | 1 ms | 256 KB |
maxrand9 | AC | 5 ms | 256 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 2 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 | 4 ms | 256 KB |
rand8 | AC | 1 ms | 256 KB |
rand9 | AC | 2 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 |