Submission #137493

# Submission time Handle Problem Language Result Execution time Memory
137493 2019-07-28T04:52:45 Z gs14004 Coins (BOI06_coins) C++17
0 / 100
3 ms 380 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, lint>;
const int MAXN = 20005;

lint m;
int t, n, a[MAXN];

lint sum(lint x, lint c){
	return 2 * x * c * (c + 1) + 4 * t * ((c + 1) * c * (c - 1) / 3);
}

pi trial(lint v){
	pi ret(0, 0);
	for(int i=0; i<n; i++){
		if(v < a[i]) break;
		lint cnt = (v - a[i]) / t + 1;
		if(cnt > 1e6){
			ret.first = m + 10ll;
			return ret;
		}
		ret.first += cnt * (cnt + 1) * 2;
		ret.second += sum(a[i], cnt);
	}
	return ret;
}

int main(){
	cin >> m >> t >> n;
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	lint s = 0, e = 1e14;
	while(s != e){
		lint mi = (s+e+1)/2;
		if(trial(mi).first <= m) s = mi;
		else e = mi-1;
	}
	auto x = trial(s);
	cout << x.second + (m - x.first) * (s + 1) << endl;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:31:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%d",&a[i]);
                         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Incorrect 2 ms 380 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Incorrect 3 ms 376 KB Output isn't correct