제출 #246426

#제출 시각아이디문제언어결과실행 시간메모리
246426sealnot123Two Dishes (JOI19_dishes)C++17
0 / 100
436 ms34620 KiB
#include<bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define SZ(a) (int)(a).size() #define FOR(i, a, b) for(int i=(a); i<=(b); ++i) #define iFOR(i, a, b) for(int i=(a); i>=(b); --i) #define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin()) using namespace std; typedef pair<int,int> PII; typedef long long LL; typedef double DD; typedef long double LD; typedef pair<LL,LL> PLL; typedef pair<DD,DD> PDD; typedef vector<int> VI; typedef vector<LL> VL; const int N = 200005; LL A[N], B[N]; LL S[N], T[N]; LL P[N], Q[N]; int pillar_A[N], pillar_B[N]; int fw[2][N]; vector<int> rmv[N]; // to remove void add(int k, int i, int v, int n){ while(i <= n) fw[k][i] += v, i += (i&-i); } int get(int k, int i){ int ans = 0; while(i > 0) ans += fw[k][i], i -= (i&-i); return ans; } void print(int k, int n){ printf("fenwick %d : ",k); FOR(i, 0, n) printf("%d ",get(k, i+1)); printf("\n"); } int main(){ int n, m; scanf("%d %d",&n,&m); FOR(i, 1, n){ scanf("%lld %lld %lld",&A[i],&S[i],&P[i]); A[i] += A[i-1]; } FOR(i, 1, m){ scanf("%lld %lld %lld",&B[i],&T[i],&Q[i]); B[i] += B[i-1]; } FOR(i, 1, n){ if(S[i] < A[i]) continue; pillar_A[i] = upper_bound(B+1, B+1+m, S[i]-A[i]) - B; rmv[pillar_A[i]].pb(i+1); add(0, i+1, 1, n+1); add(1, i+1, 1, n+1); } FOR(i, 1, m){ if(T[i] < B[i]) continue; pillar_B[i] = upper_bound(A+1, A+1+n, T[i]-B[i]) - A - 1; // iterate add(0, 1, 1, n+1); add(0, pillar_B[i]+2, -1, n+1); int pivot = pillar_B[i]; int value = get(0, pivot+1); for(int e : rmv[i]) add(1, e, -1, n+1); int l = pivot, r = n; // find the last point that it is higher while(l < r){ int m = (l+r+1)>>1; if(value + get(1, m+1) - get(1, pivot+1) > get(0, m+1)) l = m; else r = m-1; } add(0, pivot+2, 1, n+1); add(0, l+2, -1, n+1); for(int e : rmv[i]){ if(e-1 <= pivot || e-1 > l) continue; add(0, e, -1, n+1); add(0, l+2, 1, n+1); } } printf("%d",get(0, n+1)); return 0; } /* * * * * * * * * * * */

컴파일 시 표준 에러 (stderr) 메시지

dishes.cpp: In function 'int main()':
dishes.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
dishes.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld",&A[i],&S[i],&P[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld",&B[i],&T[i],&Q[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...