QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#268812#7744. Elevator2986858916Compile Error//C++201.0kb2023-11-28 21:42:402023-11-28 21:42:41

Judging History

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

  • [2023-11-28 21:42:41]
  • 评测
  • [2023-11-28 21:42:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define mid ((l+r)>>1)
#define int long long
#define lowbit(x) x&-x
const int N=1e7+1,mod=1e9+19;
struct node{
    int c,w,f;
    bool operator <(const node p){
        if(f==p.f)return w>p.w;
        else return f>p.f;
    }
};
void solve(){
    int n,k;cin>>n>>k;
    vector<node>a(n);
    for(auto &[c,w,f]:a)cin>>c>>w>>f;
    sort(a.begin(),a.end());
    ll ans=0;
    int p=k,cnt=0,ex=0;
    for(auto &[c,w,f]:a){
        c=c*w;
        if(w==1){
            if(c<=ex){
                ex-=c;continue;
            }else c=c-ex,ex=0;
        }
        if(c>=p){
            if(p%w)++ex;
            c-=p/w*w;
            ans+=cnt+c/k*f;
            p=k-c%k;
            if(p)cnt=f;
            else cnt=0;
        }else p-=c;
        cnt=max(cnt,f);
    }
    if(p!=k)ans+=cnt;
    cout<<ans<<'\n';
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t;cin>>t;
    while(t--){
        solve();
    }
}

详细

answer.code: In function ‘void solve()’:
answer.code:19:5: error: ‘ll’ was not declared in this scope
   19 |     ll ans=0;
      |     ^~
answer.code:31:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   31 |             ans+=cnt+c/k*f;
      |             ^~~
      |             abs
answer.code:38:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   38 |     if(p!=k)ans+=cnt;
      |             ^~~
      |             abs
answer.code:39:11: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   39 |     cout<<ans<<'\n';
      |           ^~~
      |           abs