QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149633#6130. Plants vs. ZombiespootyWA 85ms4688kbC++201.8kb2023-08-25 00:28:382023-08-25 00:28:39

Judging History

你现在查看的是最新测评结果

  • [2023-08-25 00:28:39]
  • 评测
  • 测评结果:WA
  • 用时:85ms
  • 内存:4688kb
  • [2023-08-25 00:28:38]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPL(i,j, n) for (int i = (j); i < (n); i++)
#define int long long
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXX = 1e6;


int solve() {
    int n,m;cin>>n>>m;
    vi arr(n);
    REP(i, n) {
        cin>>arr[i];
    }
    if (m < n) return 0;
    int mx = 1e18;
    int mn = 1e9;
    for (auto x: arr) {
        mn = min(x, mn);
    }
    while (mn < mx) {
        int md = (mn + mx + 1)/2;
        vi farr(n);
        REP(i, n) {
            farr[i] = md/arr[i];
            if (md%arr[i] != 0) {
                farr[i]++;
            }
        }
        bool can = true;
        int needed = 0;
        REP(i, n) { 
            needed += farr[i];
            if (needed > m) {
                can = false;
                mx = md-1;
                break;
            }
        }
        if (!can){
            continue;
        }
        int defneed = needed;
        needed--;
        REPL(i, 1, n) {
            int v = min(farr[i], farr[i-1]);
            farr[i-1] -= v;
            farr[i] -= v;
            if (farr[i-1] > 0) {
                needed += farr[i-1];
                if (needed > m) {
                    can - false;break;
                    mx = md-1;
                }
            }
        }
        if (!can) {
            continue;
        }
        needed += farr[n-1];
        int gg = max(defneed, needed -1);
        if (gg > m) {
            mx = md - 1;
        } else {
            mn = md;
        }
    }
    return mn;
    
}
signed main() {
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while (t--) {
        cout<<solve()<<"\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3464kb

input:

2
4 8
3 2 6 6
3 9
10 10 1

output:

6
4

result:

ok 2 number(s): "6 4"

Test #2:

score: -100
Wrong Answer
time: 85ms
memory: 4688kb

input:

116
4 0
3 2 6 6
4 1
3 2 6 6
10 19
10 2 8 4 2 4 9 3 3 3
4 8
3 9 3 6
2 19
2 10
11 15
3 1 1 4 3 7 10 8 6 7 10
10 14
8 7 1 1 10 9 2 8 10 7
2 13
2 3
10 10
8 1 6 6 9 4 7 1 8 8
7 14
6 7 4 5 3 1 3
11 6
8 1 10 9 7 2 6 6 1 3 9
4 10
6 1 3 8
7 7
10 6 2 10 4 7 2
5 11
9 10 5 9 2
9 1
2 4 8 6 2 8 8 1 6
4 5
7 2 9 8
...

output:

0
0
4
6
20
3
2
14
1
5
0
5
2
6
0
4
24
4
30
12
0
3
4
0
0
2
8
0
2
6
25
32
2
4
3
0
4
10
7
4
2
8
0
2
0
7
32
3
0
0
16
8
0
30
3
30
8
2
0
0
2
0
3
0
6
2
0
0
0
0
5
0
5
6
32
0
0
24
4
0
2
4
0
0
14
4
6
1
0
6
16
3
9
0
4
0
10
12
6
8
2
6
12
0
746
0
18
138
687
613
113
0
169
5910826
1000000000000
16561022296

result:

wrong answer 10th numbers differ - expected: '4', found: '5'