Submission #242213

#TimeUsernameProblemLanguageResultExecution timeMemory
242213SomeoneUnknownWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
792 ms5624 KiB
#include <bits/stdc++.h> using namespace std; int posof(int slow, int id, int tiem){ //printf("%d at pos %d at time %d\n", id, (tiem/slow)*slow-id, tiem); return (tiem/slow)*slow-id; } int main(){ int n, q; scanf("%d %d", &n, &q); int dancers[n+1]; dancers[0] = 1; for(int i = 0; i < n; ++i){ scanf("%d", &dancers[i+1]); --dancers[i+1]; dancers[i+1] /= dancers[i]; ++dancers[i+1]; dancers[i+1] *= dancers[i]; } for(int i = 0; i < q; ++i){ int t,s,e; scanf("%d %d %d", &t, &s, &e); ++e; int lo, hi; //Find how many dancers are after the end lo = -1; hi = n+1; int mid; while(hi-lo>1){ mid = (hi+lo)/2; if(posof(dancers[mid],mid,t) < e){ hi = mid; }else{ lo = mid; } } e = hi; //Find how many dancers are after the start lo = -1; hi = n+1; while(hi-lo>1){ mid = (hi+lo)/2; if(posof(dancers[mid],mid,t) < s){ hi = mid; }else{ lo = mid; } } s = hi; printf("%d\n",s-e); } } /* 3 6 2 5 3 1 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 4 */

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &dancers[i+1]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &t, &s, &e);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...