Submission #83851

#TimeUsernameProblemLanguageResultExecution timeMemory
83851nikolapesic2802Karte (COCI18_karte)C++14
120 / 120
534 ms28732 KiB
/* - Keep a variable k- how many cards need to be wrong until the end. */ #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int main() { int n,k; scanf("%i %i",&n,&k); int t=k; multiset<int> karte; karte.insert(INT_MAX); for(int i=0;i<n;i++) { int a; scanf("%i",&a); karte.insert(a); } vector<int> sol; for(int i=0;i<n;i++) { int a=*karte.lower_bound(k); if(a==INT_MAX) { a=*karte.begin(); } sol.pb(a); karte.erase(karte.find(a)); if(a!=k) k--; continue; } int cnt=0; for(int i=n-1;i>=0;i--) { if(sol[i]<=cnt) continue; cnt++; } if(cnt==t) { for(int i=0;i<n;i++) { printf("%i ",sol[i]); } } else { printf("-1"); } return 0; }

Compilation message (stderr)

karte.cpp: In function 'int main()':
karte.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i %i",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~
karte.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&a);
         ~~~~~^~~~~~~~~
#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...