제출 #722853

#제출 시각아이디문제언어결과실행 시간메모리
722853vjudge1Timovi (COCI18_timovi)C++17
20 / 80
1096 ms10152 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);

    ll n, c, cnt; cin >> n >> c >> cnt;
    if(n == 1){
        cout << cnt << "\n";
        return 0;
    }
    unordered_map<ll, ll> m;
    bool a = 1;
    int pos = 2;
    for(ll i = 0; cnt > 0; ){
        if(cnt >= c){
            m[i] += c;
            cnt -= c;
        }else{
            m[i] += cnt;
            cnt = 0;
        }
        if(n >= 3){
            if(i == pos){
                a = 0;
                pos++;
            }else if(i == 0 && !a){
                a = 1;
            }
        }else{
            if(i == 1){
                a = 0;
                pos++;
            }else if(i == 0 & !a){
                a = 1;
            }
        }
        if(pos == n)pos--;
        if(a)i++;
        else i--;
    }

    for(int i = 0; i < n; i++){
        cout << m[i] << " ";
    }
    cout << "\n";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

timovi.cpp: In function 'int main()':
timovi.cpp:49:24: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   49 |             }else if(i == 0 & !a){
      |                      ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...