QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#242234#7043. Image ProcessingAnwar#WA 0ms3600kbC++201.5kb2023-11-07 02:54:462023-11-07 02:54:46

Judging History

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

  • [2023-11-07 02:54:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2023-11-07 02:54:46]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 1e5 + 5 , MOD =  1e9 + 7;


int32_t main() {

    cin.tie(0);cin.sync_with_stdio(0);
    cout.tie(0);cout.sync_with_stdio(0);

   int n , k ;
   cin >> n >> k;

   ll a[n] ;

   ll  pr =  0 ;

   multiset<ll> st ;

   for(int i= 0 ; i < k -1 ;i++)
   {
       cin >> a[i] ;
       a[i] ^= pr ;
       cout << 0 << "\n" ;
       pr = 0 ;

       st.insert(a[i]) ;
   }

   ll dp[n] , best[n];

   for(int i = k-1 ; i < n; i++)
   {
       cin >> a[i] ;
       a[i] ^= pr ;


       st.insert(a[i]);

       if(i == k-1)
       {

           cout << *st.rbegin() - *st.begin() << "\n" ;

           dp[i] = *st.rbegin() - *st.begin() ;

           pr = dp[i] ;

           best[i] = -1 ;
       }
       else
       {
           best[i] = best[i-1] ;

           ll mn =*st.begin() , mx = *st.rbegin() ;

           best[i] = i-k ;

           dp[i] = max ( mx - mn , dp[ i-k ] );

           for(int j = i-k+1 ; j > best[i-1] ; j--)
           {
               mn = min( mn , a[j] ) ;
               mx = max( mx , a[j] ) ;

               if( max( mx - mn , dp[j-1] ) < dp[i] )
               {
                   dp[i] = max( mx - mn , dp[j-1] ) ;
                   best[i] = j-1;
               }
           }

           cout << dp[i] << "\n" ;

           pr = dp[i] ;
       }

       st.erase( st.find( a[i-k+1] ) ) ;
   }


    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

5 2
50 110 190 120 34

output:

0
60
40
50
64

result:

wrong answer 3rd numbers differ - expected: '80', found: '40'