結果
| 問題 |
No.3245 Payment with 8-rep Currency
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-22 22:35:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,483 bytes |
| コンパイル時間 | 2,128 ms |
| コンパイル使用メモリ | 201,352 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-08-22 22:36:36 |
| 合計ジャッジ時間 | 5,803 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long all = 9872/8;
vector<tuple<int,int,int,int>> V(all+all+all);
for(int v=0; v<all+all+all; v++){
int best = 1001001001;
bool ok = false;
for(int d=0; d*1111<=v&&ok==false; d++){
for(int c=0; c*111+d*1111<=v&&ok==false; c++){
for(int b=0; b*11+c*111+d*1111<=v&&ok==false; b++){
int a = v-d*1111-c*111-b*11;
int sum = a+b+c+d,use = max({a,b,c,d});
if(use+use < sum) V.at(v) = {a,b,c,d},ok = true;
else if(best > use+use-sum) best = use+use-sum,V.at(v) = {a,b,c,d};
}
}
}
//if(!ok){cout << v << " " << best << endl;}
}
int T; cin >> T;
while(T--){
long long N; cin >> N;
if(N%8){cout << "-1\n"; continue;}
N /= 8;
if(N < all+all+all){
auto [a,b,c,d] = V.at(N);
long long use = max({a,b,c,d}),sum = a+b+c+d;
if(use+use >= sum) cout << "-1\n";
else cout << a << " " << b << " " << c << " " << d << "\n";
}
else{
long long pos = N%all;
N -= all*3+pos;
auto [a,b,c,d] = V.at(pos+all+all);
assert(N%all == 0);
cout << a+all << " " << b+all << " " << c+all << " " << d+all << "\n";
}
}
}