답안 #1031479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031479 2024-07-22T21:31:37 Z 7again Timovi (COCI18_timovi) C++17
80 / 80
543 ms 3036 KB
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define in insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0)

using namespace std ;

void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}

const int N = 300000 , MOD = 1e9+7 ;

//bool inside(int x,int y){return(x<n&&y<m&&x>-1&&y>-1&&a[x][y]!='#');}

//int dx[4]{1 , -1 , 0 , 0} , dy[4]{0 , 0 , 1 , -1} ;


void slv()
{
    int n , m , k ;
    cin >> n >> m >> k ;


    int ok = 1 ;
    int ans[n]{0} ;
    int i = 0 ;
    while(k)
    {
        if(ok)
        {
            int x = min(m , k) ;
            ans[i] += x ;
            k -= x ;
            i++ ;
            if(i == n - 1)
                ok = 0 ;
        }
        else
        {
            int x = min(m , k) ;
            ans[i] += x ;
            k -= x ;
            i-- ;
            if(i == 0)
                ok = 1 ;
        }
    }

    for(int i = 0 ; i < n ; i++)
        cout << ans[i] << " " ;
}
main()
{
    //setIO("lasers") ;

    FAST ;

    int t = 1 ;
    //cin >> t ;

    while(t--)
        slv() ;
}

Compilation message

timovi.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   59 | main()
      | ^~~~
timovi.cpp: In function 'void setIO(std::string)':
timovi.cpp:16:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
timovi.cpp:16:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 8 ms 2436 KB Output is correct
4 Correct 7 ms 2396 KB Output is correct
5 Correct 543 ms 348 KB Output is correct
6 Correct 279 ms 348 KB Output is correct
7 Correct 407 ms 2896 KB Output is correct
8 Correct 541 ms 3036 KB Output is correct