Submission #13538212


Source Code Expand

#include<cstdio>
#include<map>
#include<set>
#include<queue>
long long int n;
long long int a, b, c, d;
std::map<long long int, long long int> codemp;
std::set<long long int> chkset;
struct st {
	long long int v, c;
	bool operator<(const st&r)const {
		return c > r.c;
	}
};
std::priority_queue<st> pq;
long long int ans;
void pqinsert(long long int v, long long int c) {
	if (codemp.find(v) != codemp.end()) {
		if (codemp[v] < c)return;
	}
	codemp[v] = c;
	st p;
	p.v = v;
	p.c = c;
	pq.push(p);
}
int main() {
	int tcn;
	scanf("%d", &tcn);
	while (tcn--) {
		scanf("%lld", &n);
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		ans = (a + d) * 100LL;
		codemp[n] = 0;
		st initp;
		initp.v = n;
		initp.c = 0;
		pq.push(initp);
		while (pq.size() > 0) {
			st pa = pq.top();
			pq.pop();
			long long int pv = pa.v;
			long long int pc = pa.c;
			if (chkset.find(pv) != chkset.end()) {
				continue;
			}
			chkset.insert(pv);
			pqinsert(pv / 2, a + pc + d * (pv % 2));
			pqinsert(pv / 2 + 1, a + pc + d * (2 - pv % 2));
			pqinsert(pv / 3, b + pc + d * (pv % 3));
			pqinsert(pv / 3 + 1, b + pc + d * (3 - pv % 3));
			pqinsert(pv / 5, c + pc + d * (pv % 5));
			pqinsert(pv / 5 + 1, c + pc + d * (5 - pv % 5));
			if ((ans - pc + d - 1) / d > pv) {
				ans = pv * d + pc;
			}
		}
		codemp.clear();
		chkset.clear();
		printf("%lld\n", ans);
	}
	return 0;
}

Submission Info

Submission Time
Task A - Pay to Win
User gs12117
Language C++ (GCC 9.2.1)
Score 400
Code Size 1425 Byte
Status AC
Exec Time 277 ms
Memory 5444 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   29 |  scanf("%d", &tcn);
      |  ~~~~~^~~~~~~~~~~~
./Main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   31 |   scanf("%lld", &n);
      |   ~~~~~^~~~~~~~~~~~
./Main.cpp:32:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   32 |   scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 10
Set Name Test Cases
Sample example0.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, example0.txt
Case Name Status Exec Time Memory
000.txt AC 10 ms 3212 KiB
001.txt AC 2 ms 3156 KiB
002.txt AC 2 ms 3292 KiB
003.txt AC 2 ms 3240 KiB
004.txt AC 1 ms 3236 KiB
005.txt AC 277 ms 5444 KiB
006.txt AC 174 ms 4648 KiB
007.txt AC 209 ms 5024 KiB
008.txt AC 181 ms 4800 KiB
example0.txt AC 49 ms 5304 KiB