Submission #7589497


Source Code Expand

Copy
#include<iostream>
#include<vector>

using namespace std;

typedef long long L11;

#define res(i,a,b) for(int i=a;i<b;++i)

int main() {

	int N;
	L11 Y;

	cin >> N >> Y;

	bool exist = false;

	L11 total = 0;
	vector<int> sum;

	int i = 0, j = 0, k = 0;

	res(i, 0, N) {
		res(j, 0, N) {
			//res(k, 0, N) {	//ループ三回では非常に計算量が多い

			k = N - (i * j);
			total = 10000 * i + 5000 * j + 1000 * k;
			//cout << total << endl;
			if (total == Y && i + j + k == N) {
				sum.push_back(i);
				sum.push_back(j);
				sum.push_back(k);
				exist = true;
			}
		}
		if (exist)break;
	}	





	if (exist==true) {
		for (int i = 0; i < sum.size(); ++i)
			cout << sum[i] << " ";
	}
	if(exist==false)
		cout << "-1 -1 -1" << endl;

}

Submission Info

Submission Time
Task A - AtCoder Group Contest
User kangjoon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 804 Byte
Status
Exec Time 2103 ms
Memory 256 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 00_example_01.txt, 00_example_02.txt
All 0 / 300 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt
Case Name Status Exec Time Memory
00_example_01.txt 1 ms 256 KB
00_example_02.txt 1 ms 256 KB
01.txt 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 85 ms 256 KB
06.txt 2103 ms 256 KB
07.txt 2103 ms 256 KB
08.txt 2103 ms 256 KB
09.txt 2103 ms 256 KB
10.txt 2103 ms 256 KB