# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
861033 | 2023-10-15T07:16:48 Z | guagua0407 | Two Dishes (JOI19_dishes) | C++17 | 145 ms | 97476 KB |
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=1e6+5; ll a[mxn],S[mxn],Q[mxn]; ll b[mxn],T[mxn],P[mxn]; int pa[mxn],pb[mxn]; vector<int> qa[mxn],qb[mxn]; int n,m; int main() {_ cin>>n>>m; for(int i=1;i<=n;i++){ cin>>a[i]>>S[i]>>P[i]; a[i]+=a[i-1]; } for(int i=1;i<=m;i++){ cin>>b[i]>>T[i]>>Q[i]; b[i]+=b[i-1]; } for(int i=1;i<=n;i++){ int pos=upper_bound(b,b+m+1,S[i]-a[i])-b-1; pa[i]=pos; if(pos>=0) qa[pos].push_back(i); } for(int i=1;i<=m;i++){ int pos=upper_bound(a,a+n+1,T[i]-b[i])-a-1; pb[i]=pos; if(pos>=0) qb[pos].push_back(i); } /*for(int i=1;i<=n;i++){ cout<<pa[i]<<' '; }cout<<'\n'; for(int i=1;i<=m;i++){ cout<<pb[i]<<' '; }cout<<'\n';*/ ll ans=0; int cur=1; for(int i=1;i<=n;i++){ while(cur<=m){ ll sum=0; if(pb[cur]>=i-1) sum+=Q[cur]; for(auto v:qa[cur-1]){ if(v>=i) sum-=P[v]; } if(sum>0){ if(pb[cur]>=i-1) ans+=Q[cur]; cur++; } else break; } if(pa[i]>=cur-1){ ans+=P[i]; } //cout<<cur<<' '<<ans<<'\n'; } for(;cur<=m;cur++){ if(pb[cur]==n) ans+=Q[cur]; } cout<<ans<<'\n'; return 0; } //maybe its multiset not set
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 145 ms | 97476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 62044 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62168 KB | Output is correct |
4 | Correct | 13 ms | 62176 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62044 KB | Output is correct |
7 | Incorrect | 12 ms | 62044 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 62044 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62168 KB | Output is correct |
4 | Correct | 13 ms | 62176 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62044 KB | Output is correct |
7 | Incorrect | 12 ms | 62044 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 62044 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62168 KB | Output is correct |
4 | Correct | 13 ms | 62176 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62044 KB | Output is correct |
7 | Incorrect | 12 ms | 62044 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 62044 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62168 KB | Output is correct |
4 | Correct | 13 ms | 62176 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62044 KB | Output is correct |
7 | Incorrect | 12 ms | 62044 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 62044 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62168 KB | Output is correct |
4 | Correct | 13 ms | 62176 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62044 KB | Output is correct |
7 | Incorrect | 12 ms | 62044 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 145 ms | 97476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 145 ms | 97476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |