QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#857710 | #9675. 电池检测 | CrayonIsGay | 10 | 326ms | 11648kb | C++14 | 1.8kb | 2025-01-15 23:45:05 | 2025-01-15 23:45:06 |
Judging History
answer
#include<bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,tune=native")
using namespace std;
// #define int long long
#define i64 __int128
#define ll long long
#define ld long double
#define vec vector
#define pii pair<ll,ll>
#define mpr make_pair
#define pb push_back
#define fir first
#define sec second
const ll N = 1010;
const ll M = 30010;
const ll V = 1.05e7;
const ll INF = (ll)1e18;
const ll mod = 1e9+7;
inline ll kpow(ll x,ll y,ll MOD){ll BASE=x%MOD,ret=1;while(y){if(y&1) ret=ret*BASE%MOD;BASE=BASE*BASE%MOD;y>>=1;}return ret;}
inline ll read(){ll ret=0,f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-') f*=-1;ch=getchar();}while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}return ret*f;}
inline ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
inline void write(ll x){if(x>=10) write(x/10);putchar('0'+x%10);}
inline void wr(ll x){if(x<0)putchar('-');write(abs(x));}
inline ll lb(ll x){return x&(-x);}
inline ll pc(ll x){ll ret=0;while(x>0)ret++,x-=lb(x);return ret;}
ll f[N][N];
void pre_work(){
for(int i=2;i<=2;i++)
for(int j=1;j<=1000;++j) f[i][j]=(i+j)*(i+j-1)/2;
for(ll i=3;i<=1000;++i)
for(ll j=1;j<=1000;++j){
if(i>j+1) f[i][j]=j+1;
else {
f[i][j]=1e18;
for(int k=1;k<=j+1;++k){
f[i][j]=min(f[i][j],f[i-1][j-(k-1)]+k*(k-1)/2);
}
}
}
}
void multi_test(){
int x,y;
cin>>x>>y;
cout<<f[x][y]<<endl;
return ;
}
int main(){
// freopen("data.in","r",stdin);
// freopen("my.out","w",stdout);
// ios::sync_with_stdio(0);cin.tie(0);
srand(time(NULL));
pre_work();
int T; cin>>T;
// int T=1;
while(T--) multi_test();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 322ms
memory: 11544kb
input:
3 2 1 3 1 2 2
output:
3 2 6
result:
ok 3 number(s): "3 2 6"
Test #2:
score: 0
Wrong Answer
time: 325ms
memory: 11348kb
input:
12 2 1 2 2 2 3 2 4 3 1 3 2 3 3 3 4 4 1 4 2 4 3 4 4
output:
3 6 10 15 2 3 6 9 2 3 4 6
result:
wrong answer 6th numbers differ - expected: '4', found: '3'
Subtask #2:
score: 5
Accepted
Test #3:
score: 5
Accepted
time: 324ms
memory: 11640kb
input:
1000 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61...
output:
3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 561 595 630 666 703 741 780 820 861 903 946 990 1035 1081 1128 1176 1225 1275 1326 1378 1431 1485 1540 1596 1653 1711 1770 1830 1891 1953 2016 2080 2145 2211 2278 2346 2415 2485 2556 2628 27...
result:
ok 1000 numbers
Subtask #3:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 326ms
memory: 11384kb
input:
1000 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61...
output:
2 3 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 15...
result:
wrong answer 2nd numbers differ - expected: '4', found: '3'
Subtask #4:
score: 5
Accepted
Test #5:
score: 5
Accepted
time: 324ms
memory: 11648kb
input:
1000 907 241 495 435 227 139 616 1 433 35 588 407 533 322 995 961 748 310 212 36 968 500 294 187 375 371 307 14 648 180 122 28 304 253 818 812 41 5 286 62 573 340 547 224 347 35 279 56 151 85 626 410 456 248 578 470 11 6 952 771 404 302 77 27 168 40 524 517 171 147 407 294 268 106 100 27 549 196 973...
output:
242 436 140 2 36 408 323 962 311 37 501 188 372 15 181 29 254 813 6 63 341 225 36 57 86 411 249 471 7 772 303 28 41 518 148 295 107 28 197 374 35 337 236 92 714 832 465 377 70 496 141 52 38 47 632 355 96 329 130 395 233 124 815 408 201 20 56 630 544 62 379 618 415 17 131 265 179 232 316 109 60 266 7...
result:
ok 1000 numbers
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%