QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197135#6135. BooksHarryJCompile Error//C++231.4kb2023-10-02 11:56:322023-10-02 11:56:33

Judging History

This is the latest submission verdict.

  • [2023-10-02 11:56:33]
  • Judged
  • [2023-10-02 11:56:32]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const int INF=0x3f3f3f3f;
const int N=1e5+10;
LL a[N];
int n,m;

void solve()
{
    cin>>n>>m;
    
    LL zero=0,miv=INF;
    
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        
        miv=min(miv,a[i]);
        if(!a[i]) zero++;
    }
    
    if(n==m) cout<<"Richman"<<endl;
    else if(!m) cout<<miv-1<<endl;
    else if(zero>m) cout<<"Impossible"<<endl;
    else
    {
        //m-=zero;
        // LL ans=0;
        // int id=-1;
        // LL miv=INF;
        
        // for(int i=1;i<=n&&m;i++)
        //     if(a[i]) ans+=a[i],m--,id=i;
            
        // for(int i=id+1;i<=n;i++) 
        //     if(a[i]) miv=min(miv,a[i]);
            
        // cout<<ans+miv-1<<endl;
        
        ll sum = 0;
        for(i = 1; i <= n; i++) {
            if(k == m)//易错
                break;
            if(a[i] != 0) {
                sum += a[i];
                k++;
            }
        }
        mi = inf;
        for(; i <= n; i++) {
            if(a[i] != 0) 
                mi = min(a[i], mi);
        }
        printf("%lld\n", sum + mi - 1);
    }
    
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int tt; cin>>tt;
    
    while(tt--) solve();
    
    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:44:9: error: ‘ll’ was not declared in this scope; did you mean ‘LL’?
   44 |         ll sum = 0;
      |         ^~
      |         LL
answer.code:45:13: error: ‘i’ was not declared in this scope
   45 |         for(i = 1; i <= n; i++) {
      |             ^
answer.code:46:16: error: ‘k’ was not declared in this scope
   46 |             if(k == m)//易错
      |                ^
answer.code:49:17: error: ‘sum’ was not declared in this scope
   49 |                 sum += a[i];
      |                 ^~~
answer.code:50:17: error: ‘k’ was not declared in this scope
   50 |                 k++;
      |                 ^
answer.code:53:9: error: ‘mi’ was not declared in this scope; did you mean ‘miv’?
   53 |         mi = inf;
      |         ^~
      |         miv
answer.code:53:14: error: ‘inf’ was not declared in this scope; did you mean ‘ynf’?
   53 |         mi = inf;
      |              ^~~
      |              ynf
answer.code:54:15: error: ‘i’ was not declared in this scope
   54 |         for(; i <= n; i++) {
      |               ^
answer.code:58:26: error: ‘sum’ was not declared in this scope
   58 |         printf("%lld\n", sum + mi - 1);
      |                          ^~~