제출 #1121039

#제출 시각아이디문제언어결과실행 시간메모리
1121039Haciyev12Stove (JOI18_stove)C++17
0 / 100
1 ms336 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define in insert #define F first #define S second #define vll vector<ll> #define all(v) v.begin(),v.end() #define endl '\n' #define pii pair<ll,ll> using namespace std; const ll INF =1e18, mod = 1e9 + 7, N = 1e5 + 5; void solve(){ ll n,m; cin >> n >> m; ll xw; vll v; for(int i = 0; i < n; i++){ cin >> xw; v.pb(xw); } if(n == m){ cout << n << endl; return; } if(m == 1){ cout << v[v.size() - 1] + 1 - v[0] << endl; return; } ll x = 0; ll in = -1; for(int i = 0; i < v.size(); i+=2){//0 1 2 3 4 if(m == 1 && (i + 1 != v.size() || i == v.size() - 1)){ in = i; break; } // cout <<v[i + 1] << " " << v[i] << endl; x += v[i + 1] + 1 - v[i]; m--; } // cout << in <<endl; if(in != -1){ x += v[v.size() - 1] + 1 - v[in]; } cout << x << endl; } int main(){ fast; solve(); return 0; }

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

stove.cpp: In function 'void solve()':
stove.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 0; i < v.size(); i+=2){//0 1 2  3 4
      |                    ~~^~~~~~~~~~
stove.cpp:34:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(m == 1 && (i + 1 != v.size() || i == v.size() - 1)){
      |                       ~~~~~~^~~~~~~~~~~
stove.cpp:34:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(m == 1 && (i + 1 != v.size() || i == v.size() - 1)){
      |                                            ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...