답안 #1031894

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031894 2024-07-23T08:30:29 Z qrn Nadan (COCI18_nadan) C++14
10 / 50
0 ms 452 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ep eneededlace_back
#define ins insert
#define fi first
#define er erase
#define se second
template<class ISqr, class T>
ISqr& operator>>(ISqr& is, vector<T>& v) { for (auto& x : v) is >> x;    }
#define give(v)        \
    cout << v << eel; \
    return;
#define print(a)          \
    for (auto v : a)      \
    {                     \
        cout << v << " "; \
    }                     \
    cout << eel;
#define vs vector<sqring>
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int, int>
#define vvi vector<vector<int>>
#define sz(x) x.size()
#define vpii vector<pair<int, int>>
#define SPEED                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define ALL(x) x.begin(), x.end()
#define endl "\n"
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define out cout << endl;
#define impos cout << -1 << endl;
#define int long long
const long double pi = 2 * acosl(0);
const int sz = 1e5 + 5;
const int inf = 1e13 + 31;

void solve(){
    int k, n;
    cin >> k >> n;
    if(k % n == 0){
        int subadd = 1;
        vi v;
        while(sz(v) != n){
            v.pb(k / n);
        }
        vi ans;
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                ans.pb(v[i] + subadd);
            } else {
                ans.pb(v[i] - subadd);
                subadd++;
            }
        }
        if(n % 2 != 0){
            ans[sz(ans)-1] = k/n;
        }
        for(int i : ans) cout << i << endl;
    } else {
        int subadd = 1;
        vi v;
        while(sz(v) != n){
            v.pb(k / n);
        }
        vi ans;
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                ans.pb(v[i] + subadd);
            } else {
                ans.pb(v[i] - subadd);
                subadd++;
            }
        }
        if(n % 2 != 0) {
            ans[sz(ans)-1] = k/n;
        }
        int maks = 0;
        for(int i : ans) maks = max(maks, i);
        for(int i : ans){
            if(i == maks) cout << i + (k % n) << endl;
            else cout << i << endl;
        }
    }
}

signed main() {
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
    SPEED;
    int tst = 1;
    // cin >> tst;
    for (int cs = 1; cs <= tst; cs++) {
        solve();
    }
    // cerr << "Time Elapsed: " << (long double)clock() << endl;
}

Compilation message

nadan.cpp: In function 'void solve()':
nadan.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   48 |         while(sz(v) != n){
      |                     ^
nadan.cpp:67:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   67 |         while(sz(v) != n){
      |                     ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 452 KB Output isn't correct