Submission #341935

#TimeUsernameProblemLanguageResultExecution timeMemory
341935HazemPreokret (COCI18_preokret)C++14
50 / 50
1 ms364 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 2e5 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; int MOD = 1e9+7; vector<pair<int,int>>vec; int cnt[N][2]; int main() { // freopen("out.txt","w",stdout); int n,m; scanf("%d",&n); for(int i=1;i<=n;i++){ int x;scanf("%d",&x); vec.push_back({x,0}); } scanf("%d",&m); for(int i=1;i<=m;i++){ int x;scanf("%d",&x); vec.push_back({x,1}); } vec.push_back({0,3}); sort(vec.begin(),vec.end()); int cnt1 = 0,cnt2 = 0; for(int i=1;i<vec.size();i++){ if(vec[i].F<=1440)cnt1++; for(int j=0;j<2;j++) cnt[i][j] = cnt[i-1][j]+(vec[i].S==j); if(i<=2||cnt[i][0]==cnt[i][1])continue; int idx = cnt[i][0]>cnt[i][1]?0:1; cnt2 += cnt[i-2][idx]<cnt[i-2][!idx]; } printf("%d\n%d",cnt1,cnt2); }

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=1;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
preokret.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
preokret.cpp:31:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         int x;scanf("%d",&x);
      |               ~~~~~^~~~~~~~~
preokret.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
preokret.cpp:36:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |         int x;scanf("%d",&x);
      |               ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...