QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#414957#2929. Concert RehearsalTheSleepyDevilWA 2ms13416kbC++174.1kb2024-05-20 05:35:022024-05-20 05:35:03

Judging History

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

  • [2024-05-20 05:35:03]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:13416kb
  • [2024-05-20 05:35:02]
  • 提交

answer

/*
     Hell, 'til I reach Hell, I ain't scared
     Mama checkin' in my bedroom, I ain't there
                                                */
    #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;

    #define Major  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    #define read(a,n) for(int i = 0 ; i<n ; i++) cin>>a[i];
    #define write(a) for(auto x : a) cout<<x<<" ";
    #define int long long
    #define pb push_back
    #define all(a)  a.begin(),a.end()
    #define el "\n"

    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

    const int inf=4e18;

    int dx[]={1,0,-1,0,1,1,-1,-1};
    int dy[]={0,1,0,-1,1,-1,1,-1};

    const int mod=1e9+7;
    const int MAX =1e6+7;

   // ---------------------------Function----------------------------------//
    int n,p,k;
     vector<array<int,2>>arr;
     vector<int>pre;
     int check(int st,int kam){
        int sum=0;
        int cnt=kam/n,lft=kam%n;
        sum+=cnt*pre[n-1];
        if((st+lft-1<=0))return sum;
        sum+=pre[min(n-1,st+lft-1)]-(!st?0:pre[st-1]);

         int mnfo2=0;
         if((st+lft-1)>=n){
            mnfo2=n-(st+lft-1);
             sum+=pre[mnfo2];
         }
//        cout<<sum<<" "<<mnfo2<<el;
//        cout<<mnfo2<<el;


        return sum;
     }
     int vis[MAX],ans[MAX],base[MAX];
    void TestCake(){
        cin>>n>>p>>k;

        int sum=0;
        for(int i=0;i<n;i++){
            int x;cin>>x;
            arr.pb({x,i});sum+=x;
            pre.pb(sum);
        }
        vector<array<int,2>>nxt;
        for(int i=0;i<n;i++){
            int l=1,r=1e9,z=1;
            while(l<=r){
                int mid=(l+r)/2;
                if(check(i,mid)>p){
                    z=mid;
                    r=mid-1;
                }
                else{
                    l=mid+1;
                }

            }
//        cout<<check(i,r)<<" "<<i<<" "<<r<<el;

           nxt.pb({(i+r)%n,r});
//           cout<<i<<" "<<(i+r)%n<<" "<<r<<el;
        }
        memset(vis,-1,sizeof vis);
        int st=0,cnt=0;
        vector<array<int,3>>here;
        while(vis[st]==-1){
            vis[st]=cnt;
            here.pb({st,nxt[st][0],nxt[st][1]});
            st=nxt[st][0];
            cnt++;
        }
         here.pb({st,nxt[st][0],nxt[st][1]});
//        cout<<cnt<<el;
//          for(auto x : here){
//             cout<<x[0]<<" "<<x[1]<<" "<<x[2]<<el;
//           }
        int tot=0;
        if(cnt>=k){
            for(int i=0;i<here.size()-1&&k--;i++){
                 int l=here[i][0],r=here[i][1];
//                 cout<<l<<" "<<r<<el;
                 int m3aya=here[i][2],zyada=here[i][2]%n;
                 tot+=m3aya;
            }

        }
        else{
            k-=cnt;

//            cout<<k<<" "<<cnt<<el;
            int id=0;
            for(int i=0;i<here.size();i++){
                if(here[i]==here.back()){id=i;break;}
            }
            int sz=(cnt-id);
            for(int i=0;i<here.size()-1;i++){
                 int m3aya=here[i][2],zyada=here[i][2]%n;
                 tot+=m3aya;

            }
            int have=(k/sz),ba2y=(k%sz);
            for(int i=id;i<here.size()-1;i++){
                 int m3aya=here[i][2],zyada=here[i][2]%n;
                tot+=(have*m3aya);
            }
            for(int i=id;i<here.size()-1&&ba2y--;i++){
                 int m3aya=here[i][2];
                 tot+=(m3aya);
            }
        }
//        cout<<tot<<el;
        cout<<tot/n<<el;

    }
    //------------------------------Main---------------------------//
    signed main(){
        Major
        int T = 1;
//        cin >> T;
        while(T--){
            TestCake();
        //       cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
        }
        return 0;
    }

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 13152kb

input:

3 20 10
6
9
5

output:

10

result:

ok single line: '10'

Test #2:

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

input:

5 11 2
5
5
5
5
5

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 2ms
memory: 11740kb

input:

7 11 3
1
2
3
4
5
6
7

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 2ms
memory: 12208kb

input:

4 8 9
2
7
2
3

output:

4

result:

ok single line: '4'

Test #5:

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

input:

1 3 7
2

output:

7

result:

ok single line: '7'

Test #6:

score: 0
Accepted
time: 2ms
memory: 11572kb

input:

1 1000000000 1000000000
1

output:

1000000000000000000

result:

ok single line: '1000000000000000000'

Test #7:

score: 0
Accepted
time: 2ms
memory: 12844kb

input:

5 999999999 999999999
2
1
4
7
3

output:

58823528941176471

result:

ok single line: '58823528941176471'

Test #8:

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

input:

5 5 1000
2
2
2
2
2

output:

400

result:

ok single line: '400'

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 12140kb

input:

980 991 978
2
1
2
1
2
3
1
1
1
3
3
3
2
2
2
2
3
3
1
3
1
2
2
3
1
2
3
3
2
3
1
2
2
3
1
3
1
3
2
2
2
1
1
2
3
3
1
2
1
1
1
2
2
2
3
3
2
1
3
3
1
3
3
1
1
2
1
1
1
1
2
1
2
3
2
1
1
3
3
2
2
1
3
3
3
2
2
3
1
2
3
3
2
2
3
2
3
2
2
2
1
3
3
1
1
3
1
2
2
2
2
1
2
2
1
1
3
2
1
1
3
1
2
3
3
3
3
3
2
2
2
3
3
1
1
2
1
3
3
3
2
2
2
3
...

output:

489

result:

wrong answer 1st lines differ - expected: '492', found: '489'