# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472380 | 2021-09-13T12:41:22 Z | MamdouhN | Nadan (COCI18_nadan) | C++17 | 1 ms | 280 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" vector<int>ans; main() { int n,k; cin>>k>>n; k-=(n*(n+1))/2; int extra=k%n; int addtoall=(k-(k%n))/n; for(int i=0;i<n;i++) { int x = (i+1)+addtoall; if(i==n-1)x+=extra; ans.push_back(x); } int diff=0; for(int i=0;i<n;i++) { if(ans[i]<=0) { diff+=1-ans[i]; ans[i]=1; } else { while(ans[i]>1&&diff>0) { ans[i]--; diff--; } } } for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 0 ms | 204 KB | Output isn't correct |
6 | Incorrect | 0 ms | 204 KB | Output isn't correct |
7 | Incorrect | 0 ms | 204 KB | Output isn't correct |
8 | Correct | 1 ms | 280 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Incorrect | 0 ms | 204 KB | Output isn't correct |