Submission #734751

#TimeUsernameProblemLanguageResultExecution timeMemory
734751vjudge1Timovi (COCI18_timovi)C++17
70 / 80
222 ms11784 KiB
#include <bits/stdc++.h> #define B begin() #define E end() #define F first #define S second #define pb push_back #define pf push_front #define eb emplace_back #define ll long long #define ui unsigned int #define ull unsigned long long #define sts stable_sort using namespace std; const int MAXN = 1e6 + 4; const int MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, m; cin >> n >> k >> m; map<int, int> ma; if(n * k >= m){ for(int i = 0; i < n; i++){ if(m >= k){ ma[i] += k; m -= k; }else if(m > 0){ ma[i] += m; m = 0; } } for(int i = 0; i < n; i++){ cout << ma[i] << " "; }cout << "\n"; return 0; } m -= n * k; int izq = 0, der = 0, rest = (n - 1) * k; bool a = 0; while(m >= rest){ m -= rest; if(a == 0){ der += k; a = 1; }else{ izq += k; a = 0; } } if(a){ for(int i = 1; m > 0;){ if(m >= k){ ma[i] += k; m -= k; }else{ ma[i] += m; m = 0; } if(i == n - 1 && a){ a = 0; }else if(i == 0 && !a){ a = 1; } if(a)i++; else i--; } }else{ for(int i = n - 2; m > 0;){ if(m >= k){ ma[i] += k; m -= k; }else{ ma[i] += m; m = 0; } if(i == n - 1 && a){ a = 0; }else if(i == 0 && !a){ a = 1; } if(a)i++; else i--; } } for(int i = 0; i < n; i++){ if(i <= n - 2){ ma[i] += der; } if(i >= 1){ ma[i] += izq; } cout << ma[i] + k << " "; }cout << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...