QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#688707 | #7744. Elevator | Time_stop | Compile Error | / | / | C++17 | 676b | 2024-10-30 12:50:45 | 2024-10-30 12:50:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool cmp(pair<ll,ll> a,pair<ll,ll> b){
return a.first>=b.first;
}
void solve(){
ll n,k;
vector<pair<ll,ll> > a;
cin>>n>>k;
for(int i=0;i<n;i++){
ll x,y,z;
cin>>x>>y>>z;
a.push_back({z,x*y});
}
a.push_back({0,1});
sort(a.begin(),a.end(),cmp);
ll ans=0;
ll now=a[0].first,sum=0;
for(auto it:a;){
sum+=it.second;
if(sum>k){
ans+=now;
sum-=k;
now=it.first;
ll c=(sum-1)/k;
ans=ans+c*now;
sum=sum-c*k;
}
}
ans+=now;
cout<<ans<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
}
Details
answer.code: In function ‘void solve()’: answer.code:23:22: error: expected ‘)’ before ‘;’ token 23 | for(auto it:a;){ | ~ ^ | ) answer.code:23:23: error: expected primary-expression before ‘)’ token 23 | for(auto it:a;){ | ^