Submission #7947207


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> a){
	ll amax = 0;
	rep(i, N) {
		amax = max(amax, a[i]);
	}
	ll res = 0;
	while(amax > N-1) {
		ll se = -1;
		rep(i, N) {
			if (a[i] > N-1) {
				se = i;
				break;
			}
		}
		ll minus = a[se]/N;
		// cout << minus << endl;
		res += minus;
		rep(i, N) {
			if (i == se) a[i] = a[i]%N; else a[i] += minus;
		}
		amax = 0;
		rep(i, N) {
			amax = max(amax, a[i]);
		}
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}

Submission Info

Submission Time
Task E - Decrease (Judge ver.)
User dn154
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1350 Byte
Status TLE
Exec Time 2103 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:54:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&N);
                  ^
./Main.cpp:57:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 5
AC × 21
TLE × 14
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 49 ms 256 KB
maxrand0 AC 1 ms 256 KB
maxrand1 TLE 2103 ms 256 KB
maxrand2 AC 1 ms 256 KB
maxrand3 TLE 2103 ms 256 KB
maxrand4 AC 1 ms 256 KB
maxrand5 TLE 2103 ms 256 KB
maxrand6 AC 2 ms 256 KB
maxrand7 TLE 2103 ms 256 KB
maxrand8 AC 6 ms 256 KB
maxrand9 TLE 2103 ms 256 KB
rand0 AC 15 ms 256 KB
rand1 TLE 2103 ms 256 KB
rand2 TLE 2103 ms 256 KB
rand3 TLE 2103 ms 256 KB
rand4 TLE 2103 ms 256 KB
rand5 TLE 2103 ms 256 KB
rand6 TLE 2103 ms 256 KB
rand7 TLE 2103 ms 256 KB
rand8 TLE 2103 ms 256 KB
rand9 TLE 2103 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