제출 #1297581

#제출 시각아이디문제언어결과실행 시간메모리
1297581trandangquangWorst Reporter 3 (JOI18_worst_reporter3)C++20
19 / 100
2093 ms5416 KiB
#include<bits/stdc++.h> using namespace std; #define foru(i,a,b) for(int i=(a); i<=(b); ++i) #define ford(i,a,b) for(int i=(a); i>=(b); --i) #define rep(i,a) for(int i=0; i<(a); ++i) #define sz(a) (int)(a).size() #define all(a) (a).begin(),(a).end() #define bit(s,i) (((s)>>(i))&1) #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define fi first #define se second #define ll long long #define eb emplace_back #define pb push_back #define __builtin_popcount __builtin_popcountll #define _ << " " << template <class X, class Y> bool maxi(X &x, Y y){return x<y?x=y,true:false;} template <class X, class Y> bool mini(X &x, Y y){return x>y?x=y,true:false;} const int N=505050; int n,q,d[N],e[N],cnt; void solve(){ cin>>n>>q; d[0]=1; foru(i,1,n)cin>>d[i]; foru(i,0,n){ if(cnt==0 || d[e[cnt]]<d[i]){ e[++cnt]=i; } } e[cnt+1]=n+1; // cout<<e[2]<<'\n'; foru(qq,1,q){ int t,l,r; cin>>t>>l>>r; int x=t, y=1, res=0; foru(i,1,cnt){ if(y==0 || x==0) break; int nx=x/((d[e[i]]+y-1)/y), ny=(d[e[i]]+y-1)/y*y; int L=-(e[i+1]-1), R=-e[i]; L=L+nx*ny, R=R+nx*ny; res+=max(0,min(R,r)-max(L,l)+1); x=nx, y=ny; } cout<<res<<'\n'; } } int32_t main(){ #define task "test" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); int tc=1; //cin>>tc; foru(i,1,tc){ solve(); } }

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

worst_reporter3.cpp: In function 'int32_t main()':
worst_reporter3.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...