Submission #346842

#TimeUsernameProblemLanguageResultExecution timeMemory
346842arnold518MP3 Player (CEOI10_mp3player)C++14
0 / 100
1096 ms1452 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, Vmax, V2; pii A[MAXN+10]; int B[MAXN+10]; int main() { scanf("%d%d%d", &N, &Vmax, &V2); N--; int t; scanf(" %*c%d", &t); for(int i=1; i<=N; i++) { int p; char q; scanf(" %c%d", &q, &p); if(q=='+') A[i]={p-t, i}; else A[i]={p-t, -i}; t=p; } sort(A+1, A+N+1); int ans1=A[1].first-1, ans2=V2; A[N+1].first=2147483647; for(int i=1; i<=N; i++) { if(A[i].second>0) B[A[i].second]=1; else B[-A[i].second]=-1; bool flag=false; for(int j=Vmax; j>=0; j--) { int t=j; for(int k=1; k<=N; k++) { t+=B[k]; t=max(t, 0); t=min(t, Vmax); } if(t==V2) { ans1=A[i+1].first-1; ans2=j; break; } } } if(ans1==2147483646) printf("infinity\n"); else printf("%d %d\n", ans1, ans2); }

Compilation message (stderr)

mp3player.cpp: In function 'int main()':
mp3player.cpp:36:8: warning: unused variable 'flag' [-Wunused-variable]
   36 |   bool flag=false;
      |        ^~~~
mp3player.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d%d%d", &N, &Vmax, &V2); N--;
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mp3player.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf(" %*c%d", &t);
      |  ~~~~~^~~~~~~~~~~~~~
mp3player.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf(" %c%d", &q, &p);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...