Submission #137627

#TimeUsernameProblemLanguageResultExecution timeMemory
137627khsoo01Bitwise (BOI06_bitwise)C++11
100 / 100
2 ms376 KiB
#include<bits/stdc++.h> using namespace std; const int N = 105; int n, m, k[N], s[N], e[N], ans; bool dn[N]; bool can (int I) { bool R = true; for(int i=1;i<=m;i++) { if(dn[i]) continue; bool F = false; for(int j=k[i-1]+1;j<=k[i];j++) { if(e[j] >= I) F = true; } if(!F) { R = false; break; } } for(int i=1;i<=m;i++) { int C1 = 0, C2 = 0; for(int j=k[i-1]+1;j<=k[i];j++) { if(e[j] >= I) { e[j] -= I; if(s[j] >= I) { C1++; s[j] -= I; } else { C2++; s[j] = 0; } } } if((!R && C2) || (C1 + C2 > 1 && C2)) dn[i] = true; } return R; } int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d",&k[i]); k[i] += k[i-1]; } for(int i=1;i<=n;i++) { scanf("%d%d",&s[i],&e[i]); } for(int i=(1<<30);i;i/=2) { if(can(i)) ans += i; } printf("%d\n", ans); }

Compilation message (stderr)

bitwise.cpp: In function 'int main()':
bitwise.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
bitwise.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&k[i]);
   ~~~~~^~~~~~~~~~~~
bitwise.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&s[i],&e[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...