QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#254996#2511. Pyramidtpc_icpc_n#AC ✓649ms3672kbC++20849b2023-11-18 14:27:302023-11-18 14:27:31

Judging History

This is the latest submission verdict.

  • [2023-11-18 14:27:31]
  • Judged
  • Verdict: AC
  • Time: 649ms
  • Memory: 3672kb
  • [2023-11-18 14:27:30]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

using i64 = long long;
constexpr int N_MAX = 1e4;
int dp[2][N_MAX];

void solve(){
    int n,k; cin >> n >> k;
    if(k==1){
        cout << 0 << '\n';
        return;
    }
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < n; j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = k-1;
    int y=0,x=0;
    for(int d=0;d<n-1;d++){
        int c =  d&1;
        if(dp[c][x]%2==0) y++;
        else x++;
        for(int i=0;i<=d;i++){
            dp[c^1][i] += (dp[c][i]+1)/2;
            dp[c^1][i+1] += (dp[c][i])/2;
        }
        rep(i,n) dp[c][i] = 0;
    }
    cout << x << '\n';
}

int main() {
    int T; cin >> T;
    while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

2
5 1
5 2

output:

0
1

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

3
5 3
5 4
5 5

output:

2
3
2

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 649ms
memory: 3604kb

input:

20
10000 100000000
9999 98987654
1234 5678
5000 20091234
1 100
1 101
7777 77777777
5890 98767897
106 67898765
2 4
9999 98987655
9999 98987656
9999 98987657
9999 98987658
9999 98987659
9999 98987660
9999 98987661
9999 98987662
9999 98987663
9999 98987664

output:

4931
5021
614
2506
0
0
3971
2907
50
1
4968
5044
5049
5002
4998
4984
5055
5045
4991
5037

result:

ok 20 lines